-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IO-1278][IO-1277] Core Items/Folders apis (#691)
* basics * get folders * linting * tests * linting * camel case fields * line length * line length * linting changes * linting changes * import sorting * assert not required * merge master * linting
- Loading branch information
1 parent
b0953bf
commit f5992b4
Showing
27 changed files
with
359 additions
and
55 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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# Can't import * in this module because of a circular import problem specific to teams | ||
# The TeamCore module can instantiate from a client, but the client needs to use the team backend module | ||
# to request the object for team. To circumvent this there's a get_raw method in this module that returns | ||
# the raw team object, which is then passed to the TeamCore module, but if we import * here it introduces the | ||
# The TeamCore module can instantiate from a client, but the client needs to use the | ||
# team backend module to request the object for team. To circumvent this there's a | ||
# get_raw method in this module that returns the raw team object, which is then passed | ||
# to the TeamCore module, but if we import * here it introduces the | ||
# circular import problem. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# @see: GraphotateWeb.Schemas.DatasetsV2.ItemRegistration.ExistingItem | ||
from typing import Dict, List, Literal, Optional, Union | ||
from uuid import UUID | ||
|
||
from pydantic import Field, validator | ||
|
||
from darwin.datatypes import NumberLike | ||
from darwin.future.data_objects.pydantic_base import DefaultDarwin | ||
from darwin.future.data_objects.typing import UnknownType | ||
|
||
ItemFrameRate = Union[NumberLike, Literal["native"]] | ||
|
||
|
||
def validate_no_slashes(v: UnknownType) -> str: | ||
assert isinstance(v, str), "Must be a string" | ||
assert len(v) > 0, "cannot be empty" | ||
assert r"^[^/].*$".find(v) == -1, "cannot start with a slash" | ||
|
||
return v | ||
|
||
|
||
class ItemSlot(DefaultDarwin): | ||
# GraphotateWeb.Schemas.DatasetsV2.ItemRegistration.ExistingSlot | ||
|
||
# Required fields | ||
slot_name: str | ||
file_name: str | ||
|
||
# Optional fields | ||
storage_key: Optional[str] | ||
as_frames: Optional[bool] | ||
extract_views: Optional[bool] | ||
fps: Optional[ItemFrameRate] = Field(None, alias="fps") | ||
metadata: Optional[Dict[str, UnknownType]] = Field({}, alias="metadata") | ||
tags: Optional[Union[List[str], Dict[str, str]]] = Field(None, alias="tags") | ||
type: Literal["image", "video", "pdf", "dicom"] = Field(..., alias="type") | ||
|
||
@validator("slot_name") | ||
def validate_slot_name(cls, v: UnknownType) -> str: | ||
assert isinstance(v, str), "slot_name must be a string" | ||
assert len(v) > 0, "slot_name cannot be empty" | ||
return v | ||
|
||
@validator("storage_key") | ||
def validate_storage_key(cls, v: UnknownType) -> str: | ||
return validate_no_slashes(v) | ||
|
||
@validator("fps") | ||
def validate_fps(cls, v: UnknownType) -> ItemFrameRate: | ||
assert isinstance(v, (int, float, str)), "fps must be a number or 'native'" | ||
if isinstance(v, (int, float)): | ||
assert v >= 0.0, "fps must be a positive number" | ||
if isinstance(v, str): | ||
assert v == "native", "fps must be 'native' or a number greater than 0" | ||
return v | ||
|
||
|
||
class Item(DefaultDarwin): | ||
name: str | ||
path: str | ||
archived: bool | ||
dataset_id: int | ||
id: UUID | ||
layout: Dict[str, UnknownType] | ||
slots: List[ItemSlot] | ||
processing_status: str | ||
priority: int | ||
|
||
@validator("name") | ||
def validate_name(cls, v: UnknownType) -> str: | ||
return validate_no_slashes(v) | ||
|
||
|
||
class Folder(DefaultDarwin): | ||
dataset_id: int | ||
filtered_item_count: int | ||
path: str | ||
unfiltered_item_count: int |
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.