-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IO-1279] Functions to move items around stages (#640)
* WIP: moving items to stage * WIP: moving items to stage * WIP: moving items to stage * pushing items between stages * added stage syntax * WIP dogfooding functions * fixing broken tests * remove curses * tests for query * tests for core * tests for stageMeta * dogfooding feedback * dogfooding feedback * fixes for tests
- Loading branch information
1 parent
fb2c848
commit fae6e41
Showing
25 changed files
with
487 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from typing import List, Union | ||
from uuid import UUID | ||
|
||
from darwin.future.core.client import Client | ||
from darwin.future.core.types.common import QueryString | ||
|
||
|
||
def get_item_ids(api_client: Client, team_slug: str, dataset_id: Union[str, int]) -> List[UUID]: | ||
""" | ||
Returns a list of item ids for the dataset | ||
Parameters | ||
---------- | ||
client: Client | ||
The client to use for the request | ||
team_slug: str | ||
The slug of the team to get item ids for | ||
dataset_id: str | ||
The id or slug of the dataset to get item ids for | ||
Returns | ||
------- | ||
List[UUID] | ||
A list of item ids | ||
""" | ||
|
||
response = api_client.get( | ||
f"/v2/teams/{team_slug}/items/ids", | ||
QueryString({"not_statuses": "archived,error", "sort[id]": "desc", "dataset_ids": str(dataset_id)}), | ||
) | ||
assert type(response) == dict | ||
uuids = [UUID(uuid) for uuid in response["item_ids"]] | ||
return uuids | ||
|
||
|
||
def get_item_ids_stage( | ||
api_client: Client, team_slug: str, dataset_id: Union[int, str], stage_id: Union[UUID, str] | ||
) -> List[UUID]: | ||
""" | ||
Returns a list of item ids for the stage | ||
Parameters | ||
---------- | ||
client: Client | ||
The client to use for the request | ||
team_slug: str | ||
The slug of the team to get item ids for | ||
dataset_id: str | ||
The id or slug of the dataset to get item ids for | ||
stage_id: str | ||
The id or slug of the stage to get item ids for | ||
Returns | ||
------- | ||
List[UUID] | ||
A list of item ids | ||
""" | ||
response = api_client.get( | ||
f"/v2/teams/{team_slug}/items/ids", | ||
QueryString({"workflow_stage_ids": str(stage_id), "dataset_ids": str(dataset_id)}), | ||
) | ||
assert type(response) == dict | ||
uuids = [UUID(uuid) for uuid in response["item_ids"]] | ||
return uuids |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from typing import List | ||
from uuid import UUID | ||
|
||
from darwin.future.core.client import Client, JSONType | ||
|
||
|
||
def move_items_to_stage( | ||
api_client: Client, team_slug: str, workflow_id: UUID, dataset_id: int, stage_id: UUID, item_ids: List[UUID] | ||
) -> JSONType: | ||
""" | ||
Moves a list of items to a stage | ||
Parameters | ||
---------- | ||
client: Client | ||
The client to use for the request | ||
team_slug: str | ||
The slug of the team to move items for | ||
dataset_id: str | ||
The id or slug of the dataset to move items for | ||
stage_id: str | ||
The id or slug of the stage to move items to | ||
item_ids: List[UUID] | ||
A list of item ids to move to the stage | ||
Returns | ||
------- | ||
None | ||
""" | ||
|
||
return api_client.post( | ||
f"/v2/teams/{team_slug}/items/stage", | ||
{ | ||
"filters": { | ||
"dataset_ids": [dataset_id], | ||
"item_ids": [str(id) for id in item_ids], | ||
}, | ||
"stage_id": str(stage_id), | ||
"workflow_id": str(workflow_id), | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.