Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make uploading large datasets more robust #162

Merged
merged 10 commits into from
Aug 16, 2023
Merged

Conversation

tonylampada
Copy link
Collaborator

@tonylampada tonylampada commented Aug 9, 2023

Description

Fixes #163

The upload API may sometimes have some hiccups giving 502 errors with some html in the response.

The pip package handles errors, but doing response.json() when handling an error will itself throw an error, and that can break uploading a big dataset.

This PR makes uploading more robust when using workspace.upload_dataset

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How has this change been tested, please provide a testcase or example of how you tested the change?

Uploaded big dataset using a snippet like

testupload.py

#! /Users/tony/.pyenv/shims/python

from roboflow import Roboflow

# export API_URL=https://api.roboflow.one
# export APP_URL=https://app.roboflow.one
# python testupload.py 2>stderr.log | tee stdout.log 

# import roboflow
# roboflow.login(force=True)

rf = Roboflow()
workspace = rf.workspace("tonyprivate2")
dataset_path = '/Users/tony/Downloads/ppe.voc'
workspace.upload_dataset(dataset_path=dataset_path, num_workers=10, project_name="ppe", dataset_format="voc")

Obs: if you separate stdout from stderr with something like python testupload.py 2>stderr.log | tee stdout.logyou get only the bad failures in stderr.

@tonylampada tonylampada marked this pull request as ready for review August 10, 2023 02:38
@CLAassistant
Copy link

CLAassistant commented Aug 11, 2023

CLA assistant check
All committers have signed the CLA.

@tonylampada tonylampada marked this pull request as draft August 15, 2023 20:10
@tonylampada tonylampada changed the title defend against error when converting http response to json Make uploading large datasets more robust Aug 15, 2023
Copy link
Contributor

@probicheaux probicheaux left a comment

Choose a reason for hiding this comment

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

lgtm!

if response.status_code == 200:
if responsejson:
if "duplicate" in responsejson.keys():
print(f"Duplicate image not uploaded: {image_path}")
Copy link
Contributor

@probicheaux probicheaux Aug 15, 2023

Choose a reason for hiding this comment

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

maybe should be warning or info

@tonylampada tonylampada merged commit 5ae3e32 into main Aug 16, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python Errors during Dataset Upload: ConnectionError and JSONDecodeError
3 participants