Skip to content

Commit

Permalink
Merge pull request #173 from kbase/test-schema-updates
Browse files Browse the repository at this point in the history
Debugging schema updates
  • Loading branch information
ialarmedalien authored Jun 4, 2024
2 parents fdfc8c4 + 0c10fc7 commit 6bf504b
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 101 deletions.
26 changes: 17 additions & 9 deletions .github/workflows/on_schema_update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,54 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Get metadata schema changes
- name: Evaluate metadata schema changes
id: metadata-schema-changes
uses: tj-actions/changed-files@v44
with:
files: |
schema/kbase/linkml/credit_metadata.yaml
- name: Set up python
if: steps.changed-markdown-files.outputs.any_changed == 'true'
if: steps.metadata-schema-changes.outputs.any_changed == 'true'
uses: actions/setup-python@v4
with:
python-version: 3.12

- name: Install linkml
shell: bash -l {0}
run: |
pip3 install linkml
- name: Regenerate JSONSchema bindings for credit metadata schame
if: steps.changed-markdown-files.outputs.any_changed == 'true'
if: steps.metadata-schema-changes.outputs.any_changed == 'true'
shell: bash -l {0}
run: |
pip3 install linkml # and any other bits and pieces required - I think that's it, though
gen-json-schema schema/kbase/linkml/credit_metadata.yaml > schema/kbase/jsonschema/credit_metadata.schema.json
- name: Commit regenerated JSONSchema bindings
if: steps.changed-markdown-files.outputs.any_changed == 'true'
if: steps.metadata-schema-changes.outputs.any_changed == 'true'
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Regenerated JSONSchema bindings for credit metadata schema

- name: checkout DTS repo
- name: Check out DTS repo
if: steps.metadata-schema-changes.outputs.any_changed == 'true'
uses: actions/checkout@v4
with:
repository: kbase/dts
path: dts

- name: Regenerate DTS Golang bindings for credit metadata schame
if: steps.changed-markdown-files.outputs.any_changed == 'true'
if: steps.metadata-schema-changes.outputs.any_changed == 'true'
shell: bash -l {0}
run: |
gen-golang schema/kbase/linkml/credit_metadata.yaml > dts/credit/metadata.go
- name: Create DTS pull request with regenerated credit metadata bindings
if: steps.changed-markdown-files.outputs.any_changed == 'true'
if: steps.metadata-schema-changes.outputs.any_changed == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.PAT }} # https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens
branch: credit-metadata-schema-update
path: dts
title: Update to Credit Engine metadata schema
token: ${{ secrets.GHCR_TOKEN }}
12 changes: 6 additions & 6 deletions credit_engine/clients/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ class GenericClientArgs(BaseModel, extra="ignore", arbitrary_types_allowed=True)
{CE.OutputFormat.JSON, CE.OutputFormat.XML}, const=True
)
doi_file: FilePath | None = Field(None)
dois_from_file: conset(
constr(strip_whitespace=True, min_length=3), min_items=1
) | None = Field(None)
doi_list: conset(
constr(strip_whitespace=True, min_length=3), min_items=1
) | None = Field(None)
dois_from_file: (
conset(constr(strip_whitespace=True, min_length=3), min_items=1) | None
) = Field(None)
doi_list: (
conset(constr(strip_whitespace=True, min_length=3), min_items=1) | None
) = Field(None)
save_files: bool = Field(default=False)
# TODO @ialarmedalien: use client's SAMPLE_DATA_DIR as default
# https://github.com/kbase/credit_engine/issues/158
Expand Down
1 change: 1 addition & 0 deletions credit_engine/clients/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base functionality for any client retrieving data from a data source."""

import types
from enum import Enum
from typing import Any
Expand Down
146 changes: 62 additions & 84 deletions schema/kbase/jsonschema/credit_metadata.schema.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
{
"$id": "https://github.com/kbase/credit_engine/schema/kbase/linkml",
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"metamodel_version": "1.7.0",
"title": "KBase Credit Metadata Schema",
"type": "object",
"version": "0.0.1-commonmeta",
"$defs": {
"Contributor": {
"additionalProperties": false,
"description": "Represents a contributor to the resource.\n\nContributors must have a 'contributor_type', either 'Person' or 'Organization', and\none of the 'name' fields: either 'given_name' and 'family_name' (for a person), or 'name' (for an organization or a person).\n\nThe 'contributor_role' field takes values from the DataCite and CRediT contributor\nroles vocabularies. For more information on these resources and choosing the\nappropriate roles, please see the following links:\n\nDataCite contributor roles: https://support.datacite.org/docs/datacite-metadata-schema-v44-recommended-and-optional-properties#7a-contributortype\n\nCRediT contributor role taxonomy: https://credit.niso.org",
"description": "Represents a contributor to the resource.\n\nContributors must have a 'contributor_type', either 'Person' or 'Organization', and\none of the 'name' fields: either 'given_name' and 'family_name' (for a person), or 'name' (for an organization or a person).\n\nThe 'contributor_role' field takes values from the DataCite and CRediT contributor\nroles vocabularies. For more information on these resources and choosing\nappropriate roles, please see the following links:\n\nDataCite contributor roles: https://support.datacite.org/docs/datacite-metadata-schema-v44-recommended-and-optional-properties#7a-contributortype\n\nCRediT contributor role taxonomy: https://credit.niso.org",
"properties": {
"affiliations": {
"description": "List of organizations with which the contributor is affiliated. For contributors that represent an organization, this may be a parent organization (e.g. KBase, US DOE; Arkin lab, LBNL).",
Expand Down Expand Up @@ -48,20 +41,7 @@
}
},
"required": [
"contributor_type"
],
"anyOf": [
{
"required": [
"name"
]
},
{
"required": [
"family_name",
"given_name"
]
}
"name"
],
"title": "Contributor",
"type": "object"
Expand Down Expand Up @@ -90,20 +70,20 @@
"DataCite:Supervisor",
"DataCite:WorkPackageLeader",
"DataCite:Other",
"CRediT:conceptualization",
"CRediT:data-curation",
"CRediT:formal-analysis",
"CRediT:funding-acquisition",
"CRediT:investigation",
"CRediT:methodology",
"CRediT:project-administration",
"CRediT:resources",
"CRediT:software",
"CRediT:supervision",
"CRediT:validation",
"CRediT:visualization",
"CRediT:writing-original-draft",
"CRediT:writing-review-editing"
"crcr:conceptualization",
"crcr:data-curation",
"crcr:formal-analysis",
"crcr:funding-acquisition",
"crcr:investigation",
"crcr:methodology",
"crcr:project-administration",
"crcr:resources",
"crcr:software",
"crcr:supervision",
"crcr:validation",
"crcr:visualization",
"crcr:writing-original-draft",
"crcr:writing-review-editing"
],
"title": "ContributorRole",
"type": "string"
Expand Down Expand Up @@ -131,8 +111,7 @@
"content_url": {
"description": "The URL of the content of the resource.",
"items": {
"type": "string",
"format": "uri"
"type": "string"
},
"type": "array"
},
Expand All @@ -143,6 +122,13 @@
},
"type": "array"
},
"credit_metadata_source": {
"description": "A list of CURIEs, URIs, or free text entries denoting the source of the credit metadata.",
"items": {
"type": "string"
},
"type": "array"
},
"dates": {
"description": "A list of relevant lifecycle events for the resource. Note that these dates apply only to the resource itself, and not to the creation or update of the credit metadata record for the resource.",
"items": {
Expand Down Expand Up @@ -197,8 +183,7 @@
},
"url": {
"description": "The URL of the resource.",
"type": "string",
"format": "uri"
"type": "string"
},
"version": {
"description": "The version of the resource. This must be an absolute version, not a relative version like 'latest'.",
Expand All @@ -211,18 +196,6 @@
"resource_type",
"titles"
],
"anyOf": [
{
"required": [
"version"
]
},
{
"required": [
"dates"
]
}
],
"title": "CreditMetadata",
"type": "object"
},
Expand Down Expand Up @@ -295,7 +268,7 @@
"properties": {
"date": {
"description": "The date associated with the event. The date may be in the format YYYY, YYYY-MM, or YYYY-MM-DD.",
"pattern": "^\\d{4}(-\\d{2}){0,2}$",
"pattern": "\\d{4}(-\\d{2}){0,2}",
"type": "string"
},
"event": {
Expand Down Expand Up @@ -346,14 +319,10 @@
},
"grant_url": {
"description": "URL for the grant",
"pattern": "^https?://\\S",
"type": "string",
"format": "uri"
"pattern": "^[a-zA-Z0-9.-_]+:\\S",
"type": "string"
}
},
"required": [
"funder"
],
"title": "FundingReference",
"type": "object"
},
Expand All @@ -367,22 +336,9 @@
},
"url": {
"description": "URL for the license.",
"type": "string",
"format": "uri"
"type": "string"
}
},
"anyOf": [
{
"required": [
"url"
]
},
{
"required": [
"id"
]
}
],
"title": "License",
"type": "object"
},
Expand All @@ -408,7 +364,7 @@
},
"PermanentID": {
"additionalProperties": false,
"description": "Represents a persistent unique identifier for an entity, with an optional relationship to some other entity.\n\nThe 'id' field is required; all other fields are optional.\n\nThe values in the 'relationship_type' field come from controlled vocabularies maintained by DataCite and Crossref. See the documentation links below for more details.\n\nDataCite relation types: https://support.datacite.org/docs/datacite-metadata-schema-v44-recommended-and-optional-properties#12b-relationtype\n\nCrossref relation types: https://www.crossref.org/documentation/schema-library/markup-guide-metadata-segments/relationships/",
"description": "Represents a persistent unique identifier for an entity, with an optional relationship to some other entity.\n\nThe 'id' field and 'relationship_type' fields are required.\n\nThe values in the 'relationship_type' field come from controlled vocabularies maintained by DataCite and Crossref. See the documentation links below for more details.\n\nDataCite relation types: https://support.datacite.org/docs/datacite-metadata-schema-v44-recommended-and-optional-properties#12b-relationtype\n\nCrossref relation types: https://www.crossref.org/documentation/schema-library/markup-guide-metadata-segments/relationships/",
"properties": {
"description": {
"description": "Description of that entity.",
Expand All @@ -425,8 +381,7 @@
}
},
"required": [
"id",
"relationship_type"
"id"
],
"title": "PermanentID",
"type": "object"
Expand Down Expand Up @@ -497,7 +452,7 @@
"Crossref:IsSameAs",
"Crossref:IsTranslationOf",
"Crossref:Replaces",
"unknown"
"kbcms:Unknown"
],
"title": "RelationshipType",
"type": "string"
Expand All @@ -512,10 +467,10 @@
},
"Title": {
"additionalProperties": false,
"description": "Represents the title or name of a resource, and the type of that title.\n\nThe 'title' field is required; 'title_type' is only necessary if the text is not the primary title.",
"description": "Represents the title or name of a resource, the type of that title, and the language used (if appropriate).\n\nThe 'title' field is required; 'title_type' is only necessary if the text is not the primary title.",
"properties": {
"language": {
"description": "The language in which the description is written, using the appropriate IETF BCP-47 notation.",
"description": "The language in which the title is written, using the appropriate IETF BCP-47 notation.",
"type": "string"
},
"title": {
Expand Down Expand Up @@ -545,13 +500,36 @@
"type": "string"
}
},
"$id": "https://github.com/kbase/credit_engine/schema/kbase/linkml",
"$schema": "https://json-schema.org/draft/2019-09/schema",
"additionalProperties": true,
"description": "Container for an instance of credit metadata; includes the credit metadata itself and metadata for the credit metadata, including the schema version used, who submitted it, and the date of submission. When the credit metadata for a resource is added or updated, a new CreditMetadataEntry is created to store the information.",
"metamodel_version": "1.7.0",
"properties": {
"credit_metadata_entry": {
"$ref": "#/$defs/CreditMetadataEntry",
"description": "A credit metadata entry for a resource."
"credit_metadata": {
"$ref": "#/$defs/CreditMetadata",
"description": "The credit metadata itself."
},
"credit_metadata_schema_version": {
"description": "The version of the credit metadata schema used.",
"type": "string"
},
"saved_by": {
"description": "KBase workspace ID of the user who added this entry.",
"type": "string"
},
"timestamp": {
"description": "Unix timestamp for the addition of this set of credit metadata.",
"type": "integer"
}
},
"required": [
"credit_metadata_entry"
]
"credit_metadata",
"credit_metadata_schema_version",
"saved_by",
"timestamp"
],
"title": "credit_metadata",
"type": "object",
"version": "0.0.1-commonmeta"
}
4 changes: 2 additions & 2 deletions schema/kbase/linkml/credit_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ classes:
one of the 'name' fields: either 'given_name' and 'family_name' (for a person), or 'name' (for an organization or a person).
The 'contributor_role' field takes values from the DataCite and CRediT contributor
roles vocabularies. For more information on these resources and choosing the
roles vocabularies. For more information on these resources and choosing
appropriate roles, please see the following links:
DataCite contributor roles: https://support.datacite.org/docs/datacite-metadata-schema-v44-recommended-and-optional-properties#7a-contributortype
Expand Down Expand Up @@ -1126,7 +1126,7 @@ enums:
Crossref:Replaces:
meaning: Crossref:Replaces
title: replaces
Unknown:
kbcms:Unknown:
# meaning: Relationship type is unknown
title: unknown
reachable_from:
Expand Down
1 change: 1 addition & 0 deletions tests/clients/test_args.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the ClientArgs classes."""

import re
from pathlib import Path
from typing import Any
Expand Down
1 change: 1 addition & 0 deletions tests/clients/test_base_errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Input error tests for retrieve_dois and retrieve_dois_from_unknown."""

import re

import pytest
Expand Down

0 comments on commit 6bf504b

Please sign in to comment.