Skip to content

Commit

Permalink
need to test still
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Szendrey committed Feb 27, 2024
1 parent 982280a commit 1781e04
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 6 additions & 7 deletions service/models/operations/optimize.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from __future__ import annotations

# from enum import Enum
from typing import ClassVar, Dict, List, Optional, Tuple
from typing import ClassVar, Dict, List, Optional

import numpy as np
import torch
from pydantic import BaseModel, Field, Extra


from models.base import OperationRequest, Timespan
from models.base import OperationRequest, Timespan, InterventionObject
from models.converters import convert_to_static_interventions
from utils.tds import fetch_model, fetch_inferred_parameters


Expand Down Expand Up @@ -58,8 +57,8 @@ class Optimize(OperationRequest):
pyciemss_lib_function: ClassVar[str] = "optimize"
model_config_id: str = Field(..., example="ba8da8d4-047d-11ee-be56")
timespan: Timespan = Timespan(start=0, end=90)
interventions: List[Tuple[float, str]] = Field(
default_factory=list, example=[(1.0, "beta")]
interventions: List[InterventionObject] = Field(
default_factory=list, example=[{"timestep": 1, "name": "beta", "value": 0.4}]
)
step_size: float = 1.0
qoi: List[str] # QOIMethod
Expand All @@ -75,7 +74,7 @@ def gen_pyciemss_args(self, job_id):
# Get model from TDS
amr_path = fetch_model(self.model_config_id, job_id)

interventions = {torch.tensor(k): v for k, v in self.interventions}
interventions = convert_to_static_interventions(self.interventions)

extra_options = self.extra.dict()
inferred_parameters = fetch_inferred_parameters(
Expand Down
6 changes: 5 additions & 1 deletion tests/examples/optimize/input/request.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
"user_id": "not_provided",
"model_config_id": "sidarthe",
"interventions": [
[1.0, "beta"]
{
"timestep": 1.0,
"name": "beta",
"value": 0.4
}
],
"timespan": {
"start": 0,
Expand Down

0 comments on commit 1781e04

Please sign in to comment.