@@ -62,7 +62,24 @@ def load_yaml(path: str) -> dict:
6262 return json .loads (result .stdout )
6363
6464
65- def parse_config (config_path : str , section : str , runner_type : str ) -> dict [str , str ]:
65+ def matches_customer_type (model : dict , customer_type : str ) -> bool :
66+ """A model runs on a config unless it pins a different customer_type.
67+
68+ Models without a ``customer_type`` field run everywhere (backward
69+ compatible). A model that pins e.g. ``customer_type: sagemaker`` only runs
70+ when the config's customer type matches — used to gate tests for features
71+ that exist on only one container variant (e.g. the SageMaker routing
72+ middleware, which adds the JSON->multipart video path absent on EC2).
73+ """
74+ pinned = model .get ("customer_type" )
75+ if not pinned or not customer_type :
76+ return True
77+ return pinned == customer_type
78+
79+
80+ def parse_config (
81+ config_path : str , section : str , runner_type : str , customer_type : str = ""
82+ ) -> dict [str , str ]:
6683 cfg = load_yaml (config_path )
6784
6885 s3_prefix = cfg .get ("s3_prefix" , "" )
@@ -73,6 +90,7 @@ def parse_config(config_path: str, section: str, runner_type: str) -> dict[str,
7390
7491 for rt in types :
7592 models = cfg .get (section , {}).get (rt , []) or []
93+ models = [m for m in models if matches_customer_type (m , customer_type )]
7694 transformed = [transform_model (m , s3_prefix , fixtures_prefix ) for m in models ]
7795 key = rt if runner_type == "all" else "matrix"
7896 results [key ] = json .dumps (transformed , separators = ("," , ":" ))
@@ -91,13 +109,19 @@ def main():
91109 default = "all" ,
92110 help = "Runner type: all, codebuild-fleet, or runner-scale-sets" ,
93111 )
112+ parser .add_argument (
113+ "--customer-type" ,
114+ default = "" ,
115+ help = "Config customer type (e.g. ec2, sagemaker). When set, drops models "
116+ "that pin a different customer_type. Empty = include all models." ,
117+ )
94118 args = parser .parse_args ()
95119
96120 if not os .path .isfile (args .config ):
97121 print (f"ERROR: Config file not found: { args .config } " , file = sys .stderr )
98122 sys .exit (1 )
99123
100- results = parse_config (args .config , args .section , args .runner_type )
124+ results = parse_config (args .config , args .section , args .runner_type , args . customer_type )
101125
102126 output_file = os .environ .get ("GITHUB_OUTPUT" )
103127 if output_file :
0 commit comments