Pass Run object between files

Pass Run object around to log from multiple Python files

When you create a run object:

run = neptune.init(project='my_workspace/my_project')

You can pass it around and use it to populate functions’ parameters and perform logging from multiple Python files.

Let’s create a recipe for that:

main.py

# Import from file shown below
from utils import log_images_epoch
# Create run in project
run = neptune.init(project='my_workspace/my_project')
# Log metrics in the same file
run['train/acc'] = 0.95
run['train/f1'] = 0.65
# Log by using imported function, pass 'run'
log_images_epoch(run=run)

utils.py

# 'run' is Neptune run
def log_images_epoch(run):
image1 = ...
image2 = ...
run['images/img_1'].upload(image1)
run['images/img_2'].upload(image2)

In this way, you can work with a larger codebase and use logging from multiple Python files.