Пример #1
0
    def fetch(cls, project: str, domain: str, name: str,
              version: str) -> "FlyteLaunchPlan":
        """
        This function uses the engine loader to call create a hydrated task from Admin.
        :param project:
        :param domain:
        :param name:
        :param version:
        """
        from flytekit.control_plane import workflow as _workflow

        launch_plan_id = _identifier.Identifier(
            _identifier_model.ResourceType.LAUNCH_PLAN, project, domain, name,
            version)

        lp = _flyte_engine.get_client().get_launch_plan(launch_plan_id)
        flyte_lp = cls.promote_from_model(lp.spec)
        flyte_lp._id = lp.id

        # TODO: Add a test for this, and this function as a whole
        wf_id = flyte_lp.workflow_id
        lp_wf = _workflow.FlyteWorkflow.fetch(wf_id.project, wf_id.domain,
                                              wf_id.name, wf_id.version)
        flyte_lp._interface = lp_wf.interface
        return flyte_lp
Пример #2
0
def test_identifier():
    identifier = _identifier.Identifier(_core_identifier.ResourceType.WORKFLOW,
                                        "project", "domain", "name", "v1")
    assert identifier == _identifier.Identifier.from_urn(
        "wf:project:domain:name:v1")
    assert identifier == _core_identifier.Identifier(
        _core_identifier.ResourceType.WORKFLOW, "project", "domain", "name",
        "v1")
    assert identifier.__str__() == "wf:project:domain:name:v1"
Пример #3
0
 def fetch(cls, project: str, domain: str, name: str, version: str):
     workflow_id = _identifier.Identifier(
         _identifier_model.ResourceType.WORKFLOW, project, domain, name,
         version)
     admin_workflow = _flyte_engine.get_client().get_workflow(workflow_id)
     cwc = admin_workflow.closure.compiled_workflow
     flyte_workflow = cls.promote_from_model(
         base_model=cwc.primary.template,
         sub_workflows={
             sw.template.id: sw.template
             for sw in cwc.sub_workflows
         },
         tasks={t.template.id: t.template
                for t in cwc.tasks},
     )
     flyte_workflow._id = workflow_id
     return flyte_workflow
Пример #4
0
def test_task_execution_identifier():
    task_id = _identifier.Identifier(_core_identifier.ResourceType.TASK,
                                     "project", "domain", "name", "version")
    node_execution_id = _core_identifier.NodeExecutionIdentifier(
        node_id="n0",
        execution_id=_core_identifier.WorkflowExecutionIdentifier(
            "project", "domain", "name"))
    identifier = _identifier.TaskExecutionIdentifier(
        task_id=task_id,
        node_execution_id=node_execution_id,
        retry_attempt=0,
    )
    assert identifier == _identifier.TaskExecutionIdentifier.from_urn(
        "te:project:domain:name:n0:project:domain:name:version:0")
    assert identifier == _identifier.TaskExecutionIdentifier.promote_from_model(
        _core_identifier.TaskExecutionIdentifier(task_id, node_execution_id,
                                                 0))
    assert identifier.__str__(
    ) == "te:project:domain:name:n0:project:domain:name:version:0"