-
Notifications
You must be signed in to change notification settings - Fork 26
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
Use file download URL as provided by the API #370
Conversation
# important, do not remove | ||
if convert_to_bool(os.getenv("SPARSEZOO_TEST_MODE")): | ||
download_url += "?increment_download=False" | ||
delimiter = "&" if "?" in download_url else "?" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
file["url"] = get_file_download_url( | ||
model_id=file["model_id"], file_name=file["display_name"] | ||
) | ||
file["url"] = get_file_download_url(file["download_url"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is this used now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, never mind, see it was replacing the previous key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The get_file_download_url
function is only called from this file, I can get rid of that method and move the logic here if you like. That would look something like:
def include_file_download_url(files: List[Dict]):
for file in files:
download_url = file["download_url"]
del file["download_url"]
# important, do not remove
if convert_to_bool(os.getenv("SPARSEZOO_TEST_MODE")):
delimiter = "&" if "?" in download_url else "?"
download_url += f"{delimiter}increment_download=False"
file["url"] = download_url
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need, looks good thanks
model_id=file["model_id"], file_name=file["display_name"] | ||
) | ||
file["url"] = get_file_download_url(file["download_url"]) | ||
del file["download_url"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why delete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not required, just trying to maintain the existing file dict interface of sorts. I'd think having both a url
and download_url
property would confuse anyone looking at the dict and trying to make sense of things
Sparsezoo shouldn't be generating file download URLs, it should use the file downloads provided by the API. The download URLs from the API are cheap and allow sparsezoo to be agnostic of where the files live on the interwebs and decoupled from whatever the current file download implementation is.