Skip to content

Enable or disable source code logging#

By default, Neptune automatically 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() function, 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.

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

Turning off source code logging#

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

run = neptune.init_run(source_files=[])

Git information will still be logged. For details and how to disable it, see Logging Git info.

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() function.

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).

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:

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