Beispiel #1
0
def test_hydrate_registration_parameters__workflow_nothing_set():
    workflow = _workflow_pb2.WorkflowSpec(
        template=_core_workflow_pb2.WorkflowTemplate(
            id=_identifier_pb2.Identifier(
                resource_type=_identifier_pb2.WORKFLOW,
                name="name",
            ),
            nodes=[
                _core_workflow_pb2.Node(
                    id="foo",
                    task_node=_core_workflow_pb2.TaskNode(
                        reference_id=_identifier_pb2.Identifier(
                            resource_type=_identifier_pb2.TASK, name="task1")),
                )
            ],
        ))
    identifier, entity = hydrate_registration_parameters(
        _identifier_pb2.WORKFLOW, "project", "domain", "12345", workflow)
    assert (identifier == _identifier_pb2.Identifier(
        resource_type=_identifier_pb2.WORKFLOW,
        project="project",
        domain="domain",
        name="name",
        version="12345",
    ) == entity.template.id)
    assert len(workflow.template.nodes) == 1
    assert workflow.template.nodes[
        0].task_node.reference_id == _identifier_pb2.Identifier(
            resource_type=_identifier_pb2.TASK,
            project="project",
            domain="domain",
            name="task1",
            version="12345",
        )
Beispiel #2
0
 def to_flyte_idl(self):
     """
     :rtype: flyteidl.admin.workflow_pb2.WorkflowSpec
     """
     return _admin_workflow.WorkflowSpec(
         template=self._template.to_flyte_idl(),
         sub_workflows=[s.to_flyte_idl() for s in self._sub_workflows],
     )
Beispiel #3
0
def test_hydrate_registration_parameters__workflow_already_set():
    workflow = _workflow_pb2.WorkflowSpec(
        template=_core_workflow_pb2.WorkflowTemplate(
            id=_identifier_pb2.Identifier(
                resource_type=_identifier_pb2.WORKFLOW,
                project="project2",
                domain="domain2",
                name="name",
                version="abc",
            ), ))
    identifier, entity = hydrate_registration_parameters(
        _identifier_pb2.WORKFLOW, "project", "domain", "12345", workflow)
    assert (identifier == _identifier_pb2.Identifier(
        resource_type=_identifier_pb2.WORKFLOW,
        project="project2",
        domain="domain2",
        name="name",
        version="abc",
    ) == entity.template.id)
Beispiel #4
0
def test_hydrate_registration_parameters__subworkflows():
    workflow_template = _core_workflow_pb2.WorkflowTemplate()
    workflow_template.id.CopyFrom(
        _identifier_pb2.Identifier(resource_type=_identifier_pb2.WORKFLOW,
                                   name="workflow"))

    sub_workflow_template = _core_workflow_pb2.WorkflowTemplate()
    sub_workflow_template.id.CopyFrom(
        _identifier_pb2.Identifier(resource_type=_identifier_pb2.WORKFLOW,
                                   name="subworkflow"))
    sub_workflow_template.nodes.append(
        _core_workflow_pb2.Node(
            id="task_node",
            task_node=_core_workflow_pb2.TaskNode(
                reference_id=_identifier_pb2.Identifier(
                    resource_type=_identifier_pb2.TASK)),
        ))
    workflow_spec = _workflow_pb2.WorkflowSpec(template=workflow_template)
    workflow_spec.sub_workflows.append(sub_workflow_template)

    identifier, entity = hydrate_registration_parameters(
        _identifier_pb2.WORKFLOW, "project", "domain", "12345", workflow_spec)
    assert (identifier == _identifier_pb2.Identifier(
        resource_type=_identifier_pb2.WORKFLOW,
        project="project",
        domain="domain",
        name="workflow",
        version="12345",
    ) == entity.template.id)

    assert entity.sub_workflows[0].id == _identifier_pb2.Identifier(
        resource_type=_identifier_pb2.WORKFLOW,
        project="project",
        domain="domain",
        name="subworkflow",
        version="12345",
    )
Beispiel #5
0
 def to_flyte_idl(self):
     """
     :rtype: flyteidl.admin.workflow_pb2.WorkflowSpec
     """
     return _admin_workflow.WorkflowSpec(
         template=self._template.to_flyte_idl())