Skip to content

Commit

Permalink
[IO-1496][external] Expose the name, type, and edge_ids of Stage obje…
Browse files Browse the repository at this point in the history
…cts (#690)
  • Loading branch information
JBWilkie authored Oct 19, 2023
1 parent 677329f commit 1ac5d03
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 4 deletions.
19 changes: 19 additions & 0 deletions darwin/future/meta/objects/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,23 @@ def move_attached_files_to_stage(self, new_stage_id: UUID) -> Stage:

@property
def id(self) -> UUID:
"""Stage ID."""
return self._element.id

@property
def name(self) -> str:
"""Stage name."""
return self._element.name

@property
def type(self) -> str:
"""Stage type."""
return self._element.type.value

@property
def edges(self) -> List[List[UUID]]:
"""Edge ID, source stage ID, target stage ID."""
return [
[edge.id, edge.source_stage_id, edge.target_stage_id]
for edge in self._element.edges
]
58 changes: 54 additions & 4 deletions darwin/future/tests/meta/objects/test_stagemeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import responses
from pytest import fixture

from darwin.future.data_objects.workflow import WFStageCore, WFTypeCore
from darwin.future.data_objects.workflow import WFEdgeCore, WFStageCore, WFTypeCore
from darwin.future.meta.client import Client
from darwin.future.meta.objects.stage import Stage
from darwin.future.tests.core.fixtures import *
Expand Down Expand Up @@ -46,7 +46,8 @@ def test_item_ids(
rsps.add(
rsps.GET,
base_meta_client.config.api_endpoint
+ f"v2/teams/default-team/items/ids?workflow_stage_ids={str(stage_meta.id)}&dataset_ids=1337",
+ f"v2/teams/default-team/items/ids?workflow_stage_ids={str(stage_meta.id)}"
"&dataset_ids=1337",
json={"item_ids": UUIDs_str},
status=200,
)
Expand All @@ -61,7 +62,8 @@ def test_move_attached_files_to_stage(
rsps.add(
rsps.GET,
base_meta_client.config.api_endpoint
+ f"v2/teams/default-team/items/ids?workflow_stage_ids={str(stage_meta.id)}&dataset_ids=1337",
+ f"v2/teams/default-team/items/ids?workflow_stage_ids={str(stage_meta.id)}"
"&dataset_ids=1337",
json={"item_ids": UUIDs_str},
status=200,
)
Expand All @@ -78,6 +80,54 @@ def test_move_attached_files_to_stage(
)
assert rsps.assert_call_count(
base_meta_client.config.api_endpoint
+ f"v2/teams/default-team/items/ids?workflow_stage_ids={str(stage_meta.id)}&dataset_ids=1337",
+ f"v2/teams/default-team/items/ids?workflow_stage_ids={str(stage_meta.id)}"
"&dataset_ids=1337",
1,
)


def test_get_stage_id(stage_meta):
assert stage_meta.id == UUID("00000000-0000-0000-0000-000000000000")


def test_get_stage_name(stage_meta):
assert stage_meta.name == "test-stage"


def test_get_stage_type(stage_meta):
assert stage_meta.type == "annotate"


def test_get_stage_edges(stage_meta):
edges = [
WFEdgeCore(
name="edge_1",
id=UUID("00000000-0000-0000-0000-000000000000"),
source_stage_id=UUID("00000000-0000-0000-0000-000000000000"),
target_stage_id=UUID("00000000-0000-0000-0000-000000000000"),
),
WFEdgeCore(
name="edge_2",
id=UUID("00000000-0000-0000-0000-000000000000"),
source_stage_id=UUID("00000000-0000-0000-0000-000000000000"),
target_stage_id=UUID("00000000-0000-0000-0000-000000000000"),
),
]
test_stage = Stage(
stage_meta.client,
WFStageCore(
id=UUID("00000000-0000-0000-0000-000000000000"),
name="test-stage",
type=WFTypeCore.ANNOTATE,
assignable_users=[],
edges=edges,
),
{
"team_slug": "default-team",
"dataset_id": 000000,
"workflow_id": UUID("00000000-0000-0000-0000-000000000000"),
},
)
assert len(test_stage.edges) == 2
assert len(test_stage.edges[0]) == 3
assert test_stage.edges[0][0] == UUID("00000000-0000-0000-0000-000000000000")

0 comments on commit 1ac5d03

Please sign in to comment.