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"
Exemple #2
0
 def resolve_params(self):
     params = self.run.params or {}
     self.compiled_operation = CompiledOperationSpecification.apply_params(
         config=self.compiled_operation,
         params=params,
         context=self.globals,
     )
Exemple #3
0
 def apply_params(self):
     self.compiled_operation = CompiledOperationSpecification.apply_params(
         config=self.compiled_operation, params=self.params, context=self.globals,
     )
     self._param_spec = CompiledOperationSpecification.calculate_context_spec(
         config=self.compiled_operation,
         contexts=self.globals,
         should_be_resolved=True,
     )
Exemple #4
0
 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"