{"id":17771509,"url":"https://github.com/marius311/parameterizednotebooks.jl","last_synced_at":"2025-06-25T13:06:43.172Z","repository":{"id":37716779,"uuid":"347776858","full_name":"marius311/ParameterizedNotebooks.jl","owner":"marius311","description":"Parameterize Jupyter notebooks in Julia","archived":false,"fork":false,"pushed_at":"2023-11-07T06:15:41.000Z","size":507,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-15T18:36:26.640Z","etag":null,"topics":["julia","jupyter","notebook"],"latest_commit_sha":null,"homepage":"","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marius311.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-14T23:09:24.000Z","updated_at":"2023-11-06T21:06:49.000Z","dependencies_parsed_at":"2024-10-26T21:56:49.992Z","dependency_job_id":"6418f236-dfc7-4d03-a35e-85275560894a","html_url":"https://github.com/marius311/ParameterizedNotebooks.jl","commit_stats":{"total_commits":18,"total_committers":1,"mean_commits":18.0,"dds":0.0,"last_synced_commit":"5a499b5636da701c024fb76d26ed698cd683a5f3"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/marius311/ParameterizedNotebooks.jl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marius311%2FParameterizedNotebooks.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marius311%2FParameterizedNotebooks.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marius311%2FParameterizedNotebooks.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marius311%2FParameterizedNotebooks.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marius311","download_url":"https://codeload.github.com/marius311/ParameterizedNotebooks.jl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marius311%2FParameterizedNotebooks.jl/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261879316,"owners_count":23223739,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["julia","jupyter","notebook"],"created_at":"2024-10-26T21:33:25.884Z","updated_at":"2025-06-25T13:06:43.145Z","avatar_url":"https://github.com/marius311.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ParameterizedNotebooks\n\n[![runtests](https://github.com/marius311/ParameterizedNotebooks.jl/actions/workflows/runtests.yml/badge.svg)](https://github.com/marius311/ParameterizedNotebooks.jl/actions/workflows/runtests.yml)\n\nTurn a Jupyter notebook or specific sections within a Jupyter notebook into a general purpose Julia function which can be run repeatedly from the same or other Julia sessions with different input arguments.\n\n## Install\n\nRequires Julia 1.6 or above. From the Julia package prompt:\n\n```\npkg\u003e add ParameterizedNotebooks\n```\n\n## Usage\n\nBest demonstrated with an example:\n\n![](examples/example.png)\n\nThere are no limitations on what the notebook contains or how complex it is, only that the arguments which will be parameterized over are marked with `@nbparam name = val`. The `@nbparam` macro does nothing special when running the notebook normally in Jupyter, so above `seed` is set to `1` and execution proceeds as usual. \n\nYou can mark code which should only run in Jupyter but will otherwise be skipped in the parameterized call (e.g. visualization) with `@nbonly`. \n\nYou can return a value from the notebook with the `@nbreturn` macro. `@nbreturn` is also useful to return the parameterized call somewhere before the end of your notebook. Code cells below this are not run and can contain other code, even triggering the parameterized call itself from the same kernel/notebook, as in the above example. \n\n## Advanced\n\n### Running only parts of the notebook\n\nYou can also select only certain sections from the notebook to run with the keyword argument `sections`. Sections should be delineated in the notebook with typical markdown headings. For example:\n\n```julia\nParameterizedNotebook(\"mynotebook.ipynb\", sections=(\"Initialization\", \"Compute result\"))\n```\n\nwill run all code in the sections \"Initialization\" and \"Compute result\" and all of their subsections. If recursing into the subsections is undesired, also pass `recursive=false`. The `sections` argument should be a string matching a heading title exactly or a regex which matches a heading title, or a tuple of strings/regexs for matching multiple sections. \n\nWhen `sections` is provided, printing the `ParameterizedNotebook` shows a tree which can be used to verify the expected code will be run, e.g. you might see something like this:\n\n```julia\njulia\u003e ParameterizedNotebook(\"mynotebook.ipynb\", sections=(\"Init\", \"Section B\"), recursive=false)\n\nParameterizedNotebook(\"mynotebook.ipynb\") with parameters: (param1, param2)\n□ ~\n  ☒ Init\n    ☒ …\n  □ Section A\n    □ Subsection A\n  ☒ Section B\n    ☒ …\n    □ Subsection B\n```\n\n### Passing parameters lazily\n\nSometimes its useful to pass parameters which contain code which depends on libraries or variables which aren't loaded or defined until parts of the notebook run. In such cases, you can use the macro form, e.g.:\n\n```julia\n@ParameterizedNotebook(\"mynotebook.ipynb\") do \n  foo = SomeLibrary.bar()  # assuming the notebook loads SomeLibrary\n  baz = 1 + qux  # assuming qux is defined in the notebook\nend\n```\n\nHere, the parameter values are not evaluated until the corresonding `@nbparam foo` and `@nbparam baz` cell in the notebook is actually reached. You can think of this as equivalent to if the code above is pasted into the spot of the `@nbparam` expression in the notebook. (Note the use of the do-block instead of a comma separated list used).\n\n## Details\n\nThe package is extremely simple and just reads the notebook file from disk and repeatedly `eval`'s all or a subset of the cells into `Main` (just as if you had run the cells in Jupyter), replacing `@nbparam` expressions with the appropriate value, skipping `@nbonly` expressions, and returning if it hits a `@nbreturn`.\n\n## Related\n\nSimilar to [takluyver/nbparameterise](https://github.com/takluyver/nbparameterise), [tritemio/nbrun](https://github.com/tritemio/nbrun), and [nteract/papermill](https://github.com/nteract/papermill), but more powerful because arbitrary objects, not just string representations, can be passed as parameters and returned from the notebooks. Also, much simpler to use and only requires decorating a few lines with macros. However, lacks the ability to generate \"reports\" with outputs filled in. Also similar to [stevengj/NBInclude.jl](https://github.com/stevengj/NBInclude.jl) which I discovered after making this, which has some nice orthogonal features, but doesn't let you parameterize.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarius311%2Fparameterizednotebooks.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarius311%2Fparameterizednotebooks.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarius311%2Fparameterizednotebooks.jl/lists"}