Skip to content

Pass run object between scripts#

Once you've created a run with the init_run() function, you can pass it around multiple Python scripts.

You can use the run object to populate parameters of functions in other files. This way, you can work with a larger codebase and log from multiple Python scripts at once.


# Import from "" file
from utils import log_images_epoch

# Create run in project
run = neptune.init_run()  # (1)!

# Log metrics in the same file
run["train/acc"] = 0.95
run["train/f1"] = 0.65

# Log by using an imported function, passing "run" as the argument
  1. We recommend saving your API token and project name as environment variables.

    If needed, you can pass them as arguments when initializing Neptune:

        api_token="Your Neptune API token here",
# "run" is the Neptune run
def log_images_epoch(run):
    image1 = ...
    image2 = ...