Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use full execution inputs and outputs data #162

Merged
merged 3 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 48 additions & 18 deletions flytekit/engines/flyte/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,16 @@ def get_inputs(self):
:rtype: flytekit.models.literals.LiteralMap
"""
client = _FlyteClientManager(_platform_config.URL.get(), insecure=_platform_config.INSECURE.get()).client
url_blob = client.get_execution_data(self.sdk_workflow_execution.id)
if url_blob.inputs.bytes > 0:
execution_data = client.get_execution_data(self.sdk_workflow_execution.id)

# Inputs are returned inline unless they are too big, in which case a url blob pointing to them is returned.
if bool(execution_data.full_inputs.literals):
return execution_data.full_inputs

if execution_data.inputs.bytes > 0:
with _common_utils.AutoDeletingTempDir() as t:
tmp_name = _os.path.join(t.name, "inputs.pb")
_data_proxy.Data.get_data(url_blob.inputs.url, tmp_name)
_data_proxy.Data.get_data(execution_data.inputs.url, tmp_name)
return _literals.LiteralMap.from_flyte_idl(
_common_utils.load_proto_from_file(_literals_pb2.LiteralMap, tmp_name)
)
Expand All @@ -448,11 +453,16 @@ def get_outputs(self):
:rtype: flytekit.models.literals.LiteralMap
"""
client = _FlyteClientManager(_platform_config.URL.get(), insecure=_platform_config.INSECURE.get()).client
url_blob = client.get_execution_data(self.sdk_workflow_execution.id)
if url_blob.outputs.bytes > 0:
execution_data = client.get_execution_data(self.sdk_workflow_execution.id)

# Outputs are returned inline unless they are too big, in which case a url blob pointing to them is returned.
if bool(execution_data.full_outputs.literals):
return execution_data.full_outputs

if execution_data.outputs.bytes > 0:
with _common_utils.AutoDeletingTempDir() as t:
tmp_name = _os.path.join(t.name, "outputs.pb")
_data_proxy.Data.get_data(url_blob.outputs.url, tmp_name)
_data_proxy.Data.get_data(execution_data.outputs.url, tmp_name)
return _literals.LiteralMap.from_flyte_idl(
_common_utils.load_proto_from_file(_literals_pb2.LiteralMap, tmp_name)
)
Expand Down Expand Up @@ -486,11 +496,16 @@ def get_inputs(self):
:rtype: flytekit.models.literals.LiteralMap
"""
client = _FlyteClientManager(_platform_config.URL.get(), insecure=_platform_config.INSECURE.get()).client
url_blob = client.get_node_execution_data(self.sdk_node_execution.id)
if url_blob.inputs.bytes > 0:
execution_data = client.get_node_execution_data(self.sdk_node_execution.id)

# Inputs are returned inline unless they are too big, in which case a url blob pointing to them is returned.
if bool(execution_data.full_inputs.literals):
return execution_data.full_inputs

if execution_data.inputs.bytes > 0:
with _common_utils.AutoDeletingTempDir() as t:
tmp_name = _os.path.join(t.name, "inputs.pb")
_data_proxy.Data.get_data(url_blob.inputs.url, tmp_name)
_data_proxy.Data.get_data(execution_data.inputs.url, tmp_name)
return _literals.LiteralMap.from_flyte_idl(
_common_utils.load_proto_from_file(_literals_pb2.LiteralMap, tmp_name)
)
Expand All @@ -501,11 +516,16 @@ def get_outputs(self):
:rtype: flytekit.models.literals.LiteralMap
"""
client = _FlyteClientManager(_platform_config.URL.get(), insecure=_platform_config.INSECURE.get()).client
url_blob = client.get_node_execution_data(self.sdk_node_execution.id)
if url_blob.outputs.bytes > 0:
execution_data = client.get_node_execution_data(self.sdk_node_execution.id)

# Outputs are returned inline unless they are too big, in which case a url blob pointing to them is returned.
if bool(execution_data.full_outputs.literals):
return execution_data.full_outputs

if execution_data.outputs.bytes > 0:
with _common_utils.AutoDeletingTempDir() as t:
tmp_name = _os.path.join(t.name, "outputs.pb")
_data_proxy.Data.get_data(url_blob.outputs.url, tmp_name)
_data_proxy.Data.get_data(execution_data.outputs.url, tmp_name)
return _literals.LiteralMap.from_flyte_idl(
_common_utils.load_proto_from_file(_literals_pb2.LiteralMap, tmp_name)
)
Expand All @@ -525,11 +545,16 @@ def get_inputs(self):
:rtype: flytekit.models.literals.LiteralMap
"""
client = _FlyteClientManager(_platform_config.URL.get(), insecure=_platform_config.INSECURE.get()).client
url_blob = client.get_task_execution_data(self.sdk_task_execution.id)
if url_blob.inputs.bytes > 0:
execution_data = client.get_task_execution_data(self.sdk_task_execution.id)

# Inputs are returned inline unless they are too big, in which case a url blob pointing to them is returned.
if bool(execution_data.full_inputs.literals):
return execution_data.full_inputs

if execution_data.inputs.bytes > 0:
with _common_utils.AutoDeletingTempDir() as t:
tmp_name = _os.path.join(t.name, "inputs.pb")
_data_proxy.Data.get_data(url_blob.inputs.url, tmp_name)
_data_proxy.Data.get_data(execution_data.inputs.url, tmp_name)
return _literals.LiteralMap.from_flyte_idl(
_common_utils.load_proto_from_file(_literals_pb2.LiteralMap, tmp_name)
)
Expand All @@ -540,11 +565,16 @@ def get_outputs(self):
:rtype: flytekit.models.literals.LiteralMap
"""
client = _FlyteClientManager(_platform_config.URL.get(), insecure=_platform_config.INSECURE.get()).client
url_blob = client.get_task_execution_data(self.sdk_task_execution.id)
if url_blob.outputs.bytes > 0:
execution_data = client.get_task_execution_data(self.sdk_task_execution.id)

# Inputs are returned inline unless they are too big, in which case a url blob pointing to them is returned.
if bool(execution_data.full_outputs.literals):
return execution_data.full_outputs

if execution_data.outputs.bytes > 0:
with _common_utils.AutoDeletingTempDir() as t:
tmp_name = _os.path.join(t.name, "outputs.pb")
_data_proxy.Data.get_data(url_blob.outputs.url, tmp_name)
_data_proxy.Data.get_data(execution_data.outputs.url, tmp_name)
return _literals.LiteralMap.from_flyte_idl(
_common_utils.load_proto_from_file(_literals_pb2.LiteralMap, tmp_name)
)
Expand Down
42 changes: 38 additions & 4 deletions flytekit/models/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytz as _pytz

from flytekit.models import common as _common_models
from flytekit.models import literals as _literals_models
from flytekit.models.core import execution as _core_execution
from flytekit.models.core import identifier as _identifier

Expand Down Expand Up @@ -382,13 +383,17 @@ class _CommonDataResponse(_common_models.FlyteIdlEntity):
superclass to reduce code duplication until things diverge in the future.
"""

def __init__(self, inputs, outputs):
def __init__(self, inputs, outputs, full_inputs, full_outputs):
"""
:param _common_models.UrlBlob inputs:
:param _common_models.UrlBlob outputs:
:param _literals_pb2.LiteralMap full_inputs:
:param _literals_pb2.LiteralMap full_outputs:
"""
self._inputs = inputs
self._outputs = outputs
self._full_inputs = full_inputs
self._full_outputs = full_outputs

@property
def inputs(self):
Expand All @@ -404,6 +409,20 @@ def outputs(self):
"""
return self._outputs

@property
def full_inputs(self):
"""
:rtype: _literals_pb2.LiteralMap
"""
return self._full_inputs

@property
def full_outputs(self):
"""
:rtype: _literals_pb2.LiteralMap
"""
return self._full_outputs


class WorkflowExecutionGetDataResponse(_CommonDataResponse):
@classmethod
Expand All @@ -415,14 +434,19 @@ def from_flyte_idl(cls, pb2_object):
return cls(
inputs=_common_models.UrlBlob.from_flyte_idl(pb2_object.inputs),
outputs=_common_models.UrlBlob.from_flyte_idl(pb2_object.outputs),
full_inputs=_literals_models.LiteralMap.from_flyte_idl(pb2_object.full_inputs),
full_outputs=_literals_models.LiteralMap.from_flyte_idl(pb2_object.full_outputs),
)

def to_flyte_idl(self):
"""
:rtype: _execution_pb2.WorkflowExecutionGetDataResponse
"""
return _execution_pb2.WorkflowExecutionGetDataResponse(
inputs=self.inputs.to_flyte_idl(), outputs=self.outputs.to_flyte_idl(),
inputs=self.inputs.to_flyte_idl(),
outputs=self.outputs.to_flyte_idl(),
full_inputs=self.full_inputs.to_flyte_idl(),
full_outputs=self.full_outputs.to_flyte_idl(),
)


Expand All @@ -436,14 +460,19 @@ def from_flyte_idl(cls, pb2_object):
return cls(
inputs=_common_models.UrlBlob.from_flyte_idl(pb2_object.inputs),
outputs=_common_models.UrlBlob.from_flyte_idl(pb2_object.outputs),
full_inputs=_literals_models.LiteralMap.from_flyte_idl(pb2_object.full_inputs),
full_outputs=_literals_models.LiteralMap.from_flyte_idl(pb2_object.full_outputs),
)

def to_flyte_idl(self):
"""
:rtype: _task_execution_pb2.TaskExecutionGetDataResponse
"""
return _task_execution_pb2.TaskExecutionGetDataResponse(
inputs=self.inputs.to_flyte_idl(), outputs=self.outputs.to_flyte_idl(),
inputs=self.inputs.to_flyte_idl(),
outputs=self.outputs.to_flyte_idl(),
full_inputs=self.full_inputs.to_flyte_idl(),
full_outputs=self.full_outputs.to_flyte_idl(),
)


Expand All @@ -457,12 +486,17 @@ def from_flyte_idl(cls, pb2_object):
return cls(
inputs=_common_models.UrlBlob.from_flyte_idl(pb2_object.inputs),
outputs=_common_models.UrlBlob.from_flyte_idl(pb2_object.outputs),
full_inputs=_literals_models.LiteralMap.from_flyte_idl(pb2_object.full_inputs),
full_outputs=_literals_models.LiteralMap.from_flyte_idl(pb2_object.full_outputs),
)

def to_flyte_idl(self):
"""
:rtype: _node_execution_pb2.NodeExecutionGetDataResponse
"""
return _node_execution_pb2.NodeExecutionGetDataResponse(
inputs=self.inputs.to_flyte_idl(), outputs=self.outputs.to_flyte_idl(),
inputs=self.inputs.to_flyte_idl(),
outputs=self.outputs.to_flyte_idl(),
full_inputs=self.full_inputs.to_flyte_idl(),
full_outputs=self.full_outputs.to_flyte_idl(),
)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
]
},
install_requires=[
"flyteidl>=0.18.1,<1.0.0",
"flyteidl>=0.18.2,<1.0.0",
"click>=6.6,<8.0",
"croniter>=0.3.20,<4.0.0",
"deprecated>=1.0,<2.0",
Expand Down
Loading