Skip to content

Logging source code#

By default, Neptune logs the entry-point script and its contents. For example, if the script was executed, that script will be snapshotted.

With the optional source_code parameter of the init_run() method, you can specify extra files to log, or turn off source code logging completely.

Snapshotting Jupyter notebooks

Netpune can't snapshot the code you execute in cloud environments, such as Google Colab.

Neptune supports notebook snapshotting for JupyterLab and Jupyter Notebook with the help of an extension. For setup instructions, see Working with Jupyter.

If you're running your Jupyter notebook locally, you can capture the source code by passing the source_files argument (see Jupyter notebooks below).

Specifying which source files to log#

To specify the source code to snapshot, pass the file paths as a list to the source_files argument of the init_run() method.

# Snapshot and
run = neptune.init_run(source_files=["", ""])

The source_files argument also supports wildcard (glob) patterns:

# Snapshot all Python files and the config.yaml file
run = neptune.init_run(source_files=["**/*.py", "config.yaml"])  # (1)
  1. When using pattern expansion, such as **/*.py, make sure that your expression does not capture files you don't intend to upload. For example, using * as a pattern will upload all files and directories from the current working directory (cwd).

Turning off source code logging#

To turn off logging of source code, pass an empty list to the source_files argument of the init_run() method:

run = neptune.init_run(source_files=[])

Git information will still be logged.

Jupyter notebooks#

If you're running a Jupyter notebook locally – for example, in Visual Studio Code – you can capture the notebook contents by passing the path of the notebook file to the source_files argument when initializing Neptune:

Notebook example
# Snapshot a notebook file from your local system
run = neptune.init_run(source_files=["train.ipynb"])