pll-python 0.9.0 → 0.9.2

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.
Files changed (4) hide show
  1. package/README.md +45 -1
  2. package/cli.cjs +310 -55
  3. package/package.json +1 -1
  4. package/worker.cjs +17 -12
package/README.md CHANGED
@@ -197,13 +197,57 @@ more — `dis` still tells the whole story to anyone who looks. That is a
197
197
  deliberate trade: the autograder holds the grade, so this check is there to
198
198
  be fast and honest rather than secret.
199
199
 
200
+ ## Bundles
201
+
202
+ A bundle is a module of yours that a student's program uses without seeing
203
+ its code - in a lab on working out what code does, say. The program names it
204
+ with a line of its own, and then uses it by that name, with no `import`:
205
+
206
+ ```python
207
+ #level beginner
208
+ #bundle mystery https://cs2000.example/lab5.json
209
+
210
+ mystery.shuffle([1, 2, 3])
211
+ ```
212
+
213
+ Write the module as an ordinary file, at the level you like, with tests, and
214
+ build it:
215
+
216
+ ```bash
217
+ pll bundle build mystery.py -o lab5.json
218
+ ```
219
+
220
+ ```
221
+ built for Python 3.13.2, at #level intermediate: defines shuffle, Deck
222
+ wrote lab5.json (1240 bytes)
223
+ ```
224
+
225
+ Its top-level `test_` functions, and an `import pytest`, are left out of the
226
+ bundle. Everything else goes in, docstrings too, so leave out one that would
227
+ give away what a function does. Only bytecode is written, compiled by the
228
+ Pyodide this package pins, so it matches the interpreter that will run it;
229
+ as with Examplar bundles, that hides the code from `inspect.getsource`, and
230
+ `dis` would still show it. The module's code starts with its level's names,
231
+ `dataclass` and `Callable` among them, wherever it is used.
232
+
233
+ Publish the bundle as you would an Examplar bundle: at an https address,
234
+ with the same CORS headers for vscode.dev, and it is cached the same way for
235
+ a run without a network. A bundle that can't be had - unreachable with no
236
+ copy kept, built for another version of Python, or one whose top level
237
+ raises - stops the student's run before it starts, at its `#bundle` line.
238
+
239
+ Nothing checks a bundle's code: it runs as the student's own does, files and
240
+ all, so publish only code you would give them to run. An error raised inside
241
+ one of its functions is shown at the student's line that called it, as
242
+ "Inside `shuffle`: ...", with the one fix they can make: what they give it.
243
+
200
244
  ## Exit codes
201
245
 
202
246
  | Code | Meaning |
203
247
  | --- | --- |
204
248
  | 0 | Ran, and any tests passed |
205
249
  | 1 | The program raised, or Ctrl+C stopped it (even if it caught the `KeyboardInterrupt`; its tests are then not run) |
206
- | 2 | Level checks found problems, so it was not run |
250
+ | 2 | Level checks found problems, or a bundle could not be loaded, so it was not run |
207
251
  | 3 | A test failed, or could not be run (it takes parameters) |
208
252
  | 64 | Bad usage, or Python could not start (it is given two minutes) |
209
253
  | 130 | A second Ctrl+C gave up waiting for the program to stop |