-
Notifications
You must be signed in to change notification settings - Fork 3
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
pragerdom/be-366: OpenAIRE authority provider #199
base: main
Are you sure you want to change the base?
pragerdom/be-366: OpenAIRE authority provider #199
Conversation
response.raise_for_status() | ||
return response.json().get("access_token") | ||
except requests.exceptions.HTTPError as http_err: | ||
print(f"HTTP error occurred: {http_err}") |
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.
please use logger.error() instead of print
|
||
response = requests.get(url, headers=headers, params=params) | ||
if response.status_code != 200: | ||
print(f"Error response: {response.status_code}") |
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.
dtto
client_id = current_app.config["OPENAIRE_CLIENT_ID"] | ||
client_secret = current_app.config["OPENAIRE_CLIENT_SECRET"] | ||
except RuntimeError: | ||
client_id = os.environ["INVENIO_OPENAIRE_CLIENT_ID"] |
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.
Assume you always have current_app and remove the os.environ code (if needed in tests, add "app" fixture to test arguments
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.
I assumed I should keep this since we also have it at orcid_provider.py. Will change it there too in that case.
|
||
def search(self, identity, params, **kwargs): | ||
params = params or {} | ||
access_token = self.openaire_client.get_token() |
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.
Can we cache the token for some time?
|
||
try: | ||
relations = project.get("rels", {}).get("rel", []) | ||
except KeyError: |
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 Key & Attribute error should not be thrown here, as you use .get(...)
"id": OpenAIREProvider.dict_get(funding, "funder", "id", "$"), | ||
"name": OpenAIREProvider.dict_get(funding, "funder", "name", "$"), | ||
} | ||
except IndexError: |
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.
Are these errors thrown? dict_get seems to check for path existence before x[...]
"id": relation_to.get("$", ""), | ||
"organization": relation.get("legalname", {}).get("$", "") | ||
}) | ||
except AttributeError: |
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 does the attribute error come from?
Quality Gate passedIssues Measures |
No description provided.