You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Each file should begin with a short copyright information, mentioning the people
340
-
who are mainly involved in coding this particular python file. In practice,
338
+
who are mainly involved in coding this particular python file.
341
339
342
340
343
341
Testing
@@ -356,106 +354,111 @@ Testing
356
354
357
355
- A code coverage diagnostic can be obtained via
358
356
```
359
-
./test.sh html
357
+
./test.sh coverage
360
358
```
361
-
it produces beautiful coverage scores in `lmfdb/cover/index.html`
359
+
which produces coverage scores saved in `lmfdb/htmlcov`.
362
360
363
-
Pro Tip: Debugging
364
-
-------------------
361
+
Code Snippets
362
+
-------------
365
363
366
-
Just add
364
+
Many of the LMFDB pages include code snippets which describe how to generate the objects on the page using computer algebra systems such as SageMath, Magma, pari/GP or Oscar. To add code snippets to a new page, the relevant code is placed in a file named `code.yaml`. The file should always define the languages used using the `prompt` tag, for example:
367
365
```
368
-
import pdb; pdb.set_trace()
366
+
prompt:
367
+
sage: 'sage'
368
+
pari: 'gp'
369
+
magma: 'magma'
370
+
oscar: 'oscar'
369
371
```
370
-
somewhere (e.g. protected inside a sensible if) this magic
371
-
line and you will end up inside the interactive python
372
-
debugger. there, you can check for the local variables with dir()
373
-
you can execute python code (e.g. to introspect objects)
374
-
and use "pp <varname>" to pretty print variables and
375
-
to continue executing code use the "n" command.
376
-
When you get lost, the command "bt" shows you exactly where you
377
-
are and "up" helps you to get on step up on the stack.
378
-
Of course, "help `<command>`" will tell you more...
379
-
380
-
Git Tips
381
-
=========
382
-
383
-
global .gitignore
384
-
-----------------
385
372
386
-
Please configure Git to have a global .gitignore for all your projects.
387
-
It should contain all the files which are not project specific, but happen
388
-
on your machine. E.g. temporary files ending in `...~` or `.DS_store`.
389
-
390
-
[copy paste ready instructions on github](https://help.github.com/articles/ignoring-files#global-gitignore)
oscar: Qx, x = polynomial_ring(QQ); K, a = number_field(%s)
415
381
```
416
382
417
-
List-table should always be like
418
-
--------------------------------
383
+
### Snippet testing
384
+
385
+
Sometimes computer algebra systems make breaking changes which render the code snippets invalid. To catch this, there's a testing system for snippets implemented in `lmfdb/tests/generate_snippet_tests.py`. This runs the code line by line in the various CAS-es, excluding magma. It does not test correctness of the results, only consistency, by comparing with previous results stored in the `lmfdb/tests/snippet_tests` directory. Normally (and at the time of writing), this is run automatically by Github Actions, which generates the relevant log files. However, it is possible to run it manually using the CLI tool
which takes a number of arguments (of which one of the positional arguments `generate` and `test` are required).
391
+
392
+
To specify which code snippets should be tested in the Github Action, add a tag of the form
393
+
394
+
```yaml
395
+
# e.g. in /lmfdb/number_fields/code.yaml
396
+
...
397
+
snippet_test:
398
+
testQ:
399
+
label: 1.1.1.1
400
+
langs:
401
+
- sage
402
+
- magma
403
+
- oscar
404
+
- gp
405
+
url: NumberField/1.1.1.1/download/{lang}
431
406
```
432
407
433
-
... we might also switch to CSS3's nth-element selector and forget about this.
408
+
The tag `langs` here is optional, and if omitted, all (available) languages in the `prompt` tag will be used.
434
409
410
+
### Snippet test and generate Github Actions
435
411
436
-
Properties
437
-
----------
412
+
Part of the code snippet testing system is a pair of code actions to generate evaluation log files automatically. The first one runs when a change to a `code*.yaml` file is pulled to the main branch, and if so, regenerates the evaluation files. If the output is different from the previous evaluation files, it will make a pull request, allowing you to manually check that the output is as expected. The logic is in `.github/workflows/snippet_generate.yml`.
438
413
439
-
The table on the right renders Strings formatted in the following datastructure:
414
+
Additionally, there's a second CI action which runs twice a month and checks that the evaluations are consistent - it can also be run on demand. This ensures that if and when SageMath (or another CAS) deprecates a function, we'll know without having to wait for someone to update the yaml files, rerun the code or submit a bug report. If this action generates a different output than what's stored in the evaluation files, it will error, and upload the diff as an artifact. This is in `.github/workflows/snippet_test.yml`. Furthermore, it will create/update an issue (see https://github.com/LMFDB/lmfdb/issues/6810 for example) which keeps track of all the evaluation errors.
somewhere in a python file (e.g. protected inside a sensible if) will pause the execution of the program;
425
+
this puts you inside an interactive python debugger, where you can:
450
426
451
-
you can mix list or non-list.
427
+
- check for the local variables with `dir()`,
428
+
- you can execute arbitrary python code (e.g. to inspect objects),
429
+
- use `pp <var name>` to pretty print variables,
430
+
- continue executing code using the `n` command.
452
431
432
+
If you get lost, the command `bt` shows you exactly where you
433
+
are, and `up` helps you to get on step up on the stack.
434
+
Of course, `help <command>` will tell you more.
453
435
454
-
LaTeX Macros
455
-
------------
456
-
457
-
Latex macros are documented in a knowl that will appear when you start editing one.
436
+
Git Tips
437
+
=========
458
438
439
+
Contributing to the LMFDB requires some familiarity with git, a popular version control system which LMFDB uses. The LMFDB code base is hosted on Github, which is a common hosting service owned by Microsoft.
440
+
- [Official git tutorial](https://git-scm.com/docs/gittutorial) and [Github's git guide](https://github.com/git-guides)
441
+
- Use a global .gitignore file to exclude temporary files like `.DS_store` or `main.py~`; [copy-paste ready instructions on github](https://help.github.com/articles/ignoring-files#global-gitignore).
442
+
- Configure your global .gitconfig for shortcuts or global configuration options; for example:
0 commit comments