diff --git a/docker/Dockerfile b/docker/Dockerfile index b2a466c61..d6039abcd 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -30,5 +30,8 @@ RUN python -m pip install git+https://github.com/indralab/mira.git@main#egg=mira python -m pip uninstall -y bootstrap_flask && \ python -m pip install bootstrap_flask +# Copy the example json for reconstructing the ode semantics +RUN wget -O /sw/sir_flux_span.json https://raw.githubusercontent.com/indralab/mira/main/tests/sir_flux_span.json + COPY startup.sh startup.sh ENTRYPOINT ["/bin/bash", "/sw/startup.sh"] diff --git a/mira/dkg/model.py b/mira/dkg/model.py index d0ef3b25a..c062a69c2 100644 --- a/mira/dkg/model.py +++ b/mira/dkg/model.py @@ -34,7 +34,7 @@ from mira.modeling.petri import PetriNetModel, PetriNetResponse from mira.modeling.viz import GraphicalModel from mira.sources.askenet.flux_span import reproduce_ode_semantics, \ - test_file_path + test_file_path, docker_test_file_path from mira.sources.askenet.petrinet import template_model_from_askenet_json from mira.sources.bilayer import template_model_from_bilayer from mira.sources.biomodels import get_sbml_model @@ -700,15 +700,19 @@ def askepetrinet_model_comparison( return resp +flux_span_path = docker_test_file_path if docker_test_file_path.exists() else \ + test_file_path + + class FluxSpanQuery(BaseModel): model: Dict[str, Any] = Field( ..., - example=json.load(test_file_path.open()), + example=json.load(flux_span_path.open()), description="The model to recover the ODE-semantics from.", ) -@model_blueprint.post("/reconstruct_ode_semnatics", +@model_blueprint.post("/reconstruct_ode_semantics", response_model=TemplateModel, tags=["modeling"]) def reproduce_ode_semantics_endpoint( diff --git a/mira/sources/askenet/flux_span.py b/mira/sources/askenet/flux_span.py index 007fe3bfd..d7a5d1335 100644 --- a/mira/sources/askenet/flux_span.py +++ b/mira/sources/askenet/flux_span.py @@ -158,10 +158,13 @@ def set_semantics(tm, model_index): test_file_path = Path( __file__ ).resolve().parent.parent.parent.parent.joinpath('tests/sir_flux_span.json') +docker_test_file_path = Path("/sw/sir_flux_span.json") if __name__ == "__main__": - with open(test_file_path.as_posix()) as fh: + path = docker_test_file_path if docker_test_file_path.exists() else \ + test_file_path + with open(path.as_posix()) as fh: flux_span = json.load(fh) tm = reproduce_ode_semantics(flux_span) tm.annotations.name = 'SIR-Two-City-Flux Stratified Model with ODE Semantics' diff --git a/tests/test_model_api.py b/tests/test_model_api.py index b13706c3e..f79e82841 100644 --- a/tests/test_model_api.py +++ b/tests/test_model_api.py @@ -675,10 +675,14 @@ def test_counts_to_dimensionless_amr(self): def test_reconstruct_ode_semantics_endpoint(self): # Load test file - from mira.sources.askenet.flux_span import test_file_path - strat_model = json.load(test_file_path.open()) + from mira.sources.askenet.flux_span import test_file_path, \ + docker_test_file_path + path = test_file_path if test_file_path.exists() else \ + docker_test_file_path + + strat_model = json.load(path.open()) response = self.client.post( - "/api/reconstruct_ode_semnatics", + "/api/reconstruct_ode_semantics", json={"model": strat_model} ) self.assertEqual(200, response.status_code)