Skip to content

Commit eabf9ee

Browse files
Require at least one category for demos (#1379)
Currently demos are technically allowed to define an empty `categories` array in their metadata. In practice every demo defines at least one category, except for the `adjoint_diff_benchmarking` demo. This was a hack to avoid surfacing it in search because it is supplementary material. The new V2 pipeline requires demos to have a category, and we have better ways to omit this demo from search, so this PR adds a category (same as the parent demo) to this demo and updates the metadata schema (the relevant change [is here](https://github.com/PennyLaneAI/qml/pull/1379/files#diff-e8a88baa22c87205641827678200ebd8b54e8f640baad11e2b828783aef0f2d4R56).) and Action to require a category for demos. It also fixes issues (trailing .html) with the links in these demos.
1 parent 249e800 commit eabf9ee

File tree

8 files changed

+141
-9
lines changed

8 files changed

+141
-9
lines changed

.github/workflows/validate-demo-metadata.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101
METADATA_FILE_LIST: ${{ needs.generate-metadata-file-list.outputs.metadata_files }}
102102
run: |
103103
cd metadata_schemas
104-
${{ steps.poetry.outputs.bin }} run check-jsonschema -v --traceback-mode full --schemafile demo.metadata.schema.0.1.5.json $METADATA_FILE_LIST
104+
${{ steps.poetry.outputs.bin }} run check-jsonschema -v --traceback-mode full --schemafile demo.metadata.schema.0.1.6.json $METADATA_FILE_LIST
105105
106106
validate-metadata-preview-images:
107107
runs-on: ubuntu-latest

demonstrations/adjoint_diff_benchmarking.metadata.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
],
88
"dateOfPublication": "2021-11-23T00:00:00+00:00",
99
"dateOfLastModification": "2024-10-07T00:00:00+00:00",
10-
"categories": [],
10+
"categories": [
11+
"Getting Started"
12+
],
1113
"tags": [],
1214
"previewImages": [
1315
{

demonstrations/adjoint_diff_benchmarking.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
##############################################################################
1818
# This page is supplementary material to the
19-
# `Adjoint Differentiation <https://pennylane.ai/qml/demos/tutorial_adjoint_diff.html>`__
19+
# `Adjoint Differentiation <https://pennylane.ai/qml/demos/tutorial_adjoint_diff>`__
2020
# demonstration. The below script produces the benchmarking images used.
2121

2222
import timeit
@@ -144,4 +144,4 @@ def circuit(params):
144144
#
145145
# About the author
146146
# ----------------
147-
#
147+
#

demonstrations/tutorial_adjoint_diff.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ def circuit_adjoint(a):
423423
# With adjoint differentiation on ``"lightning.qubit"``, you can get the best of both worlds: fast and
424424
# memory efficient.
425425
#
426-
# But how fast? The provided script `here <https://pennylane.ai/qml/demos/adjoint_diff_benchmarking.html>`__
426+
# But how fast? The provided script `here <https://pennylane.ai/qml/demos/adjoint_diff_benchmarking>`__
427427
# generated the following images on a mid-range laptop.
428428
# The backpropagation times were produced with the Python simulator ``"default.qubit"``, while parameter-shift
429429
# and adjoint differentiation times were calculated with ``"lightning.qubit"``.

demonstrations_v2/adjoint_diff_benchmarking/demo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
##############################################################################
1818
# This page is supplementary material to the
19-
# `Adjoint Differentiation <https://pennylane.ai/qml/demos/tutorial_adjoint_diff.html>`__
19+
# `Adjoint Differentiation <https://pennylane.ai/qml/demos/tutorial_adjoint_diff>`__
2020
# demonstration. The below script produces the benchmarking images used.
2121

2222
import timeit
@@ -144,4 +144,4 @@ def circuit(params):
144144
#
145145
# About the author
146146
# ----------------
147-
#
147+
#

demonstrations_v2/adjoint_diff_benchmarking/metadata.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
],
88
"dateOfPublication": "2021-11-23T00:00:00+00:00",
99
"dateOfLastModification": "2024-10-07T00:00:00+00:00",
10-
"categories": [],
10+
"categories": [
11+
"Getting Started"
12+
],
1113
"tags": [],
1214
"previewImages": [
1315
{

demonstrations_v2/tutorial_adjoint_diff/demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ def circuit_adjoint(a):
423423
# With adjoint differentiation on ``"lightning.qubit"``, you can get the best of both worlds: fast and
424424
# memory efficient.
425425
#
426-
# But how fast? The provided script `here <https://pennylane.ai/qml/demos/adjoint_diff_benchmarking.html>`__
426+
# But how fast? The provided script `here <https://pennylane.ai/qml/demos/adjoint_diff_benchmarking>`__
427427
# generated the following images on a mid-range laptop.
428428
# The backpropagation times were produced with the Python simulator ``"default.qubit"``, while parameter-shift
429429
# and adjoint differentiation times were calculated with ``"lightning.qubit"``.
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "demo.metadata.schema.0.1.6.json",
4+
"title": "Demo Metadata",
5+
"description": "A QML demo's metadata",
6+
"type": "object",
7+
"properties": {
8+
"title": {
9+
"description": "The title of the demo.",
10+
"type": "string",
11+
"minLength": 2
12+
},
13+
"slug": {
14+
"description": "The slug of the demo. This should match the base name of the metadata file.",
15+
"type": "string",
16+
"minLength": 1
17+
},
18+
"authors": {
19+
"description": "The author(s) of the demo. This array must contain at least one item.",
20+
"type": "array",
21+
"items": {
22+
"$ref": "file:./objects/author.schema.0.2.0.json"
23+
},
24+
"minItems": 1
25+
},
26+
"dateOfPublication": {
27+
"description": "The date on which the demo was first published, in the form YYYY-MM-DDTHH:MM:SS+00:00.",
28+
"type": "string",
29+
"format": "date-time",
30+
"minLength": 25,
31+
"maxLength": 25
32+
},
33+
"dateOfLastModification": {
34+
"description": "The date on which the demo was last modified, in the form YYYY-MM-DDTHH:MM:SS+00:00.",
35+
"type": "string",
36+
"format": "date-time",
37+
"minLength": 25,
38+
"maxLength": 25
39+
},
40+
"categories": {
41+
"description": "An array of the categories that this demo is in.",
42+
"type": "array",
43+
"items": {
44+
"enum": [
45+
"Algorithms",
46+
"Getting Started",
47+
"Optimization",
48+
"Quantum Machine Learning",
49+
"Quantum Chemistry",
50+
"Devices and Performance",
51+
"Quantum Computing",
52+
"Quantum Hardware",
53+
"How-to"
54+
]
55+
},
56+
"minItems": 1
57+
},
58+
"tags": {
59+
"description": "An array of the tags that the demo has. An empty array is allowed.",
60+
"type": "array",
61+
"items": {
62+
"type": "string"
63+
}
64+
},
65+
"previewImages": {
66+
"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).",
67+
"type": "array",
68+
"items": {
69+
"$ref": "file:./objects/preview.image.schema.0.1.0.json"
70+
},
71+
"minItems": 1
72+
},
73+
"seoDescription": {
74+
"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.",
75+
"type": "string",
76+
"minLength": 2
77+
},
78+
"doi": {
79+
"description": "The DOI for the demo.",
80+
"type": "string",
81+
"pattern": "^$|^10[.]"
82+
},
83+
"references": {
84+
"description": "An array of the references used for the demo.",
85+
"type": "array",
86+
"items": {
87+
"$ref": "file:./objects/reference.schema.0.1.0.json"
88+
}
89+
},
90+
"basedOnPapers": {
91+
"description": "An array of the DOIs for the papers the demo is based on. An empty array is allowed.",
92+
"type": "array",
93+
"items": {
94+
"type": "string"
95+
}
96+
},
97+
"referencedByPapers": {
98+
"description": "An array of the DOIs of any papers that reference the demo. An empty array is allowed.",
99+
"type": "array",
100+
"items": {
101+
"type": "string"
102+
}
103+
},
104+
"relatedContent": {
105+
"description": "An array of objects describing the content related to the demo. An empty array is allowed.",
106+
"type": "array",
107+
"items": {
108+
"$ref": "file:./objects/related.content.schema.0.1.0.json"
109+
}
110+
},
111+
"hardware": {
112+
"description": "An array of objects representing third-party vendors who can run the demo on their hardware. An empty array is allowed.",
113+
"type": "array",
114+
"items": {
115+
"$ref": "file:./objects/hardware.schema.0.1.0.json"
116+
}
117+
},
118+
"discussionForumUrl": {
119+
"description": "Link to dedicated discussion forum thread on https://discuss.pennylane.ai/ for this demo",
120+
"type": "string",
121+
"format": "uri",
122+
"pattern": "(^https?:\/\/(www.)?discuss.pennylane.ai(?:\/.*)?$)"
123+
}
124+
},
125+
"required": [
126+
"title", "authors", "dateOfPublication", "dateOfLastModification", "categories", "tags", "previewImages", "seoDescription", "doi", "references", "basedOnPapers", "referencedByPapers", "relatedContent"
127+
]
128+
}

0 commit comments

Comments
 (0)