def test_create_run_with_job_spec(self): config_dict = get_fxt_job() spec = OperationSpecification.read(values=config_dict) run = compile_operation_run(project_id=self.project.id, user_id=self.user.id, op_spec=spec) assert run.kind == V1RunKind.JOB assert run.name == "foo" assert run.description == "a description" assert set(run.tags) == {"tag1", "tag2"} # Check compiled operation passes compiled_operation = CompiledOperationSpecification.read(run.content) compiled_operation = CompiledOperationSpecification.apply_params( compiled_operation) CompiledOperationSpecification.apply_run_contexts(compiled_operation, ) # Check job job_spec = CompiledOperationSpecification.read(run.content) assert job_spec.run.container.image == "test" job_spec = CompiledOperationSpecification.apply_context(job_spec) assert job_spec.run.container.image == "test"
def test_create_run_with_templated_job_spec(self): config_dict = get_fxt_job_with_inputs() spec = OperationSpecification.read(values=config_dict) run = compile_operation_run(project_id=self.project.id, user_id=self.user.id, op_spec=spec) assert run.kind == V1RunKind.JOB assert run.name == "foo" assert run.description == "a description" assert set(run.tags) == {"tag1", "tag2"} # From template compiled_operation = CompiledOperationSpecification.read(run.content) compiled_operation = CompiledOperationSpecification.apply_params( compiled_operation, params=spec.params) compiled_operation = CompiledOperationSpecification.apply_context( compiled_operation) CompiledOperationSpecification.apply_run_contexts(compiled_operation, ) run.content = compiled_operation.to_dict(dump=True) run.save(update_fields=["content"]) job_spec = CompiledOperationSpecification.read(run.content) assert job_spec.run.container.image == "{{ image }}" job_spec = CompiledOperationSpecification.apply_run_contexts(job_spec) assert job_spec.run.container.image == "foo/bar"
def apply_contexts(self): self.compiled_operation = CompiledOperationSpecification.apply_run_contexts( self.compiled_operation, contexts=self.contexts)