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

Improve new prefix form #1000

Merged
merged 5 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .github/ISSUE_TEMPLATE/new-prefix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ body:
- type: input
id: repository
attributes:
label: Repository
label: Source Code Repository
description: |
What is the version control repository associated with this prefix?

Expand All @@ -64,6 +64,14 @@ body:
description: |
What is the repository's license? Write with a SPDX identifier, if possible.
placeholder: ex. CC0
- type: input
id: publications
attributes:
label: Publications
description: |
If you have a PubMed identifier, PMC identifier, or DOI with an article associated with this resource, please put it here. Please write publications using CURIE syntax. Please delimit multiple unique publications with a pipe "|" character. You only need one CURIE for each publication.
placeholder: ex. doi:10.1101/2022.07.08.499378 | pubmed:33290552 | pmc:PMC4383985

- type: input
id: example
attributes:
Expand Down Expand Up @@ -129,7 +137,13 @@ body:
placeholder: ex. 0000-0003-4423-4370
validations:
required: true

- type: input
id: contributor_email
attributes:
label: Contributor Email
description: Please provide your email address (optional) so others can contact you regarding your contribution
placeholder: ex. cthoyt@gmail.com

- type: input
id: contact_name
attributes:
Expand Down
23 changes: 20 additions & 3 deletions src/bioregistry/gh/new_prefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from bioregistry.constants import BIOREGISTRY_PATH, URI_FORMAT_KEY
from bioregistry.gh import github_client
from bioregistry.license_standardizer import standardize_license
from bioregistry.schema import Author, Resource
from bioregistry.schema import Author, Publication, Resource

Check warning on line 21 in src/bioregistry/gh/new_prefix.py

View check run for this annotation

Codecov / codecov/patch

src/bioregistry/gh/new_prefix.py#L21

Added line #L21 was not covered by tests
from bioregistry.schema_utils import add_resource
from bioregistry.utils import removeprefix

Expand All @@ -41,14 +41,15 @@
"Contributor ORCiD": "contributor_orcid",
"Contributor Name": "contributor_name",
"Contributor GitHub": "contributor_github",
"Contributor Email": "contributor_email",
"Contributor Email": "contributor_email", # enabled in https://github.com/biopragmatics/bioregistry/pull/1000
"Contact ORCiD": "contact_orcid",
"Contact Name": "contact_name",
"Contact Email": "contact_email",
"Contact GitHub": "contact_github",
"Wikidata Property": "wikidata_prefix",
"License": "license",
"Repository": "repository",
"Repository": "repository", # old
"Source Code Repository": "repository",
}

ORCID_HTTP_PREFIX = "http://orcid.org/"
Expand Down Expand Up @@ -119,6 +120,8 @@
if data_license:
resource_data["license"] = standardize_license(data_license) or data_license

publications = list(_yield_publications(resource_data))

Check warning on line 123 in src/bioregistry/gh/new_prefix.py

View check run for this annotation

Codecov / codecov/patch

src/bioregistry/gh/new_prefix.py#L123

Added line #L123 was not covered by tests

if bioregistry.get_resource(prefix) is not None:
# TODO close issue
logger.warning(
Expand All @@ -134,11 +137,25 @@
github_request_issue=issue_id,
wikidata=wikidata,
mappings=mappings,
publications=publications,
**resource_data, # type:ignore
)
return rv


def _yield_publications(data) -> Iterable[Publication]:

Check warning on line 146 in src/bioregistry/gh/new_prefix.py

View check run for this annotation

Codecov / codecov/patch

src/bioregistry/gh/new_prefix.py#L146

Added line #L146 was not covered by tests
for curie in data.pop("publications", "").split("|"):
curie = curie.strip().lower()
try:
prefix, luid = curie.split(":", 1)
except ValueError:
click.echo(f"invalid CURIE: {curie}")
continue

Check warning on line 153 in src/bioregistry/gh/new_prefix.py

View check run for this annotation

Codecov / codecov/patch

src/bioregistry/gh/new_prefix.py#L148-L153

Added lines #L148 - L153 were not covered by tests
if prefix == "pmid":
prefix = "pubmed"
yield Publication(**{prefix: luid})

Check warning on line 156 in src/bioregistry/gh/new_prefix.py

View check run for this annotation

Codecov / codecov/patch

src/bioregistry/gh/new_prefix.py#L155-L156

Added lines #L155 - L156 were not covered by tests


def _pop_orcid(data: Dict[str, str]) -> str:
orcid = data.pop("contributor_orcid")
return _trim_orcid(orcid)
Expand Down
Loading