From 6ebb9faf6f0951f299f5349687ecf855dd283e8b Mon Sep 17 00:00:00 2001 From: Mikhail Andrenkov Date: Fri, 3 May 2024 10:40:02 -0400 Subject: [PATCH] Support names and usernames in author metadata schema (#1089) **Title:** Adds support for specifying authors in demo metadata via full name or PennyLane profile username. **Summary:** The following metadata file is now accepted by the JSON validator: ```js { "authors": [ { "id": "jack_ceroni" }, { "username": "mikhail" }, { "name": "Mikhail Andrenkov" } ] // other fields ... } ``` Conversely, the metadata file below is _not_ accepted: ```js { "authors": [ {}, // no matches { "username": "mikhail", "name": "Mikhail Andrenkov" // extra field }, { "username": "mi" // too short }, { "username": "abcdefghijklmnopqrstu" // too long }, { "name": "M" // too short } ] // other fields ... } ``` **Relevant references:** N/A **Possible Drawbacks:** 1. If this PR is merged but the decision is later reverted, there will be some extraneous metadata versioning. **Related GitHub Issues:** N/A --- .github/workflows/validate-demo-metadata.yml | 12 +- .../demo.metadata.schema.0.1.1.json | 128 ++++++++++++++++++ .../objects/author.schema.0.2.0.json | 32 +++++ 3 files changed, 166 insertions(+), 6 deletions(-) create mode 100644 metadata_schemas/demo.metadata.schema.0.1.1.json create mode 100644 metadata_schemas/objects/author.schema.0.2.0.json diff --git a/.github/workflows/validate-demo-metadata.yml b/.github/workflows/validate-demo-metadata.yml index 20e3b38e07..19ef2fc99c 100644 --- a/.github/workflows/validate-demo-metadata.yml +++ b/.github/workflows/validate-demo-metadata.yml @@ -8,7 +8,7 @@ on: type: string metadata_files: description: | - List of metadata files to validate, separated by space. + List of metadata files to validate, separated by space. Not passing a value for this input is the equivalent of validating all the metadata files. required: false type: string @@ -47,7 +47,7 @@ jobs: run: | input_metadata_file_names="${{ inputs.metadata_files || steps.metadata_files.outputs.file_names }}" formatted_metadata_file_names=() - + for metadata_file_name in $input_metadata_file_names do if [[ "$metadata_file_name" =~ "../demonstrations" ]]; then @@ -58,7 +58,7 @@ jobs: formatted_metadata_file_names+=("../demonstrations/$metadata_file_name") fi done - + echo "formatted_file_names=${formatted_metadata_file_names[@]}" >> $GITHUB_OUTPUT outputs: @@ -101,7 +101,7 @@ jobs: METADATA_FILE_LIST: ${{ needs.generate-metadata-file-list.outputs.metadata_files }} run: | cd metadata_schemas - ${{ steps.poetry.outputs.bin }} run check-jsonschema -v --traceback-mode full --schemafile demo.metadata.schema.0.1.0.json $METADATA_FILE_LIST + ${{ steps.poetry.outputs.bin }} run check-jsonschema -v --traceback-mode full --schemafile demo.metadata.schema.0.1.1.json $METADATA_FILE_LIST validate-metadata-preview-images: runs-on: ubuntu-latest @@ -131,7 +131,7 @@ jobs: run: | metadata_file_names="${{ needs.generate-metadata-file-list.outputs.metadata_files }}" formatted_metadata_file_names=() - + for metadata_file_name in $metadata_file_names do if [[ "$metadata_file_name" =~ "../" ]]; then @@ -140,7 +140,7 @@ jobs: formatted_metadata_file_names+=($metadata_file_name) fi done - + echo "file_names=${formatted_metadata_file_names[@]}" >> $GITHUB_OUTPUT - name: Validate Preview Images diff --git a/metadata_schemas/demo.metadata.schema.0.1.1.json b/metadata_schemas/demo.metadata.schema.0.1.1.json new file mode 100644 index 0000000000..14b6526918 --- /dev/null +++ b/metadata_schemas/demo.metadata.schema.0.1.1.json @@ -0,0 +1,128 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "demo.metadata.schema.0.1.1.json", + "title": "Demo Metadata", + "description": "A QML demo's metadata", + "type": "object", + "properties": { + "title": { + "description": "The title of the demo.", + "type": "string", + "minLength": 2 + }, + "authors": { + "description": "The author(s) of the demo. This array must contain at least one item.", + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "file:./objects/author.schema.0.1.0.json" + }, + { + "$ref": "file:./objects/author.schema.0.2.0.json" + } + ] + }, + "minItems": 1 + }, + "dateOfPublication": { + "description": "The date on which the demo was first published, in the form YYYY-MM-DDTHH:MM:SS+00:00.", + "type": "string", + "format": "date-time", + "minLength": 25, + "maxLength": 25 + }, + "dateOfLastModification": { + "description": "The date on which the demo was last modified, in the form YYYY-MM-DDTHH:MM:SS+00:00.", + "type": "string", + "format": "date-time", + "minLength": 25, + "maxLength": 25 + }, + "categories": { + "description": "An array of the categories that this demo is in.", + "type": "array", + "items": { + "enum": [ + "Algorithms", + "Getting Started", + "Optimization", + "Quantum Machine Learning", + "Quantum Chemistry", + "Devices and Performance", + "Quantum Computing", + "Quantum Hardware" + ] + }, + "minItems": 0 + }, + "tags": { + "description": "An array of the tags that the demo has. An empty array is allowed.", + "type": "array", + "items": { + "type": "string" + } + }, + "previewImages": { + "description": "An array of the different images that can be used as previews for this demo - e.g., thumbnails, social media cards (perhaps of different aspect ratios).", + "type": "array", + "items": { + "$ref": "file:./objects/preview.image.schema.0.1.0.json" + }, + "minItems": 1 + }, + "seoDescription": { + "description": "A description of the demo suitable for SEO purposes. Ideally this should be less than 150 characters, but this is not a strict limit. It should be a full, grammatically-correct sentence ending in a full stop.", + "type": "string", + "minLength": 2 + }, + "doi": { + "description": "The DOI for the demo.", + "type": "string", + "pattern": "^$|^10[.]" + }, + "canonicalURL": { + "description": "The canonical URL for the demo. Sometimes there might be more than one URL that points to a given page on a website. The canonical URL defines which of these should be thought of as the primary or main one.", + "type": "string", + "pattern": "(^https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6})?\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)" + }, + "references": { + "description": "An array of the references used for the demo.", + "type": "array", + "items": { + "$ref": "file:./objects/reference.schema.0.1.0.json" + } + }, + "basedOnPapers": { + "description": "An array of the DOIs for the papers the demo is based on. An empty array is allowed.", + "type": "array", + "items": { + "type": "string" + } + }, + "referencedByPapers": { + "description": "An array of the DOIs of any papers that reference the demo. An empty array is allowed.", + "type": "array", + "items": { + "type": "string" + } + }, + "relatedContent": { + "description": "An array of objects describing the content related to the demo. An empty array is allowed.", + "type": "array", + "items": { + "$ref": "file:./objects/related.content.schema.0.1.0.json" + } + }, + "hardware": { + "description": "An array of objects representing third-party vendors who can run the demo on their hardware. An empty array is allowed.", + "type": "array", + "items": { + "$ref": "file:./objects/hardware.schema.0.1.0.json" + } + } + }, + "required": [ + "title", "authors", "dateOfPublication", "dateOfLastModification", "categories", "tags", "previewImages", "seoDescription", "doi", "canonicalURL", "references", "basedOnPapers", "referencedByPapers", "relatedContent" + ] + } diff --git a/metadata_schemas/objects/author.schema.0.2.0.json b/metadata_schemas/objects/author.schema.0.2.0.json new file mode 100644 index 0000000000..169dae3c6f --- /dev/null +++ b/metadata_schemas/objects/author.schema.0.2.0.json @@ -0,0 +1,32 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "author.schema.0.2.0.json", + "title": "Author Object", + "description": "An author of a demo.", + "type": "object", + "oneOf": [ + { + "additionalProperties": false, + "properties": { + "username": { + "description": "The username of the author's PennyLane profile.", + "type": "string", + "minLength": 3, + "maxLength": 20 + } + }, + "required": ["username"] + }, + { + "additionalProperties": false, + "properties": { + "name": { + "description": "The full name of the author.", + "type": "string", + "minLength": 2 + } + }, + "required": ["name"] + } + ] +}