def post(self, spec_api, execution_id, no_merge=False): """ Re-run the provided action execution optionally specifying override parameters. Handles requests: POST /executions/<id>/re_run """ no_merge = cast_argument_value(value_type=bool, value=no_merge) existing_execution = self._get_one(id=execution_id, exclude_fields=self.exclude_fields) if spec_api.tasks and existing_execution.runner['name'] != 'mistral-v2': raise ValueError( 'Task option is only supported for Mistral workflows.') # Merge in any parameters provided by the user new_parameters = {} if not no_merge: new_parameters.update(getattr(existing_execution, 'parameters', {})) new_parameters.update(spec_api.parameters) # Create object for the new execution action_ref = existing_execution.action['ref'] # Include additional option(s) for the execution context = { 're-run': { 'ref': execution_id, } } if spec_api.tasks: context['re-run']['tasks'] = spec_api.tasks if spec_api.reset: context['re-run']['reset'] = spec_api.reset # Add trace to the new execution trace = trace_service.get_trace_db_by_action_execution( action_execution_id=existing_execution.id) if trace: context['trace_context'] = {'id_': str(trace.id)} new_liveaction_api = LiveActionCreateAPI(action=action_ref, context=context, parameters=new_parameters, user=spec_api.user) return self._handle_schedule_execution( liveaction_api=new_liveaction_api)
def post(self, spec_api, execution_id, no_merge=False): """ Re-run the provided action execution optionally specifying override parameters. Handles requests: POST /executions/<id>/re_run """ no_merge = cast_argument_value(value_type=bool, value=no_merge) existing_execution = self._get_one(id=execution_id, exclude_fields=self.exclude_fields) if spec_api.tasks and existing_execution.runner['name'] != 'mistral-v2': raise ValueError('Task option is only supported for Mistral workflows.') # Merge in any parameters provided by the user new_parameters = {} if not no_merge: new_parameters.update(getattr(existing_execution, 'parameters', {})) new_parameters.update(spec_api.parameters) # Create object for the new execution action_ref = existing_execution.action['ref'] # Include additional option(s) for the execution context = { 're-run': { 'ref': execution_id, } } if spec_api.tasks: context['re-run']['tasks'] = spec_api.tasks if spec_api.reset: context['re-run']['reset'] = spec_api.reset # Add trace to the new execution trace = trace_service.get_trace_db_by_action_execution( action_execution_id=existing_execution.id) if trace: context['trace_context'] = {'id_': str(trace.id)} new_liveaction_api = LiveActionCreateAPI(action=action_ref, context=context, parameters=new_parameters, user=spec_api.user) return self._handle_schedule_execution(liveaction_api=new_liveaction_api)
def post(self, spec_api, id, requester_user, no_merge=False, show_secrets=False): """ Re-run the provided action execution optionally specifying override parameters. Handles requests: POST /executions/<id>/re_run """ if (spec_api.tasks or spec_api.reset) and spec_api.parameters: raise ValueError('Parameters override is not supported when ' 're-running task(s) for a workflow.') if spec_api.parameters: assert isinstance(spec_api.parameters, dict) if spec_api.tasks: assert isinstance(spec_api.tasks, list) if spec_api.reset: assert isinstance(spec_api.reset, list) if list(set(spec_api.reset) - set(spec_api.tasks)): raise ValueError( 'List of tasks to reset does not match the tasks to rerun.') no_merge = cast_argument_value(value_type=bool, value=no_merge) existing_execution = self._get_one_by_id( id=id, exclude_fields=self.exclude_fields, requester_user=requester_user, permission_type=PermissionType.EXECUTION_VIEW) if spec_api.tasks and existing_execution.runner['name'] != 'mistral-v2': raise ValueError( 'Task option is only supported for Mistral workflows.') # Merge in any parameters provided by the user new_parameters = {} if not no_merge: new_parameters.update(getattr(existing_execution, 'parameters', {})) new_parameters.update(spec_api.parameters) # Create object for the new execution action_ref = existing_execution.action['ref'] # Include additional option(s) for the execution context = { 're-run': { 'ref': id, } } if spec_api.tasks: context['re-run']['tasks'] = spec_api.tasks if spec_api.reset: context['re-run']['reset'] = spec_api.reset # Add trace to the new execution trace = trace_service.get_trace_db_by_action_execution( action_execution_id=existing_execution.id) if trace: context['trace_context'] = {'id_': str(trace.id)} new_liveaction_api = LiveActionCreateAPI(action=action_ref, context=context, parameters=new_parameters, user=spec_api.user) return self._handle_schedule_execution( liveaction_api=new_liveaction_api, requester_user=requester_user, show_secrets=show_secrets)
def post(self, spec_api, id, requester_user, no_merge=False, show_secrets=False): """ Re-run the provided action execution optionally specifying override parameters. Handles requests: POST /executions/<id>/re_run """ if (spec_api.tasks or spec_api.reset) and spec_api.parameters: raise ValueError("Parameters override is not supported when " "re-running task(s) for a workflow.") if spec_api.parameters: if not isinstance(spec_api.parameters, dict): raise TypeError( f"The parameters needs to be a dictionary (was {type(spec_api.parameters)})." ) if spec_api.tasks: if not isinstance(spec_api.tasks, list): raise TypeError( f"The tasks needs to be a list (was {type(spec_api.tasks)})." ) if spec_api.reset: if not isinstance(spec_api.reset, list): raise TypeError( f"The reset needs to be a list (was {type(spec_api.reset)})." ) if list(set(spec_api.reset) - set(spec_api.tasks)): raise ValueError( "List of tasks to reset does not match the tasks to rerun.") delay = None if hasattr(spec_api, "delay") and isinstance(spec_api.delay, int): delay = spec_api.delay no_merge = cast_argument_value(value_type=bool, value=no_merge) existing_execution = self._get_one_by_id( id=id, exclude_fields=self.exclude_fields, requester_user=requester_user, permission_type=PermissionType.EXECUTION_VIEW, ) if spec_api.tasks and existing_execution.runner["name"] != "orquesta": raise ValueError( "Task option is only supported for Orquesta workflows.") # Merge in any parameters provided by the user new_parameters = {} if not no_merge: new_parameters.update(getattr(existing_execution, "parameters", {})) new_parameters.update(spec_api.parameters) # Create object for the new execution action_ref = existing_execution.action["ref"] # Include additional option(s) for the execution context = { "re-run": { "ref": id, } } if spec_api.tasks: context["re-run"]["tasks"] = spec_api.tasks if spec_api.reset: context["re-run"]["reset"] = spec_api.reset # Add trace to the new execution trace = trace_service.get_trace_db_by_action_execution( action_execution_id=existing_execution.id) if trace: context["trace_context"] = {"id_": str(trace.id)} new_liveaction_api = LiveActionCreateAPI( action=action_ref, context=context, parameters=new_parameters, user=spec_api.user, delay=delay, ) return self._handle_schedule_execution( liveaction_api=new_liveaction_api, requester_user=requester_user, show_secrets=show_secrets, )
def post(self, spec_api, id, requester_user, no_merge=False, show_secrets=False): """ Re-run the provided action execution optionally specifying override parameters. Handles requests: POST /executions/<id>/re_run """ if (spec_api.tasks or spec_api.reset) and spec_api.parameters: raise ValueError('Parameters override is not supported when ' 're-running task(s) for a workflow.') if spec_api.parameters: assert isinstance(spec_api.parameters, dict) if spec_api.tasks: assert isinstance(spec_api.tasks, list) if spec_api.reset: assert isinstance(spec_api.reset, list) if list(set(spec_api.reset) - set(spec_api.tasks)): raise ValueError('List of tasks to reset does not match the tasks to rerun.') delay = None if hasattr(spec_api, "delay") and isinstance(spec_api.delay, int): delay = spec_api.delay no_merge = cast_argument_value(value_type=bool, value=no_merge) existing_execution = self._get_one_by_id(id=id, exclude_fields=self.exclude_fields, requester_user=requester_user, permission_type=PermissionType.EXECUTION_VIEW) if spec_api.tasks and existing_execution.runner['name'] != 'mistral-v2': raise ValueError('Task option is only supported for Mistral workflows.') # Merge in any parameters provided by the user new_parameters = {} if not no_merge: new_parameters.update(getattr(existing_execution, 'parameters', {})) new_parameters.update(spec_api.parameters) # Create object for the new execution action_ref = existing_execution.action['ref'] # Include additional option(s) for the execution context = { 're-run': { 'ref': id, } } if spec_api.tasks: context['re-run']['tasks'] = spec_api.tasks if spec_api.reset: context['re-run']['reset'] = spec_api.reset # Add trace to the new execution trace = trace_service.get_trace_db_by_action_execution( action_execution_id=existing_execution.id) if trace: context['trace_context'] = {'id_': str(trace.id)} new_liveaction_api = LiveActionCreateAPI(action=action_ref, context=context, parameters=new_parameters, user=spec_api.user, delay=delay) return self._handle_schedule_execution(liveaction_api=new_liveaction_api, requester_user=requester_user, show_secrets=show_secrets)