Skip to content

Commit

Permalink
Merge pull request #310 from nanglo123/update_notebook_code_only
Browse files Browse the repository at this point in the history
Update code in notebooks for LLM ingestion
  • Loading branch information
bgyori authored Mar 22, 2024
2 parents aaabd31 + ecef351 commit 4352191
Show file tree
Hide file tree
Showing 18 changed files with 360 additions and 150 deletions.
26 changes: 9 additions & 17 deletions notebooks/ASKEM MIRA demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -71,7 +69,7 @@
"outputs": [],
"source": [
"from mira.sources.biomodels import get_template_model\n",
"from mira.sources.sbml import template_model_from_sbml_file_path\n",
"# from mira.sources.sbml import template_model_from_sbml_file_path\n",
"\n",
"# Uncomment this to allow local fallback\n",
"# def local_get_template_model(model_id): \n",
Expand Down Expand Up @@ -153,9 +151,7 @@
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -277,9 +273,7 @@
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -423,7 +417,7 @@
"source": [
"## Generating model exchange formats from MIRA\n",
"Currently surpported\n",
"- Petri nets: https://miramodel.readthedocs.io/en/latest/modeling.html#module-mira.modeling.petri\n",
"- Petri nets: https://miramodel.readthedocs.io/en/latest/modeling.html#module-mira.modeling.acsets.petri\n",
"- Bilayers: https://miramodel.readthedocs.io/en/latest/modeling.html#module-mira.modeling.bilayer\n",
"- ODEs: https://miramodel.readthedocs.io/en/latest/modeling.html#module-mira.modeling.ode"
]
Expand Down Expand Up @@ -521,7 +515,7 @@
}
],
"source": [
"from mira.modeling.petri import PetriNetModel\n",
"from mira.modeling.acsets.petri import PetriNetModel\n",
"pm = PetriNetModel(Model(models['991']))\n",
"pm.to_json()"
]
Expand All @@ -540,9 +534,7 @@
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand All @@ -565,7 +557,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -579,7 +571,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.9"
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@
"rows = []\n",
"for model_data in tqdm(models_res):\n",
" try:\n",
" template_model = get_template_model(model_data[\"id\"])\n",
" template_model = get_template_model(model_data[\"biomodels_id\"])\n",
" except Exception:\n",
" pass\n",
" rows.append((\n",
" model_data[\"id\"], model_data[\"name\"], template_model,\n",
" model_data[\"biomodels_id\"], model_data[\"name\"], template_model,\n",
" ))"
]
},
Expand Down Expand Up @@ -249,9 +249,9 @@
"source": [
"# Add the hospitalized node\n",
"\n",
"svihr = svir.add_transition(infected_symptomatic, hospitalized)\n",
"svihr = svihr.add_transition(infected_asymptomatic, recovered)\n",
"svihr = svihr.add_transition(hospitalized, recovered)"
"svihr = svir.add_transition(\"test_1\",infected_symptomatic, hospitalized)\n",
"svihr = svihr.add_transition(\"test_2\",infected_asymptomatic, recovered)\n",
"svihr = svihr.add_transition(\"test_3\",hospitalized, recovered)"
]
},
{
Expand Down Expand Up @@ -331,7 +331,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down
3 changes: 2 additions & 1 deletion notebooks/Hackathon Scenario 4.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"source": [
"from mira.sources.biomodels import get_template_model\n",
"from mira.metamodel import TemplateModelComparison, get_dkg_refinement_closure\n",
"import matplotlib.pyplot as plt \n",
"refinement_fun = get_dkg_refinement_closure().is_ontological_child"
]
},
Expand Down Expand Up @@ -241,7 +242,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion notebooks/System Dynamics Ingestion.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"from pathlib import Path \n",
"from mira.sources.system_dynamics.vensim import template_model_from_mdl_url\n",
"from mira.sources.system_dynamics.stella import template_model_from_stella_model_url\n",
"from mira.sources.amr.stockflow import main\n",
"from mira.sources.amr.stockflow import *\n",
"from mira.metamodel.ops import stratify"
]
},
Expand Down
139 changes: 130 additions & 9 deletions notebooks/biomodels.ipynb

Large diffs are not rendered by default.

16 changes: 5 additions & 11 deletions notebooks/evaluation_2023.01/Scenario1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
"cell_type": "code",
"execution_count": 1,
"id": "81eb0574",
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"from mira.metamodel.ops import stratify\n",
"from mira.modeling.viz import GraphicalModel\n",
"from mira.modeling.petri import PetriNetModel\n",
"from mira.modeling.acsets.petri import PetriNetModel\n",
"from mira.modeling import Model\n",
"from mira.metamodel import model_to_json_file, ControlledConversion"
]
Expand Down Expand Up @@ -86,9 +84,7 @@
"cell_type": "code",
"execution_count": 6,
"id": "d8500893",
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"tm = stratify(sir_parameterized,\n",
Expand Down Expand Up @@ -241,9 +237,7 @@
"cell_type": "code",
"execution_count": 14,
"id": "ca0d1643",
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -351,7 +345,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down
10 changes: 4 additions & 6 deletions notebooks/evaluation_2023.01/Scenario2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"from IPython.display import Image\n",
"from mira.sources.biomodels import get_template_model\n",
"from mira.modeling import Model\n",
"from mira.modeling.petri import PetriNetModel\n",
"from mira.modeling.acsets.petri import PetriNetModel\n",
"from mira.metamodel import model_to_json_file\n",
"from mira.modeling.viz import GraphicalModel\n",
"from mira.metamodel import NaturalConversion, Parameter\n",
Expand Down Expand Up @@ -322,9 +322,7 @@
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -478,9 +476,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}
18 changes: 7 additions & 11 deletions notebooks/evaluation_2023.01/Scenario3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"outputs": [],
"source": [
"from mira.modeling import Model\n",
"from mira.modeling.petri import PetriNetModel\n",
"from mira.modeling.acsets.petri import PetriNetModel\n",
"from mira.sources.biomodels import get_template_model\n",
"from mira.metamodel import TemplateModelDelta, ControlledConversion\n",
"from mira.dkg.web_client import is_ontological_child_web\n",
Expand Down Expand Up @@ -208,9 +208,7 @@
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -325,9 +323,9 @@
"import glob\n",
"import re\n",
"from mira.metamodel import model_to_json_file\n",
"from mira.sources.petri import template_model_from_petri_json_file\n",
"from mira.sources.acsets.petri import template_model_from_petri_json_file\n",
"from mira.modeling import Model\n",
"from mira.modeling.petri import PetriNetModel\n",
"from mira.modeling.acsets.petri import PetriNetModel\n",
"\n",
"\n",
"fnames = glob.glob('../../../program-milestones/6-month-milestone/evaluation/scenario_3/ta_2/UF/*.json')\n",
Expand Down Expand Up @@ -570,9 +568,7 @@
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -942,9 +938,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}
Loading

0 comments on commit 4352191

Please sign in to comment.