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

[IO-1496][external] Expose the name, type, and edge_ids of Stage objects #690

Merged
merged 16 commits into from
Oct 19, 2023
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
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):
owencjones marked this conversation as resolved.
Show resolved Hide resolved
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")
Loading