def test_apply_params_extends_connections_and_init(self): content = { "version": 1.1, "kind": "compiled_operation", "inputs": [ { "name": "docker_image", "type": types.IMAGE }, { "name": "git_repo", "type": types.GIT }, ], "run": { "kind": V1RunKind.JOB, "connections": ["{{ docker_image.connection }}"], "container": { "name": "polyaxon-main", "image": "{{ docker_image.name }}", "command": "train", }, }, } run_config = V1CompiledOperation.read(content) # no params with self.assertRaises(ValidationError): CompiledOperationSpecification.apply_operation_contexts(run_config) params = { "docker_image": { "value": V1ImageType(name="destination:tag", connection="docker-registry") }, "git_repo": { "value": V1GitType(connection="repo-connection") }, } assert run_config.inputs[0].value is None assert run_config.inputs[1].value is None validated_params = run_config.validate_params(params=params) run_config.apply_params(params=params) assert params == {p.name: p.param.to_dict() for p in validated_params} assert run_config.inputs[0].value["connection"] == "docker-registry" assert run_config.inputs[1].value["connection"] == "repo-connection" run_config = CompiledOperationSpecification.apply_operation_contexts( run_config) run_config = CompiledOperationSpecification.apply_params(run_config) run_config = CompiledOperationSpecification.apply_runtime_contexts( run_config) assert run_config.run.connections == ["docker-registry"]
def convert_to_image_init(x): if not isinstance(x, Mapping): x = convert_to_dict(x, key) return V1ImageType.from_dict(x)