Ejemplo n.º 1
0
 def to_flyte_idl(self):
     """
     :rtype: flyteidl.core.workflow_pb2.WorkflowNode
     """
     return _core_workflow.WorkflowNode(
         launchplan_ref=self.launchplan_ref.to_flyte_idl() if self.launchplan_ref else None,
         sub_workflow_ref=self.sub_workflow_ref.to_flyte_idl() if self.sub_workflow_ref else None,
     )
Ejemplo n.º 2
0
def test_hydrate_workflow_template():
    workflow_template = _core_workflow_pb2.WorkflowTemplate()
    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_template.nodes.append(
        _core_workflow_pb2.Node(
            id="launchplan_ref",
            workflow_node=_core_workflow_pb2.WorkflowNode(
                launchplan_ref=_identifier_pb2.Identifier(
                    resource_type=_identifier_pb2.LAUNCH_PLAN,
                    project="project2",
                )),
        ))
    workflow_template.nodes.append(
        _core_workflow_pb2.Node(
            id="sub_workflow_ref",
            workflow_node=_core_workflow_pb2.WorkflowNode(
                sub_workflow_ref=_identifier_pb2.Identifier(
                    resource_type=_identifier_pb2.WORKFLOW,
                    project="project2",
                    domain="domain2",
                )),
        ))
    workflow_template.nodes.append(
        _core_workflow_pb2.Node(
            id="unchanged",
            task_node=_core_workflow_pb2.TaskNode(
                reference_id=_identifier_pb2.Identifier(
                    resource_type=_identifier_pb2.TASK,
                    project="project2",
                    domain="domain2",
                    version="abc")),
        ))
    hydrated_workflow_template = _hydrate_workflow_template_nodes(
        "project", "domain", "12345", workflow_template)
    assert len(hydrated_workflow_template.nodes) == 4
    task_node_identifier = hydrated_workflow_template.nodes[
        0].task_node.reference_id
    assert task_node_identifier.project == "project"
    assert task_node_identifier.domain == "domain"
    assert task_node_identifier.version == "12345"

    launchplan_ref_identifier = hydrated_workflow_template.nodes[
        1].workflow_node.launchplan_ref
    assert launchplan_ref_identifier.project == "project2"
    assert launchplan_ref_identifier.domain == "domain"
    assert launchplan_ref_identifier.version == "12345"

    sub_workflow_ref_identifier = hydrated_workflow_template.nodes[
        2].workflow_node.sub_workflow_ref
    assert sub_workflow_ref_identifier.project == "project2"
    assert sub_workflow_ref_identifier.domain == "domain2"
    assert sub_workflow_ref_identifier.version == "12345"

    unchanged_identifier = hydrated_workflow_template.nodes[
        3].task_node.reference_id
    assert unchanged_identifier.project == "project2"
    assert unchanged_identifier.domain == "domain2"
    assert unchanged_identifier.version == "abc"