Skip to content

Commit 1cb6ad0

Browse files
committed
add short_description to Task and Workflow model
Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com>
1 parent 8abecfe commit 1cb6ad0

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

flytekit/models/admin/workflow.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,14 @@ def from_flyte_idl(cls, pb2_object):
7070

7171

7272
class Workflow(_common.FlyteIdlEntity):
73-
def __init__(self, id, closure):
73+
def __init__(self, id, closure, short_description):
7474
"""
7575
:param flytekit.models.core.identifier.Identifier id:
7676
:param WorkflowClosure closure:
7777
"""
7878
self._id = id
7979
self._closure = closure
80+
self._short_description = short_description
8081

8182
@property
8283
def id(self):
@@ -92,11 +93,22 @@ def closure(self):
9293
"""
9394
return self._closure
9495

96+
@property
97+
def short_description(self):
98+
"""
99+
:rtype: str
100+
"""
101+
return self._short_description
102+
95103
def to_flyte_idl(self):
96104
"""
97105
:rtype: flyteidl.admin.workflow_pb2.Workflow
98106
"""
99-
return _admin_workflow.Workflow(id=self.id.to_flyte_idl(), closure=self.closure.to_flyte_idl())
107+
return _admin_workflow.Workflow(
108+
id=self.id.to_flyte_idl(),
109+
closure=self.closure.to_flyte_idl(),
110+
short_description=self.short_description,
111+
)
100112

101113
@classmethod
102114
def from_flyte_idl(cls, pb2_object):
@@ -107,6 +119,7 @@ def from_flyte_idl(cls, pb2_object):
107119
return cls(
108120
id=_identifier.Identifier.from_flyte_idl(pb2_object.id),
109121
closure=WorkflowClosure.from_flyte_idl(pb2_object.closure),
122+
short_description=pb2_object.short_description,
110123
)
111124

112125

flytekit/models/task.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,13 +686,14 @@ def from_flyte_idl(cls, pb2_object):
686686

687687

688688
class Task(_common.FlyteIdlEntity):
689-
def __init__(self, id, closure):
689+
def __init__(self, id, closure, short_description):
690690
"""
691691
:param flytekit.models.core.identifier.Identifier id: The (project, domain, name) identifier for this task.
692692
:param TaskClosure closure: The closure for the underlying workload.
693693
"""
694694
self._id = id
695695
self._closure = closure
696+
self._short_description = short_description
696697

697698
@property
698699
def id(self):
@@ -710,13 +711,21 @@ def closure(self):
710711
"""
711712
return self._closure
712713

714+
@property
715+
def short_description(self):
716+
"""
717+
:rtype: str
718+
"""
719+
return self._short_description
720+
713721
def to_flyte_idl(self):
714722
"""
715723
:rtype: flyteidl.admin.task_pb2.Task
716724
"""
717725
return _admin_task.Task(
718726
closure=self.closure.to_flyte_idl(),
719727
id=self.id.to_flyte_idl(),
728+
short_description=self.short_description,
720729
)
721730

722731
@classmethod
@@ -728,6 +737,7 @@ def from_flyte_idl(cls, pb2_object):
728737
return cls(
729738
closure=TaskClosure.from_flyte_idl(pb2_object.closure),
730739
id=_identifier.Identifier.from_flyte_idl(pb2_object.id),
740+
short_description=pb2_object.short_description,
731741
)
732742

733743

tests/flytekit/unit/remote/test_remote.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,15 @@ def get_compiled_workflow_closure():
380380
def test_fetch_lazy(remote):
381381
mock_client = remote._client
382382
mock_client.get_task.return_value = Task(
383-
id=Identifier(ResourceType.TASK, "p", "d", "n", "v"), closure=LIST_OF_TASK_CLOSURES[0]
383+
id=Identifier(ResourceType.TASK, "p", "d", "n", "v"),
384+
closure=LIST_OF_TASK_CLOSURES[0],
385+
short_description="task description",
384386
)
385387

386388
mock_client.get_workflow.return_value = Workflow(
387389
id=Identifier(ResourceType.TASK, "p", "d", "n", "v"),
388390
closure=WorkflowClosure(compiled_workflow=get_compiled_workflow_closure()),
391+
short_description="workflow description",
389392
)
390393

391394
lw = remote.fetch_workflow_lazy(name="wn", version="v")
@@ -443,8 +446,9 @@ def test_launch_backfill(remote):
443446
mock_client.get_workflow.return_value = Workflow(
444447
id=Identifier(ResourceType.WORKFLOW, "p", "d", "daily2", "v"),
445448
closure=WorkflowClosure(
446-
compiled_workflow=CompiledWorkflowClosure(primary=ser_wf, sub_workflows=[], tasks=tasks)
449+
compiled_workflow=CompiledWorkflowClosure(primary=ser_wf, sub_workflows=[], tasks=tasks),
447450
),
451+
short_description="workflow description",
448452
)
449453

450454
wf = remote.launch_backfill(
@@ -468,6 +472,7 @@ def test_fetch_workflow_with_branch(mock_promote, mock_workflow, remote):
468472
mock_client.get_workflow.return_value = Workflow(
469473
id=Identifier(ResourceType.TASK, "p", "d", "n", "v"),
470474
closure=WorkflowClosure(compiled_workflow=MagicMock()),
475+
short_description="workflow description",
471476
)
472477

473478
admin_launch_plan = MagicMock()
@@ -486,6 +491,7 @@ def test_fetch_workflow_with_nested_branch(mock_promote, mock_workflow, remote):
486491
mock_client.get_workflow.return_value = Workflow(
487492
id=Identifier(ResourceType.TASK, "p", "d", "n", "v"),
488493
closure=WorkflowClosure(compiled_workflow=MagicMock()),
494+
short_description="workflow description",
489495
)
490496
admin_launch_plan = MagicMock()
491497
admin_launch_plan.spec = {"workflow_id": 123}
@@ -856,7 +862,6 @@ def workflow1():
856862
assert isinstance(registered_workflow, FlyteWorkflow)
857863
assert registered_workflow.id == Identifier(ResourceType.WORKFLOW, "flytesnacks", "development", "tests.flytekit.unit.remote.test_remote.workflow1", "dummy_version")
858864

859-
860865
@mock.patch("flytekit.remote.remote.get_serializable")
861866
@mock.patch("flytekit.remote.remote.FlyteRemote.fetch_launch_plan")
862867
@mock.patch("flytekit.remote.remote.FlyteRemote.raw_register")

0 commit comments

Comments
 (0)