Skip to main content
App version: 3.20250825

Log Git and source code information

Neptune logs Git information and the script execution command by default. Use the API to customize or disable the logging options.

Configure logging

To customize the logging options, use the SourceTrackingConfig object:

  1. Create the SourceTrackingConfig object:

    from neptune_scale.api.run import SourceTrackingConfig


    source_config = SourceTrackingConfig(
    namespace="source_code",
    upload_entry_point=True,
    upload_diff_head=True,
    upload_diff_upstream=True,
    upload_run_command=True,
    )
  2. Pass the config to the source_tracking_config argument of the Run constructor:

    from neptune_scale import Run


    run = Run(
    experiment_name=...,
    source_tracking_config=source_config,
    )

Specify destination path

By default, Neptune logs the information under the source_code namespace.

To store the logged data under a different path, pass it to the namespace argument of the SourceTrackingConfig constructor:

source_config = SourceTrackingConfig(
namespace="source_information",
...
)

Disable logging

To disable all logging, set the source_tracking_config argument of the Run constructor to None:

from neptune_scale import Run


run = Run(
experiment_name=...,
source_tracking_config=None,
)

Log Git info

By default, Neptune automatically extracts and logs the following information from the project's .git directory:

  • commit ID, message, and date
  • commit author and their email
  • Git repository path
  • name of the currently checked out Git branch
  • URLs of Git remotes
  • whether the working tree is dirty – that is, whether it has local changes uncommitted to the current branch

Log Git repository path

Neptune detects the Git repository path by searching the working directory and its parent directories.

To specify the path manually, pass the Git repository path to the repository argument of the SourceTrackingConfig constructor:

source_config = SourceTrackingConfig(
repository="path/to/repository",
...
)

Track uncommited changes

Neptune tracks uncommited changes in your local repository be generating .patch files:

  • To log the diff between your current working directory and the last commit, use the upload_diff_head argument.
  • To log the diff between your current branch and the upstream branch, use the upload_diff_upstream argument.
source_config = SourceTrackingConfig(
upload_diff_head=True,
upload_diff_upstream=True,
...
)

Log source code info

Logging source code information to Neptune can help you with debugging training runs and sharing experiment context with team members.

Log script execution command

To enable or disable logging of the script execution command, use the upload_run_command argument:

source_config = SourceTrackingConfig(
upload_run_command=True,
...
)

Log entry point file

To enable or disable logging of the entry point file, use the upload_entry_point argument:

source_config = SourceTrackingConfig(
upload_entry_point=True,
...
)

View info in the app

To view the logged data in the Neptune app, navigate to the Attributes tab of a selected run.