def test_create_run_with_templated_service_spec(self):
     config_dict = get_fxt_service_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.SERVICE
     assert run.name == "foo"
     assert run.description == "a description"
     assert set(run.tags) == {"backend", "lab"}
     job_spec = CompiledOperationSpecification.read(run.content)
     assert job_spec.run.container.image == "{{ image }}"
     compiled_operation = CompiledOperationSpecification.read(run.content)
     compiled_operation = CompiledOperationSpecification.apply_params(
         compiled_operation, params=spec.params
     )
     compiled_operation = CompiledOperationSpecification.apply_operation_contexts(
         compiled_operation
     )
     CompiledOperationSpecification.apply_runtime_contexts(compiled_operation)
     run.content = compiled_operation.to_dict(dump=True)
     run.save(update_fields=["content"])
     job_spec = CompiledOperationSpecification.read(run.content)
     job_spec = CompiledOperationSpecification.apply_runtime_contexts(job_spec)
     assert job_spec.run.container.image == "foo/bar"
 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_runtime_contexts(compiled_operation)
     # Check job
     job_spec = CompiledOperationSpecification.read(run.content)
     assert job_spec.run.container.image == "test"
     job_spec = CompiledOperationSpecification.apply_operation_contexts(job_spec)
     assert job_spec.run.container.image == "test"
Exemple #3
0
 def _apply_runtime_contexts(self):
     contexts = resolve_contexts(
         namespace=self.namespace,
         owner_name=self.owner_name,
         project_name=self.project_name,
         project_uuid=self.project_uuid,
         run_name=self.run_name,
         run_path=self.run_path,
         run_uuid=self.run_uuid,
         compiled_operation=self.compiled_operation,
         connection_by_names=self.connection_by_names,
         artifacts_store=self.artifacts_store,
         iteration=self.iteration,
         created_at=self.created_at,
         compiled_at=self.compiled_at,
     )
     return CompiledOperationSpecification.apply_runtime_contexts(
         self.compiled_operation, contexts=contexts)
Exemple #4
0
 def _apply_runtime_contexts(self):
     contexts = self._resolve_contexts()
     return CompiledOperationSpecification.apply_runtime_contexts(
         self.compiled_operation, contexts=contexts
     )