qfest-grader 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qfest_grader-0.1.2/LICENSE +202 -0
- qfest_grader-0.1.2/NOTICE +15 -0
- qfest_grader-0.1.2/PKG-INFO +73 -0
- qfest_grader-0.1.2/README.md +56 -0
- qfest_grader-0.1.2/pyproject.toml +29 -0
- qfest_grader-0.1.2/qfest_grader/__init__.py +22 -0
- qfest_grader-0.1.2/qfest_grader/account.py +127 -0
- qfest_grader-0.1.2/qfest_grader/answers.py +223 -0
- qfest_grader-0.1.2/qfest_grader/api.py +79 -0
- qfest_grader-0.1.2/qfest_grader/challenges/__init__.py +0 -0
- qfest_grader-0.1.2/qfest_grader/challenges/warsaw_2026/__init__.py +49 -0
- qfest_grader-0.1.2/qfest_grader/challenges/warsaw_2026/lab0.py +56 -0
- qfest_grader-0.1.2/qfest_grader/challenges/warsaw_2026/lab1.py +62 -0
- qfest_grader-0.1.2/qfest_grader/env.py +28 -0
- qfest_grader-0.1.2/qfest_grader/grade.py +169 -0
- qfest_grader-0.1.2/qfest_grader.egg-info/PKG-INFO +73 -0
- qfest_grader-0.1.2/qfest_grader.egg-info/SOURCES.txt +23 -0
- qfest_grader-0.1.2/qfest_grader.egg-info/dependency_links.txt +1 -0
- qfest_grader-0.1.2/qfest_grader.egg-info/requires.txt +6 -0
- qfest_grader-0.1.2/qfest_grader.egg-info/top_level.txt +1 -0
- qfest_grader-0.1.2/setup.cfg +4 -0
- qfest_grader-0.1.2/tests/test_account.py +88 -0
- qfest_grader-0.1.2/tests/test_answers.py +202 -0
- qfest_grader-0.1.2/tests/test_api.py +90 -0
- qfest_grader-0.1.2/tests/test_grade.py +152 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
qfest-grader
|
|
2
|
+
Copyright 2026 Qiskit Fall Fest 2026 Warsaw organisers
|
|
3
|
+
|
|
4
|
+
This product is derived from the Quantum Challenge Grader (qc-grader 2026.9.29),
|
|
5
|
+
https://github.com/qiskit-community/Quantum-Challenge-Grader
|
|
6
|
+
Copyright 2019 IBM and its contributors, licensed under the Apache License, Version 2.0.
|
|
7
|
+
|
|
8
|
+
Changes from the original:
|
|
9
|
+
- Answers are reduced to final values (counts, numbers, sparse amplitudes,
|
|
10
|
+
circuit depth and gate positions, stabilizer expectation values) on the client.
|
|
11
|
+
- Participants are identified by a saved email instead of an IBM Quantum API key.
|
|
12
|
+
- Submissions go to the Warsaw grading server instead of IBM's grading API.
|
|
13
|
+
- Only the Warsaw Lab 0 and Lab 1 grading functions are included.
|
|
14
|
+
|
|
15
|
+
Files derived from the original keep IBM's copyright notice and state the changes.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: qfest-grader
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Grader client for the Qiskit Fall Fest 2026 Warsaw lab notebooks
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Source, https://github.com/wolfomania/qfest-grader
|
|
7
|
+
Requires-Python: >=3.9
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
License-File: NOTICE
|
|
11
|
+
Requires-Dist: numpy>=1.21
|
|
12
|
+
Requires-Dist: qiskit>=1.0
|
|
13
|
+
Requires-Dist: requests>=2.25
|
|
14
|
+
Provides-Extra: test
|
|
15
|
+
Requires-Dist: pytest>=7; extra == "test"
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# qfest-grader
|
|
19
|
+
|
|
20
|
+
Grader client for the Qiskit Fall Fest 2026 Warsaw lab notebooks. It checks your lab answers and records which exercises you completed. The organisers issue participation certificates from these records.
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
Run in a notebook cell (Google Colab, Jupyter or VS Code), then restart the kernel:
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
%pip install -q qfest-grader
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The install needs Python 3.9 or later. Update an existing install with `%pip install -U qfest-grader`.
|
|
31
|
+
|
|
32
|
+
## Use
|
|
33
|
+
|
|
34
|
+
Save the email you registered with. Run this once per environment; a new Colab session needs it again:
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from qfest_grader import save_account
|
|
38
|
+
save_account("<your email>")
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Grade an exercise and check your progress:
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from qfest_grader.challenges.warsaw_2026 import check_progress, grade_lab0_ex2
|
|
45
|
+
|
|
46
|
+
grade_lab0_ex2(counts)
|
|
47
|
+
check_progress("lab0")
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Without a saved account, the grader reads the `QFEST_EMAIL` environment variable.
|
|
51
|
+
|
|
52
|
+
## What is sent
|
|
53
|
+
|
|
54
|
+
Each grade call sends your email and a small summary of your answer to the grading server:
|
|
55
|
+
|
|
56
|
+
- counts, numbers and dictionaries as they are;
|
|
57
|
+
- statevectors as their non-zero amplitudes;
|
|
58
|
+
- circuits as their qubit count, depth, the qubits of each multi-qubit gate and their final state.
|
|
59
|
+
|
|
60
|
+
Circuit source code and notebook contents are never sent. The email is stored in `~/.qfest/grader.json`, readable only by you.
|
|
61
|
+
|
|
62
|
+
## Develop
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pip install -e ".[test]"
|
|
66
|
+
pytest
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Releases go to [PyPI](https://pypi.org/project/qfest-grader/) from GitHub Actions: set the same version in `pyproject.toml` and `qfest_grader/__init__.py`, push, then push the tag `v<version>`.
|
|
70
|
+
|
|
71
|
+
## Licence
|
|
72
|
+
|
|
73
|
+
Apache License 2.0. Derived from IBM's [Quantum Challenge Grader](https://github.com/qiskit-community/Quantum-Challenge-Grader); see `NOTICE`.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# qfest-grader
|
|
2
|
+
|
|
3
|
+
Grader client for the Qiskit Fall Fest 2026 Warsaw lab notebooks. It checks your lab answers and records which exercises you completed. The organisers issue participation certificates from these records.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
Run in a notebook cell (Google Colab, Jupyter or VS Code), then restart the kernel:
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
%pip install -q qfest-grader
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The install needs Python 3.9 or later. Update an existing install with `%pip install -U qfest-grader`.
|
|
14
|
+
|
|
15
|
+
## Use
|
|
16
|
+
|
|
17
|
+
Save the email you registered with. Run this once per environment; a new Colab session needs it again:
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from qfest_grader import save_account
|
|
21
|
+
save_account("<your email>")
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Grade an exercise and check your progress:
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from qfest_grader.challenges.warsaw_2026 import check_progress, grade_lab0_ex2
|
|
28
|
+
|
|
29
|
+
grade_lab0_ex2(counts)
|
|
30
|
+
check_progress("lab0")
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Without a saved account, the grader reads the `QFEST_EMAIL` environment variable.
|
|
34
|
+
|
|
35
|
+
## What is sent
|
|
36
|
+
|
|
37
|
+
Each grade call sends your email and a small summary of your answer to the grading server:
|
|
38
|
+
|
|
39
|
+
- counts, numbers and dictionaries as they are;
|
|
40
|
+
- statevectors as their non-zero amplitudes;
|
|
41
|
+
- circuits as their qubit count, depth, the qubits of each multi-qubit gate and their final state.
|
|
42
|
+
|
|
43
|
+
Circuit source code and notebook contents are never sent. The email is stored in `~/.qfest/grader.json`, readable only by you.
|
|
44
|
+
|
|
45
|
+
## Develop
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install -e ".[test]"
|
|
49
|
+
pytest
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Releases go to [PyPI](https://pypi.org/project/qfest-grader/) from GitHub Actions: set the same version in `pyproject.toml` and `qfest_grader/__init__.py`, push, then push the tag `v<version>`.
|
|
53
|
+
|
|
54
|
+
## Licence
|
|
55
|
+
|
|
56
|
+
Apache License 2.0. Derived from IBM's [Quantum Challenge Grader](https://github.com/qiskit-community/Quantum-Challenge-Grader); see `NOTICE`.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "qfest-grader"
|
|
7
|
+
version = "0.1.2"
|
|
8
|
+
description = "Grader client for the Qiskit Fall Fest 2026 Warsaw lab notebooks"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
license-files = ["LICENSE", "NOTICE"]
|
|
12
|
+
requires-python = ">=3.9"
|
|
13
|
+
dependencies = [
|
|
14
|
+
"numpy>=1.21",
|
|
15
|
+
"qiskit>=1.0",
|
|
16
|
+
"requests>=2.25",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.optional-dependencies]
|
|
20
|
+
test = ["pytest>=7"]
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
Source = "https://github.com/wolfomania/qfest-grader"
|
|
24
|
+
|
|
25
|
+
[tool.setuptools.packages.find]
|
|
26
|
+
include = ["qfest_grader*"]
|
|
27
|
+
|
|
28
|
+
[tool.pytest.ini_options]
|
|
29
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Copyright 2026 Qiskit Fall Fest 2026 Warsaw organisers.
|
|
2
|
+
#
|
|
3
|
+
# This code is licensed under the Apache License, Version 2.0. You may
|
|
4
|
+
# obtain a copy of this license in the LICENSE file in the root directory
|
|
5
|
+
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
|
|
7
|
+
"""Grader client for the Qiskit Fall Fest 2026 Warsaw lab notebooks.
|
|
8
|
+
|
|
9
|
+
Set up once per environment::
|
|
10
|
+
|
|
11
|
+
from qfest_grader import save_account
|
|
12
|
+
save_account("<your email>")
|
|
13
|
+
|
|
14
|
+
Then call the ``grade_labN_exM`` functions from ``qfest_grader.challenges.warsaw_2026``.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
__version__ = "0.1.2"
|
|
18
|
+
|
|
19
|
+
from qfest_grader.account import AccountError, save_account, saved_email # noqa: E402
|
|
20
|
+
from qfest_grader.challenges.warsaw_2026 import check_progress # noqa: E402
|
|
21
|
+
|
|
22
|
+
__all__ = ["AccountError", "__version__", "check_progress", "save_account", "saved_email"]
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Copyright 2026 Qiskit Fall Fest 2026 Warsaw organisers.
|
|
2
|
+
#
|
|
3
|
+
# This code is licensed under the Apache License, Version 2.0. You may
|
|
4
|
+
# obtain a copy of this license in the LICENSE file in the root directory
|
|
5
|
+
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
|
|
7
|
+
"""Participant identity: the email saved once per environment."""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
import os
|
|
13
|
+
import re
|
|
14
|
+
import tempfile
|
|
15
|
+
from datetime import datetime, timezone
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
from typing import Optional
|
|
18
|
+
|
|
19
|
+
CONFIG_DIR_ENV = "QFEST_CONFIG_DIR"
|
|
20
|
+
EMAIL_ENV = "QFEST_EMAIL"
|
|
21
|
+
CONFIG_FILE = "grader.json"
|
|
22
|
+
|
|
23
|
+
_EMAIL_RE = re.compile(r"^[^@\s]+@[^@\s]+\.[^@\s]+$")
|
|
24
|
+
_PLACEHOLDER_DOMAINS = ("example.com", "example.org", "example.net")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class AccountError(ValueError):
|
|
28
|
+
"""The grader email is missing or invalid."""
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def normalize_email(email: object) -> str:
|
|
32
|
+
"""Return the email trimmed and lower-cased, or raise AccountError."""
|
|
33
|
+
if not isinstance(email, str):
|
|
34
|
+
raise AccountError('Pass your email as text: save_account("<your email>").')
|
|
35
|
+
normalized = email.strip().lower()
|
|
36
|
+
if len(normalized) > 254 or not _EMAIL_RE.match(normalized):
|
|
37
|
+
raise AccountError(f"{email!r} does not look like an email address.")
|
|
38
|
+
if normalized.rsplit("@", 1)[1] in _PLACEHOLDER_DOMAINS:
|
|
39
|
+
raise AccountError("Replace the placeholder with the email you registered with.")
|
|
40
|
+
return normalized
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def config_path() -> Path:
|
|
44
|
+
base = os.environ.get(CONFIG_DIR_ENV)
|
|
45
|
+
directory = Path(base) if base else Path.home() / ".qfest"
|
|
46
|
+
return directory / CONFIG_FILE
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _write_private_json(path: Path, data: dict) -> None:
|
|
50
|
+
"""Write JSON readable only by the owner, replacing the file atomically."""
|
|
51
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
52
|
+
fd, tmp_name = tempfile.mkstemp(dir=path.parent, prefix=".grader-", suffix=".json")
|
|
53
|
+
try:
|
|
54
|
+
with os.fdopen(fd, "w", encoding="utf-8") as handle:
|
|
55
|
+
json.dump(data, handle)
|
|
56
|
+
os.chmod(tmp_name, 0o600)
|
|
57
|
+
os.replace(tmp_name, path)
|
|
58
|
+
except BaseException:
|
|
59
|
+
if os.path.exists(tmp_name):
|
|
60
|
+
os.remove(tmp_name)
|
|
61
|
+
raise
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def saved_email() -> Optional[str]:
|
|
65
|
+
"""The saved email, else the QFEST_EMAIL environment variable, else None."""
|
|
66
|
+
path = config_path()
|
|
67
|
+
if path.is_file():
|
|
68
|
+
try:
|
|
69
|
+
email = json.loads(path.read_text(encoding="utf-8")).get("email")
|
|
70
|
+
return normalize_email(email)
|
|
71
|
+
except (OSError, ValueError, AttributeError):
|
|
72
|
+
pass
|
|
73
|
+
env_email = os.environ.get(EMAIL_ENV)
|
|
74
|
+
if env_email:
|
|
75
|
+
try:
|
|
76
|
+
return normalize_email(env_email)
|
|
77
|
+
except AccountError:
|
|
78
|
+
return None
|
|
79
|
+
return None
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def require_email() -> str:
|
|
83
|
+
email = saved_email()
|
|
84
|
+
if email is None:
|
|
85
|
+
raise AccountError(
|
|
86
|
+
'No grader account found. Run save_account("<your email>") with the email '
|
|
87
|
+
"you registered with, then run this cell again."
|
|
88
|
+
)
|
|
89
|
+
return email
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def save_account(email: str, verify: bool = True) -> None:
|
|
93
|
+
"""Save the email that identifies your submissions. Run once per environment.
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
email: The email you registered for Qiskit Fall Fest 2026 Warsaw.
|
|
97
|
+
verify: Also register the email with the grading server (default True).
|
|
98
|
+
"""
|
|
99
|
+
normalized = normalize_email(email)
|
|
100
|
+
_write_private_json(
|
|
101
|
+
config_path(),
|
|
102
|
+
{"email": normalized, "saved_at": datetime.now(timezone.utc).isoformat(timespec="seconds")},
|
|
103
|
+
)
|
|
104
|
+
if not verify:
|
|
105
|
+
print(f"Grader account saved for {normalized}.")
|
|
106
|
+
return
|
|
107
|
+
|
|
108
|
+
from qfest_grader.api import GraderError, call_rpc
|
|
109
|
+
|
|
110
|
+
try:
|
|
111
|
+
response = call_rpc("qf_register", {"p_email": normalized, "p_client": _client_tag()})
|
|
112
|
+
except GraderError as err:
|
|
113
|
+
print(f"Grader account saved for {normalized}, but the server check failed: {err}")
|
|
114
|
+
return
|
|
115
|
+
if isinstance(response, dict) and response.get("ok"):
|
|
116
|
+
print(f"{response.get('msg', 'Grader account saved.')} ✅")
|
|
117
|
+
else:
|
|
118
|
+
message = response.get("msg") if isinstance(response, dict) else response
|
|
119
|
+
print(f"Grader account saved for {normalized}, but the server replied: {message}")
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def _client_tag() -> str:
|
|
123
|
+
import platform
|
|
124
|
+
|
|
125
|
+
from qfest_grader import __version__
|
|
126
|
+
|
|
127
|
+
return f"qfest-grader/{__version__} python/{platform.python_version()}"
|