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 13 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."""
edges = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not obligatory, but you could do this with a list comprehension, which are a bit faster, and worth getting used to.

    return [
        [edge.id, edge.source_stage_id, edge.target_stage_id]
        for edge in in self._element.edges
    ]

Optional, but consider it, and also have a think about listcomps in general.

for edge in self._element.edges:
edges.append([edge.id, edge.source_stage_id, edge.target_stage_id])
return edges
25 changes: 22 additions & 3 deletions darwin/future/tests/meta/objects/test_stagemeta.py
Original file line number Diff line number Diff line change
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,23 @@ 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
assert stage_meta.edges == []
Loading