-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: add suport for Metadata API #26
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5,9 +5,10 @@ | |||||||||||||||||||||||
from requests import Session | ||||||||||||||||||||||||
from requests.adapters import HTTPAdapter, Retry | ||||||||||||||||||||||||
from requests.auth import AuthBase | ||||||||||||||||||||||||
from requests.exceptions import HTTPError | ||||||||||||||||||||||||
from requests.models import PreparedRequest, Response | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
from .models import GetBmCsProjectsResultsParams | ||||||||||||||||||||||||
from .models import GetBmCsProjectsResultsParams, GetExternalMetadataTracksParams | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
class _Auth(AuthBase): # pylint: disable=too-few-public-methods | ||||||||||||||||||||||||
|
@@ -155,3 +156,14 @@ def get_bm_cs_projects_results( | |||||||||||||||||||||||
params=params, | ||||||||||||||||||||||||
**kwargs, | ||||||||||||||||||||||||
).get("data") | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
def get_external_metadata_tracks( | ||||||||||||||||||||||||
self, params: Optional[GetExternalMetadataTracksParams] = None | ||||||||||||||||||||||||
) -> list: | ||||||||||||||||||||||||
try: | ||||||||||||||||||||||||
return self.json(path="/api/external-metadata/tracks", params=params).get( | ||||||||||||||||||||||||
"data" | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
except HTTPError as error: | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this error persistent? if it's a temporary error a retry/backoff loop might be better than ignoring it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔 retry/backoff code is already here: python-acrclient/acrclient/client.py Lines 46 to 56 in 399bcc9
maybe we need to tune it, or it doesn't include 500 errors There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For some entries, the error persists and for some it returns 200 after retrying a few seconds later. You're absolutely correct to handle this in the central location. |
||||||||||||||||||||||||
print(error) | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. imo libs should not have side effects like
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I just pushed the code to have it somewhere. I agree :) |
||||||||||||||||||||||||
return [] |
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.
it should probably also pass kwargs along so users can pass additional args to
requests.get
(like a session for retry/backoff).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.
Ok good idea