Skip to content

Upload or download files#

Uploading files#

You can generally pass any file path to the upload() method. This will upload the contents of the file under the specified field in the run.

Log a file
run = neptune.init_run()
run["aux/data"].upload("auxiliary-data.zip")

See example uploads in Neptune 

To see the upload() commands that were used for this example, check the code snapshot in the Source code tab.

Artifact tip

You should only upload files that you specifically want to store or interact with in Neptune.

If you just want to track the metadata of your files (for example, for versioning purposes) logging them as artifacts is handier than uploading the files in full.

For details, see Track artifacts.

Logging chart or figure objects#

To log a file-like object, like a confusion matrix, simply assign the object to a field name of your choice.

import matplotlib.pyplot as plt

fig = plt.figure(figsize=(7, 9))

# Log figure to run
run["my-figure"] = fig

Viewing files in the web app#

To preview files logged with the upload() function, navigate to Run detailsAll metadata.

A more convenient way to display logged files is to create a custom dashboard with one or more File preview widgets.

  1. In the Run details view mode, create a custom dashboard if you don't have one already.
  2. Select Add widget.
  3. In the input box at the stop, start typing the name of the file field you want to display.

    Alternatively, you can add the File preview widget first, then view suggestions for files to display.

  4. Save your dashboard.

Downloading or fetching files#

Use the download() function to fetch uploaded files.

First, connect to the run in your code:

import neptune

run = neptune.init_run(with_id="NLI-8", mode="read-only")
Download a file to the current working directory
run["data/sample"].download()
Download a file to the specified directory
run["data/sample"].download(destination="path/to/destination")

Related

Query the API

File series#

Series of images in carousel mode

For FileSeries fields created with append() or extend(), you can use download() or download_last() to fetch the files.

Log images as series
import neptune

run = neptune.init_run()
for iteration in range(100):
    pil_image = ...
    run["train/predictions"].append(pil_image)
Fetch all logged images of the series
run["train/predictions"].download(destination="downloaded_predictions")

File set#

Preview of set of images

If you don't need advanced display options for individual files, you can upload a set of files to a single field with the upload_files() method.

run["data_samples"].upload_files("data/dataset_samples")
run["config_files"].upload_files([path_to_config_1, path_to_config_2])
Use a wildcard pattern (glob)
run["preprocessing_scripts"].upload_files("./preprocessing/*.py") # (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).

You can still preview and download individual files from the set, but if you create a custom widget, you can only preview the FileSet field as a whole.

If you want to display and interact with images individually, log them to separate fields instead: run["my-file"].upload("path/to/single/file.png")