def compile_operation(cls, config: V1Operation, override: Dict = None) -> V1CompiledOperation: if override: preset = OperationSpecification.read(override, is_preset=True) config = config.patch(preset, preset.patch_strategy) # Patch run component = config.component # type: V1Component if config.run_patch: component.run = component.run.patch( validate_run_patch(config.run_patch, component.run.kind), strategy=config.patch_strategy, ) # Gather contexts io config_params = config.params or {} contexts = [ V1IO(name=p) for p in config_params if config_params[p].context_only ] patch_compiled = V1CompiledOperation( name=config.name, description=config.description, contexts=contexts, tags=config.tags, presets=config.presets, queue=config.queue, cache=config.cache, hooks=config.hooks, actions=config.actions, events=config.events, plugins=config.plugins, termination=config.termination, matrix=config.matrix, schedule=config.schedule, dependencies=config.dependencies, trigger=config.trigger, conditions=config.conditions, skip_on_upstream_skip=config.skip_on_upstream_skip, ) values = [ { cls.VERSION: config.version }, component.to_dict(), { cls.KIND: kinds.COMPILED_OPERATION }, ] compiled = V1CompiledOperation.read( values) # type: V1CompiledOperation return compiled.patch(patch_compiled, strategy=config.patch_strategy)
def compile_operation(cls, config: V1Operation, override: Dict = None) -> V1CompiledOperation: if override: preset = OperationSpecification.read(override, is_preset=True) config = config.patch(preset, preset.patch_strategy) # Patch run component = config.component # type: V1Component if config.run_patch: component.run = component.run.patch( validate_run_patch(config.run_patch, component.run.kind), strategy=config.patch_strategy, ) contexts = [] def get_context_io(c_name: str, c_io: V1Param, is_list=None): if not c_io.context_only: return contexts.append( V1IO( name=c_name, to_init=c_io.to_init, connection=c_io.connection, is_list=is_list, )) # Collect contexts io form params for p in config.params or {}: get_context_io(c_name=p, c_io=config.params[p]) # Collect contexts io form joins for j in config.joins or []: for p in j.params or {}: get_context_io(c_name=p, c_io=j.params[p], is_list=True) patch_compiled = V1CompiledOperation( name=config.name, description=config.description, contexts=contexts, tags=config.tags, presets=config.presets, queue=config.queue, cache=config.cache, hooks=config.hooks, events=config.events, plugins=config.plugins, termination=config.termination, matrix=config.matrix, joins=config.joins, schedule=config.schedule, dependencies=config.dependencies, trigger=config.trigger, conditions=config.conditions, skip_on_upstream_skip=config.skip_on_upstream_skip, ) values = [ { cls.VERSION: config.version }, component.to_dict(), { cls.KIND: kinds.COMPILED_OPERATION }, ] compiled = V1CompiledOperation.read( values) # type: V1CompiledOperation return compiled.patch(patch_compiled, strategy=config.patch_strategy)