Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use refactored PyCIEMSS lib #50

Merged
merged 15 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dist
.venv
.tmp
.vscode
.devcontainer
.cache
.sqlite
experiments-main
Expand Down Expand Up @@ -73,3 +74,4 @@ create.sql
.eslintcache

.version
*.nix
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SHELL = /bin/bash
SHELL = /usr/bin/env bash
LANG = en_US.utf-8
PYTHON = $(shell which python3 || which python)
DOCKER = $(shell which docker)
Expand Down
4 changes: 4 additions & 0 deletions docker/Dockerfile.api
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ COPY poetry.lock poetry.lock
RUN poetry config virtualenvs.create false && \
poetry install --no-root --no-cache

# We have to install PyCIEMSS now since the interface uses Torch
# TODO: Do not use Torch in PyCIEMSS Library interface
RUN poetry run poe install-pyciemss

COPY service service
COPY tests tests
COPY README.md README.md
Expand Down
57 changes: 0 additions & 57 deletions docker/optimize-simulate/output/tds_simulation.json

This file was deleted.

696 changes: 378 additions & 318 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ fakeredis = "^2.17.0"
httpx = "^0.24.1"

[tool.poe.tasks]
install-pyciemss = "pip install --no-cache git+https://github.com/ciemss/pyciemss.git@v0.0.3"
install-pyciemss = "pip install --no-cache-dir git+https://github.com/fivegrant/pyciemss.git@087bc64d935f2ab5090330f1f7d6bde930404115 --use-pep517"


[tool.pytest.ini_options]
markers = ["example_dir"]
Expand Down
26 changes: 19 additions & 7 deletions service/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

import logging
import os
from fastapi import FastAPI, Depends
from fastapi import FastAPI, Depends, HTTPException
from fastapi.middleware.cors import CORSMiddleware

from models import (
Status,
JobResponse,
Calibrate,
Simulate,
OptimizeSimulate,
OptimizeCalibrate,
EnsembleSimulate,
EnsembleCalibrate,
StatusSimulationIdGetResponse,
)

Expand All @@ -22,10 +19,7 @@
operations = {
"simulate": Simulate,
"calibrate": Calibrate,
"optimize-simulate": OptimizeSimulate,
"optimize-calibrate": OptimizeCalibrate,
"ensemble-simulate": EnsembleSimulate,
"ensemble-calibrate": EnsembleCalibrate,
}

logging.basicConfig()
Expand Down Expand Up @@ -111,3 +105,21 @@ def operate(
return create_job(body, operation_name, redis_conn)

registrar(operate)


@app.get("/ensemble-calibrate", response_model=StatusSimulationIdGetResponse)
def ensemble_calibrate_not_yet_implemented():
"""
DO NOT USE. Placeholder for `ensemble-calibrate` endpoint.
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")
13 changes: 1 addition & 12 deletions service/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,7 @@
attach_files,
)

from pyciemss.PetriNetODE.interfaces import ( # noqa: F401
load_and_calibrate_and_sample_petri_model,
load_and_sample_petri_model,
load_and_optimize_and_sample_petri_model,
load_and_calibrate_and_optimize_and_sample_petri_model,
)

from pyciemss.Ensemble.interfaces import ( # noqa: F401
load_and_sample_petri_ensemble,
load_and_calibrate_and_sample_ensemble_model,
)

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

TDS_SIMULATIONS = "/simulations/"
TDS_URL = settings.TDS_URL
Expand Down
Loading