-
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
Feature/mx 1677 orcid extractor #361
base: main
Are you sure you want to change the base?
Conversation
I think this occurs because I have added orcid as a primary source? |
|
yep, that's it. feel free to bump the expected length up to 5 |
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.
good work already! i found some unused bits and pieces, and i had one bigger issue with the way the orcid models are written. could you take a look at that first?
i didn't review the tests yet, but i think they might change a bit anyway once the models are updated.
…mmon into feature/mx-1677-orcid-extractor
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's coming along! we just need to ensure proper unit test isolation
I was running my unit tests after pulling all new changes from main. But now I encounter this error:
|
But I fixed the requested changes and made sure I'm running unit tests and no integration tests |
…mmon into feature/mx-1677-orcid-extractor
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.
a few simplifications and were good to go
@staticmethod | ||
def get_data_by_id(orcid_id: str) -> dict[str, Any]: | ||
"""Retrieve data by UNIQUE ORCID ID. | ||
|
||
Args: | ||
orcid_id: Unique identifier in ORCID system. | ||
|
||
Returns: | ||
Personal data of the single matching id. | ||
""" | ||
orcidapi = OrcidConnector.get() | ||
# or endpoint = f"{orcid_id}/person" | ||
endpoint = f"{orcid_id}/record" | ||
return dict(orcidapi.request(method="GET", endpoint=endpoint)) |
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 does this have to be static?
@staticmethod | |
def get_data_by_id(orcid_id: str) -> dict[str, Any]: | |
"""Retrieve data by UNIQUE ORCID ID. | |
Args: | |
orcid_id: Unique identifier in ORCID system. | |
Returns: | |
Personal data of the single matching id. | |
""" | |
orcidapi = OrcidConnector.get() | |
# or endpoint = f"{orcid_id}/person" | |
endpoint = f"{orcid_id}/record" | |
return dict(orcidapi.request(method="GET", endpoint=endpoint)) | |
def get_data_by_id(self, orcid_id: str) -> dict[str, Any]: | |
"""Retrieve data by UNIQUE ORCID ID. | |
Args: | |
orcid_id: Unique identifier in ORCID system. | |
Returns: | |
Personal data of the single matching id. | |
""" | |
endpoint = f"{orcid_id}/record" | |
return dict(self.request(method="GET", endpoint=endpoint)) |
response = self._send_request("HEAD", url=url, params={}) | ||
response.raise_for_status() | ||
|
||
def check_orcid_id_exists(self, orcid_id: str) -> bool: |
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.
this method is unused in mex-common, do you need it for mex-backend?
|
||
def fetch(self, filters: dict[str, Any]) -> dict[str, Any]: | ||
"""Perform a search query against the ORCID API.""" | ||
query = OrcidConnector.build_query(filters) |
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.
query = OrcidConnector.build_query(filters) | |
query = self.build_query(filters) |
return dict(orcidapi.request(method="GET", endpoint=endpoint)) | ||
|
||
@staticmethod | ||
def get_data_by_name( |
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.
same here, why make this static?
instead of orcidapi = OrcidConnector.get()
you could just use self
|
||
def build_query(filters: dict[str, Any]) -> str: | ||
"""Construct the ORCID API query string.""" | ||
if "givennames" in filters: | ||
return "givennames:Josiah AND familyname:Carberry" | ||
return "given-names:Josiah AND family-name:Carberry" | ||
|
||
monkeypatch.setattr(OrcidConnector, "build_query", staticmethod(build_query)) |
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.
def build_query(filters: dict[str, Any]) -> str: | |
"""Construct the ORCID API query string.""" | |
if "givennames" in filters: | |
return "givennames:Josiah AND familyname:Carberry" | |
return "given-names:Josiah AND family-name:Carberry" | |
monkeypatch.setattr(OrcidConnector, "build_query", staticmethod(build_query)) |
you don't need to mock this method. since it does not do any network-io, it is "unit-test-safe"
Returns: | ||
Orcidrecord of the matching person by name. | ||
""" | ||
orcid_data = OrcidConnector.get_data_by_name( |
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.
when you make get_data_by_name non-static, this would become:
orcid_data = OrcidConnector.get_data_by_name( | |
orcid_data = OrcidConnector.get().get_data_by_name( |
PR Context
connector in mex-common that takes a string or orcid ID as argument
returns orcid person
convenience function: search for person, if one is found, transform to ExtractedPerson
Added
Changes
Deprecated
Removed
Fixed
Security