Add your description here
Project description
astronote: AST to Reprodceble Output NOTEbook
This tool allows to generate a Jupyter notebook from a Python script. The generated notebook includes the original source code and hyperparameters used for execution, enabling reproducibility and easy sharing of results.
Usage
A notebook entry is defined by decorating a function with @notebook_entry.
This marks the function as an entry point for notebook generation.
When the decorated function is executed, astronote captures its source code and parameters, and generates a notebook that includes this information.
from astronote import notebook_entry
def func() -> str:
return "This is a sub-function, not a notebook entry."
def calc(x: int, y: int) -> int:
return x + y
@notebook_entry
def main(a: int = 10, b: int = 20) -> str:
result = calc(a, b)
return f"The result of calc({a}, {b}) is {result}"
if __name__ == "__main__":
main()
And run the script with:
astronote example.py
you are able to find the generated notebook in the same directory as example.py with a name like example.ipynb.
To embed local helper code directly into the generated notebook instead of keeping imports, use --expand-module for imported module names and --embed-file for local .py paths:
astronote examples/example_multiple_file.py --expand-module sub_mod
astronote examples/example_multiple_file.py --embed-file examples/sub_mod.py
When --embed-file is used, the .py path must resolve to a local module that is actually imported by the source script.
pyproject.toml Configuration
CLI options can also be provided from [tool.astronote] in pyproject.toml.
CLI arguments take precedence over pyproject.toml, and list-style options are merged as pyproject.toml first, then CLI.
[tool.astronote]
# Each variable can be defaulted here, and overridden on the CLI when needed.
# Default SOURCE when you run astronote without a positional SOURCE argument.
# If SOURCE is passed on the CLI, that CLI value is used instead.
source = "examples/example_single_file.py"
# Base parameter set (JSON) to run the entrypoint reproducibly.
parameter_file = "examples/params.json"
# Quick per-run overrides; useful for changing only a few values without editing JSON.
override = ['beta="from_pyproject"']
# Target function to execute when multiple @notebook_entry functions exist.
entrypoint = "run"
# Inline imported local modules by module name (keeps notebook self-contained).
expand_module = ["sub_mod"]
# Inline imported local modules by file path instead of module name.
embed_file = ["examples/sub_mod.py"]
# Where to save the generated notebook.
output = "dist/example_single_file.ipynb"
# Show dependency/expansion analysis to verify what was included.
show_analysis = true
# Show parameter schema/metadata to document expected inputs.
show_schema = true
Usage notes:
sourceis for the "no positional SOURCE" workflow. It lets you runastronotewith no source argument.- CLI positional
SOURCEoverrides[tool.astronote].source. - Scalar options such as
parameter_file,entrypoint, andoutputuse CLI values when provided, otherwisepyproject.tomlvalues. - List options (
override,expand_module,embed_file) are merged in order:pyproject.tomlfirst, then CLI values. show_analysisandshow_schemaare enabling flags: passing CLI flags turns them on; when omitted,pyproject.tomlvalues are used.
With that configuration, astronote can be run without repeating those options on the command line.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file astronote-0.1.5.tar.gz.
File metadata
- Download URL: astronote-0.1.5.tar.gz
- Upload date:
- Size: 56.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11423c4eeb652bf2de10e10071b478645e2ad15849f58db056c40b51a124d062
|
|
| MD5 |
d0ad883ec52e98bd6c108d54dc06bd5f
|
|
| BLAKE2b-256 |
ea8cdfe3f0f3f344a38d375ba7fa511f8b1e6e2c1502bc8c56fe1a91931e1cdd
|
Provenance
The following attestation bundles were made for astronote-0.1.5.tar.gz:
Publisher:
release.yaml on elda27/astronote
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
astronote-0.1.5.tar.gz -
Subject digest:
11423c4eeb652bf2de10e10071b478645e2ad15849f58db056c40b51a124d062 - Sigstore transparency entry: 1448434544
- Sigstore integration time:
-
Permalink:
elda27/astronote@93b3bf5a50c9ad295342a15fe745731b8aeac9da -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/elda27
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@93b3bf5a50c9ad295342a15fe745731b8aeac9da -
Trigger Event:
push
-
Statement type:
File details
Details for the file astronote-0.1.5-py3-none-any.whl.
File metadata
- Download URL: astronote-0.1.5-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60f1ed04ba66360e62aa6478180b99b81001a4dadd82b4838da3028e0f5757d6
|
|
| MD5 |
6066271e13c0e10d14a47b897710d641
|
|
| BLAKE2b-256 |
6baa95b5c40c1e2fc6409bae9c710451fd397c772546edac1fb51293875e2878
|
Provenance
The following attestation bundles were made for astronote-0.1.5-py3-none-any.whl:
Publisher:
release.yaml on elda27/astronote
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
astronote-0.1.5-py3-none-any.whl -
Subject digest:
60f1ed04ba66360e62aa6478180b99b81001a4dadd82b4838da3028e0f5757d6 - Sigstore transparency entry: 1448434612
- Sigstore integration time:
-
Permalink:
elda27/astronote@93b3bf5a50c9ad295342a15fe745731b8aeac9da -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/elda27
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@93b3bf5a50c9ad295342a15fe745731b8aeac9da -
Trigger Event:
push
-
Statement type: