@@ -232,15 +232,13 @@ def _gather_cron_blueprints(self):
232232 def run_blueprint_via_api (
233233 self ,
234234 blueprint_id : str ,
235- trigger_type : Literal ["API" , "Cron" ],
236235 branch_id : Optional [str ] = None ,
237236 execution_environment : Optional [Dict [str , Any ]] = None
238237 ):
239238 """
240239 Executes a blueprint by its key via the API.
241240
242241 :param blueprint_id: The blueprint identifier.
243- :param trigger_type: The type of trigger ("API" or "Cron").
244242 :param branch_id: Optional branch ID to start execution from.
245243 :param execution_environment: The execution environment for
246244 the blueprint.
@@ -250,13 +248,24 @@ def run_blueprint_via_api(
250248 execution_environment = {}
251249
252250 trigger_id = branch_id
253- if trigger_id is None :
254- if trigger_type == "Cron" or not self .is_blueprint_api_available (blueprint_id ):
255- trigger_id = self .get_blueprint_cron_trigger (blueprint_id )
251+ if trigger_id is not None :
252+ # Determine trigger type from the component
253+ component = self .session .session_component_tree .get_component (trigger_id )
254+ if component and component .type == "blueprints_apitrigger" :
255+ trigger_type = "API"
256+ elif component and component .type == "blueprints_crontrigger" :
256257 trigger_type = "Cron"
257258 else :
258- trigger_id = self .get_blueprint_api_trigger (blueprint_id )
259-
259+ trigger_type = "Branch"
260+ elif self .is_blueprint_api_available (blueprint_id ):
261+ # Prioritize API trigger over Cron if both exist
262+ trigger_id = self .get_blueprint_api_trigger (blueprint_id )
263+ trigger_type = "API"
264+ elif self .is_blueprint_cron_available (blueprint_id ):
265+ trigger_id = self .get_blueprint_cron_trigger (blueprint_id )
266+ trigger_type = "Cron"
267+ else :
268+ raise ValueError (f'No trigger found for blueprint "{ blueprint_id } ".' )
260269 return self .run_branch (
261270 trigger_id ,
262271 None ,
0 commit comments