Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _extract_pair(identifier_file, object_file):
"""
:param Text identifier_file:
:param Text object_file:
:rtype: (flyteidl.core.identifier_pb2.Identifier, T)
"""
resource_map = {
_identifier_pb2.LAUNCH_PLAN: _launch_plan_pb2.LaunchPlanSpec,
_identifier_pb2.WORKFLOW: _workflow_pb2.WorkflowSpec,
_identifier_pb2.TASK: _task_pb2.TaskSpec
}
id = _load_proto_from_file(_identifier_pb2.Identifier, identifier_file)
if not id.resource_type in resource_map:
raise _user_exceptions.FlyteAssertion(f"Resource type found in identifier {id.resource_type} invalid, must be launch plan, "
f"task, or workflow")
entity = _load_proto_from_file(resource_map[id.resource_type], object_file)
return id, entity
def _extract_pair(identifier_file, object_file):
"""
:param Text identifier_file:
:param Text object_file:
:rtype: (flyteidl.core.identifier_pb2.Identifier, T)
"""
resource_map = {
_identifier_pb2.LAUNCH_PLAN: _launch_plan_pb2.LaunchPlanSpec,
_identifier_pb2.WORKFLOW: _workflow_pb2.WorkflowSpec,
_identifier_pb2.TASK: _task_pb2.TaskSpec
}
id = _load_proto_from_file(_identifier_pb2.Identifier, identifier_file)
if not id.resource_type in resource_map:
raise _user_exceptions.FlyteAssertion(f"Resource type found in identifier {id.resource_type} invalid, must be launch plan, "
f"task, or workflow")
entity = _load_proto_from_file(resource_map[id.resource_type], object_file)
return id, entity
from __future__ import absolute_import
from flytekit.models import common as _common_models
from flyteidl.core import identifier_pb2 as _identifier_pb2
class ResourceType(object):
UNSPECIFIED = _identifier_pb2.UNSPECIFIED
TASK = _identifier_pb2.TASK
WORKFLOW = _identifier_pb2.WORKFLOW
LAUNCH_PLAN = _identifier_pb2.LAUNCH_PLAN
class Identifier(_common_models.FlyteIdlEntity):
def __init__(self, resource_type, project, domain, name, version):
"""
:param int resource_type: enum value from ResourceType
:param Text project:
:param Text domain:
:param Text name:
:param Text version:
"""
self._resource_type = resource_type
self._project = project
self._domain = domain
self._name = name
from __future__ import absolute_import
from flytekit.models import common as _common_models
from flyteidl.core import identifier_pb2 as _identifier_pb2
class ResourceType(object):
UNSPECIFIED = _identifier_pb2.UNSPECIFIED
TASK = _identifier_pb2.TASK
WORKFLOW = _identifier_pb2.WORKFLOW
LAUNCH_PLAN = _identifier_pb2.LAUNCH_PLAN
class Identifier(_common_models.FlyteIdlEntity):
def __init__(self, resource_type, project, domain, name, version):
"""
:param int resource_type: enum value from ResourceType
:param Text project:
:param Text domain:
:param Text name:
:param Text version:
"""
self._resource_type = resource_type
def to_flyte_idl(self):
"""
:rtype: flyteidl.core.identifier_pb2.TaskExecutionIdentifier
"""
return _identifier_pb2.TaskExecutionIdentifier(
task_id=self.task_id.to_flyte_idl(),
node_execution_id=self.node_execution_id.to_flyte_idl(),
retry_attempt=self.retry_attempt
)
def to_flyte_idl(self):
"""
:rtype: flyteidl.core.identifier_pb2.WorkflowExecutionIdentifier
"""
return _identifier_pb2.WorkflowExecutionIdentifier(
project=self.project,
domain=self.domain,
name=self.name,
)
def to_flyte_idl(self):
"""
:rtype: flyteidl.core.identifier_pb2.NodeExecutionIdentifier
"""
return _identifier_pb2.NodeExecutionIdentifier(
node_id=self.node_id,
execution_id=self.execution_id.to_flyte_idl(),
)
def to_flyte_idl(self):
"""
:rtype: flyteidl.core.identifier_pb2.Identifier
"""
return _identifier_pb2.Identifier(
resource_type=self.resource_type,
project=self.project,
domain=self.domain,
name=self.name,
version=self.version
)