moved models to separate folder
This commit is contained in:
parent
1b7c56ac3e
commit
c4fdd68af2
60
app/main.py
60
app/main.py
@ -2,66 +2,10 @@ from fastapi import FastAPI, __version__
|
||||
from pydantic import BaseModel
|
||||
from typing import Set, List, Optional, Dict
|
||||
|
||||
from models.solver_content import SolverContent
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
class MetaData(BaseModel):
|
||||
key: str
|
||||
value: str
|
||||
field_id: Optional[int]
|
||||
option_id: Optional[int]
|
||||
|
||||
class Item(BaseModel):
|
||||
id: int
|
||||
metadata: List[MetaData]
|
||||
|
||||
class Constraint(BaseModel):
|
||||
key: str
|
||||
value: str
|
||||
field_id: Optional[int]
|
||||
option_id: Optional[int]
|
||||
minimum: int
|
||||
maximum: int
|
||||
|
||||
class IRTModel(BaseModel):
|
||||
a_param: float
|
||||
b_param: float
|
||||
c_param: float
|
||||
model: str
|
||||
|
||||
class Targets(BaseModel):
|
||||
neg_2_5: int
|
||||
neg_1_5: int
|
||||
neg_0_5: int
|
||||
_0_5: int
|
||||
_1: int
|
||||
|
||||
class ObjectiveFunction(BaseModel):
|
||||
# minimizing tif/tcc target value is only option currently
|
||||
# as we add more we can build this out to be more dynamic
|
||||
# likely with models representing each objective function type
|
||||
tif_targets: Targets
|
||||
tcc_targets: Targets
|
||||
weight: Dict = {'tif': 1, 'tcc': 1}
|
||||
|
||||
class AdvancedOptions(BaseModel):
|
||||
# will supported currently
|
||||
linearity_check: bool
|
||||
show_progress: bool
|
||||
max_solution_time: Optional[int]
|
||||
brand_bound_tolerance: Optional[float]
|
||||
max_forms: Optional[int]
|
||||
precision: Optional[float]
|
||||
extra_param_range: Optional[List[Dict]]
|
||||
|
||||
class SolverContent(BaseModel):
|
||||
items: List[Item]
|
||||
constraints: List[Constraint]
|
||||
irt_model: IRTModel
|
||||
objective_fuction: ObjectiveFunction
|
||||
total_form_items: int
|
||||
advanced_options: Optional[List[AdvancedOptions]]
|
||||
engine: str
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
return {"message": "Welcome to Measures LOFT solver service. v0.1"}
|
||||
|
12
app/models/advanced_options.py
Normal file
12
app/models/advanced_options.py
Normal file
@ -0,0 +1,12 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import List, Optional, Dict
|
||||
|
||||
class AdvancedOptions(BaseModel):
|
||||
# will supported currently
|
||||
linearity_check: bool
|
||||
show_progress: bool
|
||||
max_solution_time: Optional[int]
|
||||
brand_bound_tolerance: Optional[float]
|
||||
max_forms: Optional[int]
|
||||
precision: Optional[float]
|
||||
extra_param_range: Optional[List[Dict]]
|
10
app/models/constraint.py
Normal file
10
app/models/constraint.py
Normal file
@ -0,0 +1,10 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional
|
||||
|
||||
class Constraint(BaseModel):
|
||||
key: str
|
||||
value: str
|
||||
field_id: Optional[int]
|
||||
option_id: Optional[int]
|
||||
minimum: int
|
||||
maximum: int
|
7
app/models/irt_model.py
Normal file
7
app/models/irt_model.py
Normal file
@ -0,0 +1,7 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
class IRTModel(BaseModel):
|
||||
a_param: float
|
||||
b_param: float
|
||||
c_param: float
|
||||
model: str
|
8
app/models/item.py
Normal file
8
app/models/item.py
Normal file
@ -0,0 +1,8 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import List
|
||||
|
||||
from models.metadata import MetaData
|
||||
|
||||
class Item(BaseModel):
|
||||
id: int
|
||||
metadata: List[MetaData]
|
8
app/models/metadata.py
Normal file
8
app/models/metadata.py
Normal file
@ -0,0 +1,8 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional
|
||||
|
||||
class MetaData(BaseModel):
|
||||
key: str
|
||||
value: str
|
||||
field_id: Optional[int]
|
||||
option_id: Optional[int]
|
12
app/models/objective_function.py
Normal file
12
app/models/objective_function.py
Normal file
@ -0,0 +1,12 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import Dict
|
||||
|
||||
from models.targets import Targets
|
||||
|
||||
class ObjectiveFunction(BaseModel):
|
||||
# minimizing tif/tcc target value is only option currently
|
||||
# as we add more we can build this out to be more dynamic
|
||||
# likely with models representing each objective function type
|
||||
tif_targets: Targets
|
||||
tcc_targets: Targets
|
||||
weight: Dict = {'tif': 1, 'tcc': 1}
|
17
app/models/solver_content.py
Normal file
17
app/models/solver_content.py
Normal file
@ -0,0 +1,17 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import List, Optional
|
||||
|
||||
from models.item import Item
|
||||
from models.constraint import Constraint
|
||||
from models.irt_model import IRTModel
|
||||
from models.objective_function import ObjectiveFunction
|
||||
from models.advanced_options import AdvancedOptions
|
||||
|
||||
class SolverContent(BaseModel):
|
||||
items: List[Item]
|
||||
constraints: List[Constraint]
|
||||
irt_model: IRTModel
|
||||
objective_fuction: ObjectiveFunction
|
||||
total_form_items: int
|
||||
advanced_options: Optional[List[AdvancedOptions]]
|
||||
engine: str
|
8
app/models/targets.py
Normal file
8
app/models/targets.py
Normal file
@ -0,0 +1,8 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
class Targets(BaseModel):
|
||||
neg_2_5: int
|
||||
neg_1_5: int
|
||||
neg_0_5: int
|
||||
_0_5: int
|
||||
_1: int
|
Loading…
x
Reference in New Issue
Block a user