Upload files
You can log a single file or a sequence of files under the specified attribute of the run. The files are uploaded to the Neptune object storage and the attributes point to the uploaded files.
Upload a single file
To upload a single file to an attribute, use the assign_files()
function. The resulting attribute type is File
.
To log multiple files in a single call, pass multple key-value pairs to the files
dictionary:
from neptune_scale import Run
with Run(...) as run:
run.assign_files(
{
"dataset/data_sample": "sample_data.csv",
"dataset/image_sample": "input/images/img1.png",
}
)
To specify more details about the logged file, for example its MIME type and size, use the File
object:
from neptune_scale import Run
from neptune_scale.types import File
with Run(...) as run:
run.assign_files(
{
"files/file.txt": File(source=b"Hello world!", mime_type="text/plain"),
}
)
Overwrite an attribute value
To overwrite a file stored by an attribute, assign a new file to the same attribute path. If the run is no longer active in your Python session, use the resume
parameter:
run = Run(
run_id="seagull-s68kj78", # a run with this ID already exists
resume=True,
)
run.log_configs({"dataset/data_sample": "different_sample_data.csv",})
run.close()
Download files with API
To download files with API, use neptune-fetcher. For details, see download_files()
.
Upload a file series
To log a sequence of files to a single attribute, use the log_files()
function. The resulting attribute type is FileSeries
.
To log multiple files in a single call, pass multple key-value pairs to the files
dictionary:
from neptune_scale import Run
run = Run(...)
# for step in training loop
run.log_files(
files={"predictions/train": "output/train/predictions.png", "aux/data": "auxiliary-data.csv"},
step=1,
)
Set the step value
To specify the index of the logged file, use the step
parameter:
run.log_files(
files={"predictions/train": "output/train/predictions.png"},
step=2,
)
Note that within a particular attribute path, the step values must increase.
Set custom timestamp
To provide a custom timestamp, pass a Python datetime value to the timestamp
argument:
run.log_files(
data=...,
step=...,
timestamp=datetime.utcnow(),
)
If the timestamp
argument isn't provided, the current time is used.
If timestamp.tzinfo
is not set, the time is assumed to be in the local timezone.
View files in the app
You can view the logged files in the Neptune app and download them directly from there.
To access the files, navigate to the Attributes tab of a selected run.