-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip added file * define model schema * remove runnable from model schema add models to pipeline
- Loading branch information
Showing
3 changed files
with
55 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from typing import Optional | ||
|
||
from pydantic import root_validator | ||
|
||
from pipeline.schemas.base import BaseModel | ||
from pipeline.schemas.file import FileCreate, FileGet | ||
|
||
|
||
class ModelBase(BaseModel): | ||
id: Optional[str] | ||
name: str | ||
|
||
|
||
class ModelGet(ModelBase): | ||
id: str | ||
hex_file: FileGet | ||
|
||
source_sample: str | ||
|
||
class Config: | ||
orm_mode = True | ||
|
||
|
||
class ModelGetDetailed(ModelGet): | ||
... | ||
|
||
|
||
class ModelCreate(BaseModel): | ||
# The local ID is assigned when a new model is used as part of a new | ||
# pipeline; the server uses the local ID to associated a model to a | ||
# Pipeline before replacing the local ID with the server-generated one | ||
local_id: Optional[str] | ||
|
||
model_source: str | ||
|
||
name: str | ||
|
||
file_id: Optional[str] | ||
file: Optional[FileCreate] | ||
|
||
@root_validator | ||
def file_or_id_validation(cls, values): | ||
file, file_id = values.get("file"), values.get("file_id") | ||
|
||
file_defined = file is not None | ||
file_id_defined = file_id is not None | ||
|
||
if file_defined == file_id_defined: | ||
raise ValueError("You must define either the file OR file_id of a model.") | ||
|
||
return values |
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