Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions bigml/api_handlers/sourcehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
LOGGER.addHandler(CONSOLE)

MAX_CHANGES = 5

MAX_RETRIES = 5

def compact_regions(regions):
"""Returns the list of regions in the compact value used for updates """
Expand Down Expand Up @@ -573,18 +573,20 @@ def update_composite_annotations(self, source, images_file,
offset * MAX_CHANGES: (offset + 1) * MAX_CHANGES]
if new_batch:
source = self.update_source(source,
{"row_values": new_batch})
if source["error"] is not None:
{"row_values": new_batch})+
counter = 0
while source["error"] is not None and counter < MAX_RETRIES:
# retrying in case update is temporarily unavailable
time.sleep(1)
counter += 1
time.sleep(counter)
source = self.get_source(source)
self.ok(source)
source = self.update_source(source,
{"row_values": new_batch})
if source["error"] is not None:
LOGGER.error("WARNING: Some annotations were not"
" updated (%s)",
new_batch)
if source["error"] is not None:
LOGGER.error("WARNING: Some annotations were not"
" updated (%s)",
new_batch)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps it'd be a good idea to log also source["error"] here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, though the error message and code are not very reprentative so far

if not self.ok(source):
raise Exception(
f"Failed to update {len(new_batch)} annotations.")
Expand Down
Loading