Optimizing logging calls to reduce requests#
Related error
Experiencing connection interruptions. Will try to reestablish communication with Neptune. Internal exception was: HTTPTooManyRequests
This error occurs when there's a delay between logging data and sending it to the Neptune servers. The error doesn't imply data loss; it means that you can't watch the training process in real time in the Neptune app.
To avoid sending too many requests to the Neptune server too frequently, you can optimize your logging calls.
Series#
If you're logging a series, you can use the extend()
method instead of append()
.
The below involves ten logging calls:
The following results in the same metadata structure, but involves a single logging call:
The tradeoff is that in the first case, values are logged almost as soon as they are generated. This is not the case with the latter.
Logging multiple series fields in nested loops#
To optimize batching when creating multiple series fields in a single statement, iterate through the fields in the outer loop and the values in the inner loop:
for i in range(1000):
for field in range(500):
run[f"my_metric_{field}"].append(i)
Files#
Uploading files one by one with the upload()
method results in one File
field for each file. Instead, to log files in batch, you can do one of the following:
- Upload a folder or set with the
upload_files()
method (results in aFileSet
field) - Create a series of files with
append()
orextend()
(results in aFileSeries
field)