Skip to content

Commit

Permalink
Updating code2fn to use local artifacts for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentraymond-ua committed Apr 19, 2024
1 parent f55bca9 commit 1f4d110
Show file tree
Hide file tree
Showing 25 changed files with 43 additions and 41 deletions.
Binary file removed data/program_analysis/ABM-COVID-ABS.zip
Binary file not shown.
Binary file removed data/program_analysis/ABM-COmplexVID-19.zip
Binary file not shown.
Binary file removed data/program_analysis/ABM-Covasim.zip
Binary file not shown.
Binary file removed data/program_analysis/ABM-REINA.zip
Binary file not shown.
Binary file removed data/program_analysis/Bucky.zip
Binary file not shown.
Binary file removed data/program_analysis/CHIME-SIR-model.zip
Binary file not shown.
Binary file removed data/program_analysis/CHIME-SVIIvR-model.zip
Binary file not shown.
Binary file removed data/program_analysis/CHIME-penn-full-model.zip
Binary file not shown.
Binary file removed data/program_analysis/Climlab.zip
Binary file not shown.
Binary file not shown.
Binary file removed data/program_analysis/Generated-Halfar.zip
Binary file not shown.
Binary file removed data/program_analysis/MechBayes.zip
Binary file not shown.
Binary file removed data/program_analysis/SIDARTHE.zip
Binary file not shown.
Binary file removed data/program_analysis/SV2AIR3-Waterloo-MATLAB.zip
Binary file not shown.
Binary file removed data/program_analysis/Simple-SIR.zip
Binary file not shown.
Binary file removed data/program_analysis/TIE-GCM.zip
Binary file not shown.
Binary file removed data/program_analysis/cism_v3.zip
Binary file not shown.
Binary file removed data/program_analysis/climlab-v2.zip
Binary file not shown.
Binary file removed data/program_analysis/code_sir.zip
Binary file not shown.
Binary file removed data/program_analysis/examples_python.zip
Binary file not shown.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ all = ["skema[core]", "skema[dev]", "skema[doc]", "skema[demo]", "skema[annotati
"skema.rest" = "skema/rest"
"skema.skema_py" = "skema/skema_py"
"skema.utils" = "skema/utils"
"skema.data" = "skema/data"

# re-map skema/text_reading/python to skema.text_reading
#"skema.text_reading" = "skema/text_reading/python"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
from skema.program_analysis.tree_sitter_parsers.util import extension_to_language
from skema.rest.utils import fn_preprocessor
from skema.utils.fold import del_nulls, dictionary_to_gromet_json
from skema.data.program_analysis import MODEL_ZIP_ROOT_PATH


THIS_PATH = Path(__file__).parent.resolve()
MODEL_YAML_PATH = Path(__file__).parent / "models.yaml"
Expand Down Expand Up @@ -141,11 +143,14 @@ def process_single_model(html: HTML_Instance, output_dir: str, model_name: str):
"""Generate an HTML report for a single model"""
html.add_model(model_name)

if model_name in MODEL_YAML:
model_url = MODEL_YAML[model_name]["zip_archive"]
response = requests.get(model_url)

zip = ZipFile(BytesIO(response.content))


if not model_name in MODEL_YAML:
return

model_path = MODEL_ZIP_ROOT_PATH.resolve() / MODEL_YAML[model_name]["zip_archive"]

zip = ZipFile(BytesIO(model_path.read_bytes()))
with TemporaryDirectory() as temp:
# We need to write all the files to the temporary directory before processing
# This is because some steps may require additional files, such as include directories in Fortran
Expand Down
39 changes: 19 additions & 20 deletions skema/program_analysis/model_coverage_report/models.yaml
Original file line number Diff line number Diff line change
@@ -1,57 +1,56 @@
---
CHIME-penn-full:
zip_archive: "https://artifacts.askem.lum.ai/askem/data/models/zip-archives/CHIME-penn-full-model.zip"
zip_archive: "CHIME-penn-full-model.zip"

CHIME-SIR:
zip_archive: "https://artifacts.askem.lum.ai/askem/data/models/zip-archives/CHIME-SIR-model.zip"
zip_archive: "CHIME-SIR-model.zip"

CHIME-SVIIvR:
zip_archive: "https://artifacts.askem.lum.ai/askem/data/models/zip-archives/CHIME-SVIIvR-model.zip"
zip_archive: "CHIME-SVIIvR-model.zip"

ABM-COmplexVID-19:
zip_archive: "https://artifacts.askem.lum.ai/askem/data/models/zip-archives/ABM-COmplexVID-19.zip"
zip_archive: "ABM-COmplexVID-19.zip"

ABM-COVID-ABS:
zip_archive: "https://artifacts.askem.lum.ai/askem/data/models/zip-archives/ABM-COVID-ABS.zip"
zip_archive: "ABM-COVID-ABS.zip"

CHIME-penn-full:
zip_archive: "https://artifacts.askem.lum.ai/askem/data/models/zip-archives/CHIME-penn-full-model.zip"
zip_archive: "CHIME-penn-full-model.zip"

MechBayes:
zip_archive: "https://artifacts.askem.lum.ai/askem/data/models/zip-archives/MechBayes.zip"
zip_archive: "MechBayes.zip"

SIDARTHE:
zip_archive: "https://artifacts.askem.lum.ai/askem/data/models/zip-archives/SIDARTHE.zip"
zip_archive: "SIDARTHE.zip"

Simple-SIR:
zip_archive: "https://artifacts.askem.lum.ai/askem/data/models/zip-archives/Simple-SIR.zip"
zip_archive: "Simple-SIR.zip"

Climlab-v1:
zip_archive: "https://artifacts.askem.lum.ai/askem/data/models/zip-archives/Climlab.zip"
zip_archive: "Climlab.zip"

Climlab-v2:
zip_archive: "https://artifacts.askem.lum.ai/askem/data/models/zip-archives/climlab-v2.zip"
zip_archive: "climlab-v2.zip"

Examples-Python:
zip_archive: "https://artifacts.askem.lum.ai/askem/data/models/zip-archives/examples_python.zip"
zip_archive: "examples_python.zip"

Generated-Halfar:
zip_archive: "https://artifacts.askem.lum.ai/askem/data/models/zip-archives/Generated-Halfar.zip"
zip_archive: "Generated-Halfar.zip"

SV2AIR3-Waterloo-MATLAB:
zip_archive: "https://artifacts.askem.lum.ai/askem/data/models/zip-archives/SV2AIR3-Waterloo-MATLAB.zip"
zip_archive: "SV2AIR3-Waterloo-MATLAB.zip"

Bucky:
zip_archive: "https://artifacts.askem.lum.ai/askem/data/models/zip-archives/Bucky.zip"
zip_archive: "Bucky.zip"

ABM-REINA:
zip_archive: "https://artifacts.askem.lum.ai/askem/data/models/zip-archives/ABM-REINA.zip"
zip_archive: "ABM-REINA.zip"

Cornell-COVID19-sim-Frazier:
zip_archive: "https://artifacts.askem.lum.ai/askem/data/models/zip-archives/Cornell-COVID19-sim-Frazier.zip"
zip_archive: "Cornell-COVID19-sim-Frazier.zip"

ABM-Covasim:
zip_archive: "https://artifacts.askem.lum.ai/askem/data/models/zip-archives/ABM-Covasim.zip"
zip_archive: "ABM-Covasim.zip"

TIE-GCM:
zip_archive: "https://artifacts.askem.lum.ai/askem/data/models/zip-archives/TIE-GCM.zip"
zip_archive: "TIE-GCM.zip"
6 changes: 3 additions & 3 deletions skema/program_analysis/tests/test_code2fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

from skema.program_analysis.multi_file_ingester import process_file_system
from skema.gromet.fn import GrometFNModuleCollection
from skema.data.program_analysis import MODEL_ZIP_ROOT_PATH

BUCKY_ZIP_URL = "https://artifacts.askem.lum.ai/askem/data/models/zip-archives/Bucky.zip"
BUCKY_ZIP_URL = MODEL_ZIP_ROOT_PATH.resolve() / "Bucky.zip"

def test_code2fn():
"""This is simply a smokescreen test to see if the PA pipeline runs to
Expand All @@ -19,8 +20,7 @@ def test_code2fn():
flag or postprocessing function to be able to compare two GroMEts modulo
their random components."""

response = requests.get(BUCKY_ZIP_URL)
zip = zipfile.ZipFile(io.BytesIO(response.content))
zip = zipfile.ZipFile(io.BytesIO(BUCKY_ZIP_URL.read_bytes()))

with TemporaryDirectory() as temp:
system_filepaths_path = Path(temp) / "system_filepaths.txt"
Expand Down
23 changes: 10 additions & 13 deletions skema/rest/tests/test_model_to_amr.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import json
import httpx
import pytest
import asyncio
import requests
from pathlib import Path
Expand All @@ -16,26 +19,21 @@
from skema.rest.llm_proxy import Dynamics
from skema.rest.proxies import SKEMA_RS_ADDESS
from skema.skema_py import server as code2fn
import json
import httpx
import pytest
from skema.data.program_analysis import MODEL_ZIP_ROOT_PATH

CHIME_SIR_URL = (
"https://artifacts.askem.lum.ai/askem/data/models/zip-archives/CHIME-SIR-model.zip"
)

SIDARTHE_URL = (
"https://artifacts.askem.lum.ai/askem/data/models/zip-archives/SIDARTHE.zip"
)
CHIME_SIR_PATH = MODEL_ZIP_ROOT_PATH.resolve() / "CHIME-SIR-model.zip"
SIDARTHE_PATH = MODEL_ZIP_ROOT_PATH.resolve() / "SIDARTHE.zip"


@pytest.mark.asyncio
async def test_any_amr_chime_sir():
"""
Unit test for checking that Chime-SIR model produces any AMR. This test zip contains 4 versions of CHIME SIR.
This will test if just the core dynamics works, the whole script, and also rewritten scripts work.
"""
response = requests.get(CHIME_SIR_URL)
zip_bytes = BytesIO(response.content)

zip_bytes = BytesIO(CHIME_SIR_PATH.read_bytes())

# NOTE: For CI we are unable to use the LLM assisted functions due to API keys
# So, we will instead mock the output for those functions instead
Expand Down Expand Up @@ -136,8 +134,7 @@ async def test_any_amr_sidarthe():
Unit test for checking that Chime-SIR model produces any AMR. This test zip contains 4 versions of CHIME SIR.
This will test if just the core dynamics works, the whole script, and also rewritten scripts work.
"""
response = requests.get(SIDARTHE_URL)
zip_bytes = BytesIO(response.content)
zip_bytes = BytesIO(SIDARTHE_PATH.read_bytes())

# NOTE: For CI we are unable to use the LLM assisted functions due to API keys
# So, we will instead mock the output for those functions instead
Expand Down

0 comments on commit 1f4d110

Please sign in to comment.