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

Run notebook examples in CI #132

Merged
merged 5 commits into from
Aug 22, 2024

Conversation

Saityi
Copy link
Collaborator

@Saityi Saityi commented Aug 22, 2024

Issue

Our notebook examples easily go out of date, and it's hard to notice when it happens without a regular CI checking them

Fix

Convert notebook examples to Julia code and run them

Fix errors CI exposed:

  • Graph was removed from visualization.jl, but was used by examples, especially older ones
  • ClOUD -> CLOUD
  • Graph -> GraphCL
  • Remove Pkg.activate('../../../') in a causal loop example
  • Fix a causal loop example to use vectors instead of tuples

Notes

Includes commits from #131 and verifies removing GraphViz did not break any examples. @KevinDCarlson

Also addresses #113 (comment)

Misc

  • Removed ipynb-checkpoints and add a more generalised pattern to exclude them
  • Ignore vim & emacs temporary files
  • Clean up a couple complaints from Aqua.jl around non-existent exports
  • Renamed full_fledged_schema_examples/CaulsalLoopDiagrams to full_fledged_schema_examples/CausalLoopDiagrams

These tests can be run locally by running the helper script, validate-notebook-examples.sh, which does what the workflow does:

$ validate-notebook-examples.sh
Starting to run notebooks ...
Checking: ["./jlexamples/full_fledged_schema_examples.COVID_full_model.ipynb.jl", "./jlexamples/full_fledged_schema_examples.Pertussis Model.ipynb.jl", "./jlexamples/full_fledged_schema_examples.SEIR_full_model_measles_chickenpox.ipynb.jl", "./jlexamples/full_fledged_schema_examples.SIR_example_function_structure_test_compostion_and_stratification.ipynb.jl", "./jlexamples/full_fledged_schema_examples.composed open population SIRV model.ipynb.jl", "./jlexamples/full_fledged_schema_examples.convert_from_SEIR_stockFlowDiagram.ipynb.jl", "./jlexamples/full_fledged_schema_examples.create_a_causalLoopDiagram.ipynb.jl", "./jlexamples/full_fledged_schema_examples.curable sexually transmitted diseases model.ipynb.jl", "./jlexamples/full_fledged_schema_examples.diabetes model.ipynb.jl", "./jlexamples/full_fledged_schema_examples.diabetes_diagnose.ipynb.jl", "./jlexamples/full_fledged_schema_examples.sex_transmission_SIS.ipynb.jl", "./jlexamples/full_fledged_schema_examples_new.COVID_full_model.ipynb.jl", "./jlexamples/
OK: Any["./jlexamples/full_fledged_schema_examples.COVID_full_model.ipynb.jl", "./jlexamples/full_fledged_schema_examples.Pertussis Model.ipynb.jl", "./jlexamples/full_fledged_schema_examples.SEIR_full_model_measles_chickenpox.ipynb.jl", "./jlexamples/full_fledged_schema_examples.SIR_example_function_structure_test_compostion_and_stratification.ipynb.jl", "./jlexamples/full_fledged_schema_examples.composed open population SIRV model.ipynb.jl", "./jlexamples/full_fledged_schema_examples.convert_from_SEIR_stockFlowDiagram.ipynb.jl", "./jlexamples/full_fledged_schema_examples.create_a_causalLoopDiagram.ipynb.jl", "./jlexamples/full_fledged_schema_examples.curable sexually transmitted diseases model.ipynb.jl", "./jlexamples/full_fledged_schema_examples.diabetes model.ipynb.jl", "./jlexamples/full_fledged_schema_examples.diabetes_diagnose.ipynb.jl", "./jlexamples/full_fledged_schema_examples.sex_transmission_SIS.ipynb.jl", "./jlexamples/full_fledged_schema_examples_new.COVID_full_model.ipynb.jl", "./jlexamples/ful

TODO

  • In line with the comment in Causal Loop with Polarities #128 (review) we should consider renaming functions like Graph and what our 'display' API looks like going into a full initial 1.0
  • Speed up notebook regression tests (e.g., parallelism in the test runner or performance improvements in the library).
    • I tried a simple speed up using the Threads.@threads on the for loop in the test runner, but was getting strange errors: Reason: LoadError: package StockFlow did not define the expected module StockFlow, check for typos in package module name

KevinDCarlson and others added 4 commits August 19, 2024 18:51
Move OrdinaryDiffEq to [extras] and use TestEnv to add it for examples

Update gitignore to ignore all ipynb_checkpoints & rm existing ones in repo

Restore Graph function for StockAndFlow

Remove non-existing exports
Remove Pkg.activate("../../..")

ClOUD -> CLOUD

CausalLoop uses vectors now, not tuples
Copy link
Collaborator

@neonWhiteout neonWhiteout left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks Alex.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any particular reason you changed it to a Vector? I'd think it'd work either way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't work either way.

MethodError: no method matching CausalLoop(::Tuple{Symbol, Symbol, Symbol}, ::NTuple{4, Pair{Symbol, Symbol}})

Stacktrace:
 [1] top-level scope
   @ In[2]:2

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh dang. Sorry.

@@ -663,7 +661,7 @@
" \n",
" :flows\n",
" CLOUD => f_NewBorn(v_NewBorn) => NormalWeight\n",
" NormalWeight => f_DeathNormalWeight(v_DeathNormalWeight) => ClOUD\n",
" NormalWeight => f_DeathNormalWeight(v_DeathNormalWeight) => CLOUD\n",
" NormalWeight => f_BecomingOverWeight(v_BecomingOverWeight) => OverWeight\n",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I swear, I thought we've fixed this same thing 3 times over...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we have CI on these, hopefully it never slips back in! 😃

@KevinDCarlson
Copy link
Contributor

Just a remark that the “official” way to accomplish what you’re doing here is with Literate.jl, which will generate Documenter files, notebooks, and scripts from the same markdown source, if you find that shell script inconvenient to maintain at some point.

@Saityi Saityi merged commit d636847 into AlgebraicJulia:main Aug 22, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants