Skip to main content

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]
source = "examples/example_single_file.py"
parameter_file = "examples/params.json"
override = ['beta="from_pyproject"']
entrypoint = "run"
expand_module = ["sub_mod"]
embed_file = ["examples/sub_mod.py"]
output = "dist/example_single_file.ipynb"
show_analysis = true
show_schema = true

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

astronote-0.1.2.tar.gz (57.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

astronote-0.1.2-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file astronote-0.1.2.tar.gz.

File metadata

  • Download URL: astronote-0.1.2.tar.gz
  • Upload date:
  • Size: 57.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for astronote-0.1.2.tar.gz
Algorithm Hash digest
SHA256 8e2e216bfc809dbe9baa1e846619e9915f993fbb4ac042a4a0eecfab7b4b344e
MD5 2e7cf69c35e7873f161a772040677aad
BLAKE2b-256 9d99bf76e36101e3ad7f2ebf8e67bdc6cd9258ac3b91bedf77c904ec15ce4d02

See more details on using hashes here.

File details

Details for the file astronote-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: astronote-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for astronote-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e585f7048086f5f5071af9b2e50c7086e56adb552619f6bebe2c39bd630b7c44
MD5 596d4320f390b17e2de1138f11a93cd0
BLAKE2b-256 81557594ce1eafc594ed971971dd756e78550a880b1abd80c44666a46fc57e39

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page