-
Notifications
You must be signed in to change notification settings - Fork 41
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-1278][IO-1277] Core Items/Folders apis #691
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e9c5615
basics
Nathanjp91 bb3743a
get folders
cfa2e6a
linting
8abc2df
tests
5bca9ff
linting
1aa2773
camel case fields
2ab3fd1
line length
1a3cce4
line length
5dc229b
linting changes
785c764
linting changes
0ffbe10
mypy cleanup and merge master
d5e8f8f
import sorting
32f11e0
assert not required
7e7d0c5
Merge branch 'master' into IO-1278
Nathanjp91 5a2a89d
merge master
Nathanjp91 6d0ea6d
linting
Nathanjp91 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the main one I've changed in my branch |
||
# 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And this is where we'll have to figure it out between us. |
||
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this stuff especially 😉