-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
32 lines (25 loc) · 987 Bytes
/
models.py
File metadata and controls
32 lines (25 loc) · 987 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import typing as tp
from uuid import uuid4
from pydantic import BaseModel, Field
class ProductionSchemaStage(BaseModel):
name: str
stage_id: str = Field(default_factory=lambda: uuid4().hex)
type: tp.Optional[str] = None
description: tp.Optional[str] = None
equipment: tp.Optional[tp.List[str]] = None
workplace: tp.Optional[str] = None
duration_seconds: tp.Optional[int] = None
class ProductionSchema(BaseModel):
schema_id: str = Field(default_factory=lambda: uuid4().hex)
unit_name: str
unit_short_name: str = None
schema_type: str
production_stages: tp.Optional[tp.List[ProductionSchemaStage]] = None
required_components_schema_ids: tp.Optional[tp.List[str]] = None
parent_schema_id: tp.Optional[str] = None
@property
def is_composite(self) -> bool:
return self.required_components_schema_ids is not None
@property
def is_a_component(self) -> bool:
return self.parent_schema_id is not None