Skip to content

Commit

Permalink
Merge pull request #212 from indralab/fix-test-file
Browse files Browse the repository at this point in the history
Fix test file path
  • Loading branch information
bgyori authored Jul 14, 2023
2 parents 4945c98 + fdb4363 commit 5f22de7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
3 changes: 3 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
10 changes: 7 additions & 3 deletions mira/dkg/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
5 changes: 4 additions & 1 deletion mira/sources/askenet/flux_span.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
10 changes: 7 additions & 3 deletions tests/test_model_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5f22de7

Please sign in to comment.