Skip to content

Commit

Permalink
Fix serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
fivegrant committed Feb 14, 2024
1 parent 344f039 commit 50a7e2c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 19 deletions.
11 changes: 2 additions & 9 deletions service/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Calibrate,
Simulate,
EnsembleSimulate,
Optimize,
StatusSimulationIdGetResponse,
)

Expand All @@ -20,6 +21,7 @@
"simulate": Simulate,
"calibrate": Calibrate,
"ensemble-simulate": EnsembleSimulate,
"optimize": Optimize,
}

logging.basicConfig()
Expand Down Expand Up @@ -114,12 +116,3 @@ def ensemble_calibrate_not_yet_implemented():
This will be reimplemented in the future.
"""
raise HTTPException(status=501, detail="Not yet reimplemented")


@app.get("/optimize", response_model=StatusSimulationIdGetResponse) # NOT YET IN SPEC
def optimize_not_yet_implemented(): # NOT YET IN SPEC
"""
DO NOT USE. Placeholder for `optimize` endpoint.
This will be implemented in the future.
"""
raise HTTPException(status=501, detail="Not yet implemented")
7 changes: 6 additions & 1 deletion service/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
attach_files,
)

from pyciemss.interfaces import sample, calibrate, ensemble_sample # noqa: F401
from pyciemss.interfaces import ( # noqa: F401
sample,
calibrate,
ensemble_sample,
optimize,
)

# jl = newmodule("SciMLIntegration")
# jl.seval("using SciMLIntegration, PythonCall")
Expand Down
6 changes: 0 additions & 6 deletions service/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ class InterventionSelection(BaseModel):
name: str


class QuantityOfInterest(BaseModel):
function: str
state: str
arg: int # TODO: Make this a list of args?


class OperationRequest(BaseModel):
pyciemss_lib_function: ClassVar[str] = ""
engine: str = Field("ciemss", example="ciemss")
Expand Down
3 changes: 2 additions & 1 deletion service/models/operations/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def obs_nday_average_qoi(
return np.mean(dataQoI[:, -ndays:], axis=1)


qoi_implementations = {QOIMethod.obs_nday_average: obs_nday_average_qoi}
qoi_implementations = {QOIMethod.obs_nday_average.value: obs_nday_average_qoi}


class OptimizeExtra(BaseModel):
Expand Down Expand Up @@ -99,3 +99,4 @@ def gen_pyciemss_args(self, job_id):

class Config:
extra = Extra.forbid
use_enum_values = True
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""
NOTE: PyCIEMSS library had a broken ensemble but it has now been fixed. This
test succeeded using the broken version but now fails using the updated PyCIEMSS.
Will be fixed and moved by to `test_ensemble_simulate` soon.
"""
import json

import pytest
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/test_optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


@pytest.mark.example_dir("optimize")
def test_simulate_example(
def test_optimize_example(
example_context, client, worker, file_storage, file_check, requests_mock
):
job_id = "9ed74639-7778-4bb9-96fd-7509d68cd425"
Expand All @@ -22,7 +22,6 @@ def test_simulate_example(
response = client.post(
"/optimize",
json=request,
headers={"Content-Type": "application/json"},
)
simulation_id = response.json()["simulation_id"]
response = client.get(
Expand Down

0 comments on commit 50a7e2c

Please sign in to comment.