Skip to content

Optimizing logging calls to reduce requests#

Related error

Experiencing connection interruptions. Will try to reestablish communication with Neptune. Internal exception was: HTTPTooManyRequests

To avoid sending too many requests to the Neptune server too frequently, there may be things you can do to 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:

for value in range(10):
    run["values"].append(value)

The following results in the same metadata structure, but involves a single logging call:

run["values"].extend([value for value in range(10)])

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.

Files#

Instead of uploading files one by one with upload() (resulting in one File field for each file) you could do one of the following:

  • Upload the files in batch with upload_files() (results in a FileSet field)
  • Create a series of files with append() or extend() (results in a FileSeries field)

Getting help