access-config-utils 0.6__tar.gz → 0.7__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.
- {access_config_utils-0.6 → access_config_utils-0.7}/AGENTS.md +113 -37
- {access_config_utils-0.6/src/access_config_utils.egg-info → access_config_utils-0.7}/PKG-INFO +49 -12
- {access_config_utils-0.6 → access_config_utils-0.7}/README.md +48 -11
- {access_config_utils-0.6 → access_config_utils-0.7}/pyproject.toml +6 -2
- {access_config_utils-0.6 → access_config_utils-0.7}/skills/add-parallel-constraint/SKILL.md +2 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/skills/check/SKILL.md +4 -1
- access_config_utils-0.7/skills/use-access-config/SKILL.md +163 -0
- access_config_utils-0.7/src/access/config/__init__.py +95 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/config_dict.py +239 -19
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/config_insert.py +42 -27
- access_config_utils-0.7/src/access/config/config_resize.py +354 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/config_store.py +110 -8
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/grammar_compiled.py +3 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/grammar_values.py +45 -9
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/json_config.py +99 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/parallel_allocation_strategies.py +90 -78
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/parallel_component.py +122 -9
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/parallel_constraints.py +10 -8
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/parallel_layouts.py +22 -21
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/parser.py +66 -1
- access_config_utils-0.7/src/access/config/py.typed +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/rose_conf.py +114 -1
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/tree_edits.py +18 -2
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/yaml_config.py +99 -0
- {access_config_utils-0.6 → access_config_utils-0.7/src/access_config_utils.egg-info}/PKG-INFO +49 -12
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access_config_utils.egg-info/SOURCES.txt +3 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/conftest.py +287 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_config_dict.py +306 -4
- access_config_utils-0.7/tests/test_config_resize.py +571 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_config_store.py +228 -1
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_field_table.py +48 -1
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_fortran_nml.py +65 -1
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_grammar_values.py +71 -20
- access_config_utils-0.7/tests/test_init.py +74 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_json_config.py +76 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_mom6_input.py +10 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_nuopc_config.py +5 -6
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_parallel_allocation_strategies.py +47 -17
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_parallel_component.py +70 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_parallel_layouts.py +47 -16
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_parser.py +253 -10
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_rose_conf.py +201 -11
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_tree_edits.py +31 -2
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_yaml_config.py +65 -0
- access_config_utils-0.6/src/access/config/__init__.py +0 -37
- access_config_utils-0.6/src/access/config/config_resize.py +0 -197
- access_config_utils-0.6/tests/test_config_resize.py +0 -273
- {access_config_utils-0.6 → access_config_utils-0.7}/.github/workflows/cd.yml +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/.github/workflows/check_links.yml +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/.github/workflows/ci.yml +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/.github/workflows/pr_preview_message.yml +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/.gitignore +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/.pre-commit-config.yaml +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/.readthedocs.yaml +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/.zenodo.json +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/COPYRIGHT.txt +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/LICENSE +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/MANIFEST.in +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/conda/environment.yml +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/conda/meta.yaml +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/scripts/run_f90nml_tests.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/setup.cfg +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/setup.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/skills/add-parser/SKILL.md +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/skills/grammar-debug/SKILL.md +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/config.lark +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/entry_fragments.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/entry_render.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/entry_style.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/field_table.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/fortran_nml.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/grammar_contract.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/list_layout.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/mom6_input.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/nuopc_config.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/nuopc_runseq.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/parallel_domain.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/parallel_mpi_grid.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/tree_navigation.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access/config/tree_reader.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access_config_utils.egg-info/dependency_links.txt +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access_config_utils.egg-info/requires.txt +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/src/access_config_utils.egg-info/top_level.txt +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_config_insert.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_entry_fragments.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_entry_render.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_entry_style.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_grammar_compiled.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_grammar_contract.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_list_layout.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_nuopc_runseq.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_parallel_constraints.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_parallel_doctests.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_parallel_domain.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_parallel_mpi_grid.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_tree_navigation.py +0 -0
- {access_config_utils-0.6 → access_config_utils-0.7}/tests/test_tree_reader.py +0 -0
|
@@ -55,8 +55,8 @@ src/access/config/
|
|
|
55
55
|
is_comment_line, entry_insertion_index, line_index, key_token,
|
|
56
56
|
locate_entry/node_at
|
|
57
57
|
tree_edits.py update_node_value, write_values, parse_entry_nodes,
|
|
58
|
-
splice_entry_nodes, replace_entry_contents,
|
|
59
|
-
remove_entry_node, merge_adjacent_repetitions
|
|
58
|
+
splice_entry_nodes, replace_entry_contents, rewrite_key,
|
|
59
|
+
blank_comments, remove_entry_node, merge_adjacent_repetitions
|
|
60
60
|
tree_reader.py EntryRef + EntryReader: tree -> one reference per key
|
|
61
61
|
|
|
62
62
|
── entry synthesis: the text of a key the file does not have yet ──
|
|
@@ -70,7 +70,9 @@ src/access/config/
|
|
|
70
70
|
list_layout.py The text of a list whose length changes: ListText, align_values,
|
|
71
71
|
layout_candidates (text only, no tree)
|
|
72
72
|
config_insert.py insert_entry: synthesise, validate, splice
|
|
73
|
-
config_resize.py
|
|
73
|
+
config_resize.py An entry rewritten where it stands: resize_entry (a list of another
|
|
74
|
+
length), fill_entry (a value where there was none), retype_entry (a
|
|
75
|
+
value of another type)
|
|
74
76
|
config_store.py ConfigStore: the tree behind one container, kept in step
|
|
75
77
|
config_dict.py Config (dict subclass), ConfigList and ConfigRecord (read only)
|
|
76
78
|
parser.py ConfigParser (ABC)
|
|
@@ -84,7 +86,8 @@ src/access/config/
|
|
|
84
86
|
field_table.py FieldTableParser (keys lower-cased, headers as chains of three keys,
|
|
85
87
|
methods of three strings as records)
|
|
86
88
|
rose_conf.py RoseConfParser (case-sensitive, [NAME] sections nothing closes,
|
|
87
|
-
every value untyped text, ignore marks in the key)
|
|
89
|
+
every value untyped text, ignore marks in the key) + RoseConfig,
|
|
90
|
+
the Config it returns (active, enable, ignore)
|
|
88
91
|
yaml_config.py YAMLParser (thin wrapper over ruamel.yaml, its text patched)
|
|
89
92
|
json_config.py JSONParser (thin wrapper over json, its layout detected)
|
|
90
93
|
|
|
@@ -137,12 +140,12 @@ entry_style <- contract, values, fragments, navigation, tree_edits
|
|
|
137
140
|
entry_render <- contract, values, fragments, style
|
|
138
141
|
config_insert <- contract, values, tree_*, entry_render [compiled, style]
|
|
139
142
|
config_resize <- contract, values, tree_*, list_layout, config_insert
|
|
140
|
-
[compiled]
|
|
143
|
+
[compiled, style]
|
|
141
144
|
config_store <- contract, values, tree_*, entry_style, list_layout, config_insert,
|
|
142
145
|
config_resize [compiled]
|
|
143
146
|
config_dict <- contract, values, tree_reader [config_store]
|
|
144
147
|
parser <- compiled, contract, config_dict, config_store, tree_navigation
|
|
145
|
-
<format modules> <- parser, contract
|
|
148
|
+
<format modules> <- parser, contract (rose_conf also config_dict, for RoseConfig)
|
|
146
149
|
yaml_config, json_config -- no package imports
|
|
147
150
|
```
|
|
148
151
|
|
|
@@ -388,17 +391,42 @@ header in `__init__.py`. Structure is a review matter; line length is not.
|
|
|
388
391
|
table entry could be written back in the top-level syntax, as a file that no longer parses.
|
|
389
392
|
Keep the distinguishing punctuation in a rule of its own: `assign: "="` in `nuopc_config.py`,
|
|
390
393
|
`separator: ","` in `fortran_nml.py`.
|
|
394
|
+
- `load` and `save` are `parse` and `str` on a file read and written as UTF-8, with no newline
|
|
395
|
+
translation, so neither the locale's encoding nor its line endings come into it. `load` adds a
|
|
396
|
+
note naming the file to whatever `parse` raises. `save` goes through `_write_file`: a path that
|
|
397
|
+
is no regular file once resolved (a new one, `/dev/stdout`, a FIFO) is written in place, never
|
|
398
|
+
read; nothing is written where a readable file already holds the text; a file `os.access` says
|
|
399
|
+
the caller may not write raises `PermissionError`, since a rename needs leave of the directory
|
|
400
|
+
only; otherwise the text goes to a `mkstemp` file beside the target, given its mode and
|
|
401
|
+
`fsync`ed, which `replace`s it, the path resolved first so a link stays a link, and only a
|
|
402
|
+
directory that takes no new file (`PermissionError`) gets an in-place write. With
|
|
403
|
+
`follow_symlinks=False` what is replaced is the link itself (the path with only its directory
|
|
404
|
+
resolved), and that directory taking no new file is a `PermissionError` rather than a write
|
|
405
|
+
through the link; with `atomic=True` it is a `PermissionError` for any file, which is then
|
|
406
|
+
never written over in place.
|
|
407
|
+
Both are written three times (`ConfigParser`/`Config`, and the YAML and JSON pairs, with
|
|
408
|
+
`SavesAtomically` in `conftest.py` testing each `save`) because those two modules import
|
|
409
|
+
nothing from the package. `run_in_ascii_locale` in `conftest.py` runs a check
|
|
410
|
+
in a Python whose default encoding is ASCII: in-process, UTF-8 mode can hide the difference.
|
|
391
411
|
- `ConfigParser.parse` appends a `"\n"` to the input before parsing (so grammars need not
|
|
392
412
|
handle a missing final newline), and `Config.__str__` strips one trailing newline back off.
|
|
393
413
|
- **`ConfigStore` owns the tree; `Config` owns the dict.** The store keeps `refs`, one
|
|
394
414
|
`EntryRef` per key — the entry node, the value-type nodes, and the `block` node where there is
|
|
395
415
|
one — and mutates those nodes in place on assignment. `Config` never touches a `Tree`: it
|
|
396
416
|
normalises the key, decides update or addition, and wraps what the store reports into a
|
|
397
|
-
`ConfigList` or a nested `Config`. Do not let either side reach across.
|
|
398
|
-
|
|
417
|
+
`ConfigList` or a nested `Config`. Do not let either side reach across. A value is made plain
|
|
418
|
+
on its way in (`_plain` in `config_dict`): a subclass of a builtin, such as ruamel.yaml's
|
|
419
|
+
`ScalarFloat`, becomes the builtin, and its `ScalarBoolean`, an `int`, a `bool`. Below that,
|
|
420
|
+
every value-type check is an exact `type(...) is`, which is what keeps a `bool` out of an
|
|
421
|
+
integer, so a subclass would otherwise be refused.
|
|
422
|
+
- Editing is restricted, but adding keys, resizing lists, renaming keys and giving a valueless
|
|
423
|
+
key a value are supported. Assigning to a
|
|
399
424
|
**new** key adds an entry — a scalar, a list of two or more values, `None` where the grammar
|
|
400
425
|
has a `key_null` rule, a `dict` to create a block and fill it, or a list of dicts for records.
|
|
401
|
-
What still fails: changing a value's type raises `TypeError
|
|
426
|
+
What still fails: changing a value's type raises `TypeError` (a value to `None`, and `None` to
|
|
427
|
+
a list or a dict, included) — except an `int` given for a `float`, or to a list of floats only,
|
|
428
|
+
which `Config` widens to a `float` first (`_widened`), and a change the parser was made to take
|
|
429
|
+
(`ConfigParser(type_changes=...)`, below) — as does a new element of a list
|
|
402
430
|
whose elements all have one type, unless it has that type too (a mixed list, such as a Fortran
|
|
403
431
|
derived type assigned as a list of its components, takes any); a list shorter than two
|
|
404
432
|
elements (one, for records), or one written with a repeat count, array qualifiers, skipped
|
|
@@ -409,6 +437,32 @@ header in `__init__.py`. Structure is a review matter; line length is not.
|
|
|
409
437
|
`ValueError`; and a value the grammar cannot express raises `UnsupportedEntryError` (a
|
|
410
438
|
`TypeError` subclass). A list write that fails leaves the file and the list as they were:
|
|
411
439
|
every value is checked before any node changes.
|
|
440
|
+
- **A `key_null` entry takes a scalar where it stands, and a key is renamed where it stands.**
|
|
441
|
+
Both keep the entry's node and are validated by parsing before the tree changes, as a resize
|
|
442
|
+
is. `fill_entry` keeps the line and writes only the value into it, after the punctuation that
|
|
443
|
+
follows the key: the value's text and the spacing before it are read off a new entry of the
|
|
444
|
+
format (`iter_valid_entries`, the candidates `insert_entry` would write), and nothing else of
|
|
445
|
+
that entry is used. `ConfigStore.rename` writes the line out with the new key, parses it, and
|
|
446
|
+
requires it to read as before with the new key for the old; only then does `rewrite_key`
|
|
447
|
+
change the key tokens, so every node survives and no block is read afresh. It renames each
|
|
448
|
+
entry of a key assigned more than once, and refuses what has no key of its own: a gathered
|
|
449
|
+
array, collected records, a chain. `Config.rename` refills the dict so its order stays the
|
|
450
|
+
file's, and points a held `ConfigList` or block at the new key.
|
|
451
|
+
- **A value of another type is the caller's to allow, and is written where it stands too.**
|
|
452
|
+
`ConfigParser(type_changes=...)` is `"refuse"` (the default, today's `TypeError`), `"shape"`
|
|
453
|
+
(a scalar ↔ a list whose values keep the one type of the old ones) or `"any"`; it travels on
|
|
454
|
+
`ParseContext.type_changes`, so the cached grammar is shared still. `ConfigStore.replace` tries
|
|
455
|
+
the in-place write, and only on a `TypeError` that is not an `UnsupportedEntryError` asks
|
|
456
|
+
`_takes`, which never takes a block, a `key_null` or records, and under `"shape"` leaves a
|
|
457
|
+
skipped position's `None` out of the old types. `retype_entry` keeps the line up to the first
|
|
458
|
+
value and from the last, refuses a list shorter than two, what `_resizable_entry` refuses
|
|
459
|
+
(assigned twice, qualifiers, unset positions, a repeat count) and values written over several
|
|
460
|
+
lines (text the new values would drop: line breaks and their comments), and takes the
|
|
461
|
+
values' text from a new entry of the format, except that a value the old first value's rule
|
|
462
|
+
can write is written by it: in the old notation if it has the old type (`'x'` keeps its
|
|
463
|
+
quotes), as a new value of that rule if not (a field table's bare `restart_file = 5`).
|
|
464
|
+
`Config.__setitem__` wraps a scalar that became a list afresh, and detaches the `ConfigList` of
|
|
465
|
+
a list that became a scalar (`_detach`), so a caller holding it cannot write a list back.
|
|
412
466
|
- **Indexed Fortran assignments are gathered into one list.** `v(1) = 1` and `v(2) = 2` are the
|
|
413
467
|
two-element `V`; `EntryRef.values` holds what such an array reads as, and each element is
|
|
414
468
|
edited through the node that wrote it. A position no entry writes, or a skipped one
|
|
@@ -421,11 +475,20 @@ header in `__init__.py`. Structure is a review matter; line length is not.
|
|
|
421
475
|
its components hold.
|
|
422
476
|
- One property says how keys are cased, `ConfigParser.key_case`: `"keep"` (the default, for
|
|
423
477
|
case-sensitive formats), `"upper"` for `FortranNMLParser`, `"lower"` for `FieldTableParser`.
|
|
424
|
-
A parser has to declare nothing but its grammar.
|
|
478
|
+
A parser has to declare nothing but its grammar. `ConfigParser.config_class` is the class
|
|
479
|
+
`parse` returns and `Config._block` builds for a block (`type(self)`): `Config`, except for
|
|
480
|
+
Rose. A **new** key is written into the file
|
|
425
481
|
exactly as the caller spelled it, while the dict entry is normalised — idempotently, which is
|
|
426
482
|
why `add_path` and `insert_entry` take only the spelled keys. Whether a new key is a usable
|
|
427
483
|
name is asked of the grammar's own `key` rule (`ParseContext.accepts_key`, parsing with
|
|
428
484
|
`start="key"`), never of `str.isidentifier`: a field table key may hold a hyphen or a slash.
|
|
485
|
+
- **Rose's ignore marks stay in the key; `RoseConfig` is the API over them.** `!KEY` and `KEY`
|
|
486
|
+
are two keys, so nothing ignored is mistaken for something in use. `active`, `enable` and
|
|
487
|
+
`ignore` take a name with or without marks and go through `Config` only (`rename`, `del`,
|
|
488
|
+
assignment), plus `Config.file_order` for the order: `refs` and the dict are in the
|
|
489
|
+
order keys are *first* written, and Rose reads a name in the state written *last*. A name in
|
|
490
|
+
several states is left written once, where it was last; a section in several states is
|
|
491
|
+
refused, since settling it would delete settings.
|
|
429
492
|
- `ConfigParser.repeated_blocks` says what a block written twice means: `"merge"` (the default)
|
|
430
493
|
reads one block holding both, `"separate"` keeps each occurrence as a block of its own, in a
|
|
431
494
|
`ConfigBlockList`. Fortran is `"separate"`, because its `READ` stops at the first group of a
|
|
@@ -496,9 +559,10 @@ header in `__init__.py`. Structure is a review matter; line length is not.
|
|
|
496
559
|
them into fixed text, punctuation and all; `probe_entry_style` keeps one per
|
|
497
560
|
`(depth, category)`, from the last entry on a line of its own above the insertion point. It is
|
|
498
561
|
offered ahead of the declared template, and a value written with the same rule as the one
|
|
499
|
-
copied keeps its notation (quotes, logical spelling, exponent letter
|
|
500
|
-
|
|
501
|
-
|
|
562
|
+
copied keeps its notation (quotes, logical spelling, a real's exponent letter, sign and width,
|
|
563
|
+
and a bare point; `_float_to_str` takes the digits from `repr`, so the value reads back).
|
|
564
|
+
Comments, array qualifiers and block contents are left out, and a list broken after its first
|
|
565
|
+
value is not copied at all. The only other thing read from the file is the *indentation* of the entry above
|
|
502
566
|
(`EntryStyle.indent`, `None` where there is none), never the spacing inside an entry.
|
|
503
567
|
- **The candidates, in order**: the donor; the declared template with the indent of the entry
|
|
504
568
|
above; the declared template with its own indent, the leading whitespace of the line holding
|
|
@@ -599,18 +663,24 @@ header in `__init__.py`. Structure is a review matter; line length is not.
|
|
|
599
663
|
- **The root is a `RootAllocation`, and that is the whole class** — it adds no fields to the
|
|
600
664
|
base. The base's four fields are exactly what a root may state, and every *sizing* field
|
|
601
665
|
lives on a mode, so "the root cannot size itself" is expressed by the type. One `isinstance`
|
|
602
|
-
check in `resolve_root_strategy` enforces it, and it is **required**: there is no mypy in CI
|
|
603
|
-
|
|
666
|
+
check in `resolve_root_strategy` enforces it, and it is **required**: there is no mypy in CI,
|
|
667
|
+
so the annotation alone enforces nothing here (the package ships `py.typed`, which helps a
|
|
668
|
+
caller's type checker, not this one).
|
|
604
669
|
`RootAllocation` declares no `_phase`, so nesting one raises `AttributeError` naming the
|
|
605
670
|
class; its `_iter_core_shares` exists only to satisfy the ABC and raises `TypeError` (not a
|
|
606
671
|
generator, so it fires on the call).
|
|
607
|
-
- **
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
`
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
672
|
+
- **The base has no default mode; the resolved tree has a default for every component.** A
|
|
673
|
+
component the caller's tree leaves out takes one when `resolve_root_strategy` completes the
|
|
674
|
+
tree (`_with_defaults`): `WholeRangeAllocation()` under a `CoreSharing.SHARED` parent,
|
|
675
|
+
`FreeAllocation()` under any other, its own sub-components completed by the same rule. An
|
|
676
|
+
unknown name is still `ValueError`, before the fractions are resolved. The default is chosen
|
|
677
|
+
by module-level code below the modes, since choosing it knows the modes: don't give the base a
|
|
678
|
+
default mode, or a field default that is one. A tree that leaves nothing out comes back as the
|
|
679
|
+
same object. `iter_layouts(allocations=None)` is `RootAllocation()`, completed the same way, so
|
|
680
|
+
no strategy and a strategy that names nothing give the same layouts. The enumerator always holds
|
|
681
|
+
a complete tree, which is why `strategies_for` can index `subcomponents` directly. What this gives
|
|
682
|
+
up is the loud failure of a missing entry: a component forgotten in a strategy, or added to a
|
|
683
|
+
model later, silently takes its default, which under a shared parent pins it to the whole range.
|
|
614
684
|
- **The scheduler is mode-agnostic**, and this is the invariant most worth protecting. Adding a
|
|
615
685
|
mode means writing the class, declaring `_phase`, and implementing `_iter_core_shares`;
|
|
616
686
|
nothing in `iter_core_splits` is edited, and there is no `isinstance` chain to extend. The
|
|
@@ -645,8 +715,8 @@ header in `__init__.py`. Structure is a review matter; line length is not.
|
|
|
645
715
|
API: Python has no `internal`, and importing a `_`-prefixed name across modules is worse. (The
|
|
646
716
|
one such import, `_occupied` into `parallel_layouts`, is a Housekeeping item.) Everything a
|
|
647
717
|
mode knows about *itself* stays `_`-prefixed and inside `parallel_allocation_strategies`:
|
|
648
|
-
`
|
|
649
|
-
`_shared_core_range`, `
|
|
718
|
+
`_with_defaults`, `_core_range`, `_resolve_fractions`, `_iter_core_shares`,
|
|
719
|
+
`_shared_core_range`, `_group_by_mode`. What a caller touches is the six classes'
|
|
650
720
|
fields plus `iter_layouts`. Doctests run on private methods too, but keep *class-level*
|
|
651
721
|
examples on the public API.
|
|
652
722
|
- Code that knows *all* the modes at once sits at module level below them, never on the base
|
|
@@ -709,12 +779,12 @@ header in `__init__.py`. Structure is a review matter; line length is not.
|
|
|
709
779
|
- Core splits under a `PARTITIONED` parent may leave cores idle by design; bound the slack with
|
|
710
780
|
`MaxWastedCoreFractionConstraint` on the parent rather than changing the enumerator. On a
|
|
711
781
|
`SHARED` parent the covering rule does that job by pruning: `iter_shared_core_shares` yields
|
|
712
|
-
only the combinations that fill the range (on ACCESS-OM3's tree, a little over half the
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
rather than shrinking it.
|
|
782
|
+
only the combinations that fill the range (on ACCESS-OM3's tree, a little over half the layouts
|
|
783
|
+
and more than half the time). What is left is still a product — four siblings each given an
|
|
784
|
+
unbounded `FreeAllocation` on 275 cores is most of 275⁴ — so shrink it with allocations: leave a
|
|
785
|
+
sibling out of the strategy, which pins it to the whole range, or give it a `FixedAllocation`,
|
|
786
|
+
and narrow bounds or a `core_step` to thin one. `EqualCoresGroupConstraint` says "all the same
|
|
787
|
+
count" in one rule, but filters the product rather than shrinking it.
|
|
718
788
|
- One `iter_layouts` call is one `_LayoutSearch`. The two things invariant for a whole search —
|
|
719
789
|
`total_cores` and the subtree memo — are its state; `(component, n_cores, thread_range,
|
|
720
790
|
strategy)` varies with the recursion and is exactly the memo key. That is why the key omits
|
|
@@ -730,13 +800,18 @@ header in `__init__.py`. Structure is a review matter; line length is not.
|
|
|
730
800
|
`access.config.parallel_allocation_strategies` (a core split the fixed allocations cannot
|
|
731
801
|
fit). pytest's `caplog` leaves the *root* logger at WARNING, so a test naming the wrong one
|
|
732
802
|
sees no record at all.
|
|
733
|
-
- Both modules carry an `__all__`: `parallel_allocation_strategies.__all__` is the abstract
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
803
|
+
- Both modules carry an `__all__`: `parallel_allocation_strategies.__all__` is the abstract base,
|
|
804
|
+
`RootAllocation` and the four modes; `parallel_layouts.__all__` is `iter_layouts` alone — the
|
|
805
|
+
classes are imported from where they are defined, not re-exported. The package itself,
|
|
806
|
+
`access.config`, re-exports everything a caller builds or calls: the component tree, layouts,
|
|
807
|
+
domains and grids, the two constraint base classes, `iter_layouts`, `RootAllocation`, the four
|
|
808
|
+
modes and every constraint of `parallel_constraints`. `tests/test_init.py` checks that a new
|
|
809
|
+
mode or constraint is among them. `AllocationStrategy` is not: a tree is written with the root
|
|
810
|
+
and the modes. The user documentation imports from `access.config` only. Names in neither module's `__all__` are an import, module
|
|
811
|
+
state (`logger`), `_`-prefixed, or one of the cross-module contract names above. Ruff's `F822`
|
|
812
|
+
fails the build on a name in `__all__` that no longer exists, so a rename must touch both.
|
|
813
|
+
`__all__` constrains `import *` only; it does not stop an explicit import, and it says nothing
|
|
814
|
+
about which *methods* are internal.
|
|
740
815
|
- `LocalConstraint.is_satisfied(layout)` filters a single component;
|
|
741
816
|
`GroupConstraint.is_satisfied(sub_layouts)` filters siblings and must be attached to the
|
|
742
817
|
**parent's** `group_constraints`. A constraint sees only the layout it judges: a rule stated
|
|
@@ -763,6 +838,7 @@ Read the relevant one *before* starting the task:
|
|
|
763
838
|
| [`skills/grammar-debug/SKILL.md`](skills/grammar-debug/SKILL.md) | a file fails to parse, a round-trip differs, a key is missing, or an edit corrupts the output |
|
|
764
839
|
| [`skills/add-parallel-constraint/SKILL.md`](skills/add-parallel-constraint/SKILL.md) | adding a constraint to the layout enumeration library |
|
|
765
840
|
| [`skills/check/SKILL.md`](skills/check/SKILL.md) | finishing a change, before committing or opening a PR |
|
|
841
|
+
| [`skills/use-access-config/SKILL.md`](skills/use-access-config/SKILL.md) | *using* the library from another project: reading and editing a configuration file, or running a layout search |
|
|
766
842
|
|
|
767
843
|
`.claude/skills` is a symlink to `skills/` so that Claude Code auto-discovers them; the guides
|
|
768
844
|
themselves are tool-neutral.
|
{access_config_utils-0.6/src/access_config_utils.egg-info → access_config_utils-0.7}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: access-config-utils
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7
|
|
4
4
|
Summary: Utilities to work with configurations for the ACCESS climate models.
|
|
5
5
|
Author-email: Micael Oliveira <micael.oliveira@anu.edu.au>
|
|
6
6
|
Keywords: configurations,parser,access
|
|
@@ -78,7 +78,17 @@ pip install .
|
|
|
78
78
|
|
|
79
79
|
Here is a simple example of how to parse a text and modify its contents.
|
|
80
80
|
|
|
81
|
-
To
|
|
81
|
+
To read a file, call the `load` method of the appropriate parser. Edit the configuration like a Python dict, and
|
|
82
|
+
write it back with `save`:
|
|
83
|
+
```python
|
|
84
|
+
from access.config import FortranNMLParser
|
|
85
|
+
|
|
86
|
+
config = FortranNMLParser().load("input.nml")
|
|
87
|
+
config["fms_nml"]["domains_stack_size"] = 8000000
|
|
88
|
+
config.save("input.nml")
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
To parse a text that you already have, call the `parse` method instead:
|
|
82
92
|
```python
|
|
83
93
|
from access.config import FortranNMLParser
|
|
84
94
|
|
|
@@ -93,7 +103,7 @@ print(config)
|
|
|
93
103
|
|
|
94
104
|
This prints:
|
|
95
105
|
|
|
96
|
-
```
|
|
106
|
+
```text
|
|
97
107
|
&data_nml
|
|
98
108
|
parameterA = 1
|
|
99
109
|
parameterB = 'abc'
|
|
@@ -109,7 +119,7 @@ print(config)
|
|
|
109
119
|
|
|
110
120
|
This prints:
|
|
111
121
|
|
|
112
|
-
```
|
|
122
|
+
```text
|
|
113
123
|
&data_nml
|
|
114
124
|
parameterA = 2
|
|
115
125
|
parameterB = 'abc'
|
|
@@ -127,7 +137,7 @@ print(config)
|
|
|
127
137
|
|
|
128
138
|
This prints:
|
|
129
139
|
|
|
130
|
-
```
|
|
140
|
+
```text
|
|
131
141
|
&data_nml
|
|
132
142
|
parameterA = 2
|
|
133
143
|
parameterB = 'abc'
|
|
@@ -157,7 +167,7 @@ print(config)
|
|
|
157
167
|
|
|
158
168
|
This prints:
|
|
159
169
|
|
|
160
|
-
```
|
|
170
|
+
```text
|
|
161
171
|
&data_nml
|
|
162
172
|
parameterD = 1,
|
|
163
173
|
2,
|
|
@@ -166,10 +176,14 @@ parameterD = 1,
|
|
|
166
176
|
```
|
|
167
177
|
|
|
168
178
|
A few caveats on the dict and list behaviour:
|
|
169
|
-
- A list keeps at least two elements, since a single value is a scalar
|
|
170
|
-
become a list or the other way round.
|
|
179
|
+
- A list keeps at least two elements, since a single value is a scalar. A scalar does not
|
|
180
|
+
become a list, or the other way round, unless the parser takes a change of type (below).
|
|
171
181
|
- A list whose elements are all of one type keeps them so: a new element of another type raises
|
|
172
182
|
`TypeError`.
|
|
183
|
+
- A value of another type raises `TypeError`, unless the parser was made to take it:
|
|
184
|
+
`FortranNMLParser(type_changes="shape")` lets a scalar become a list and a list a scalar of the
|
|
185
|
+
same type, and `type_changes="any"` lets any value take the place of any other. The new value is
|
|
186
|
+
written where the old one was, the rest of its line kept.
|
|
173
187
|
- A list written with repeat counts (`3*1.0`), array qualifiers (`x(2) = …`) or skipped
|
|
174
188
|
positions, or assigned more than once, can have its elements changed but not its length:
|
|
175
189
|
delete the key and assign it again instead. The elements a repeat count stands for can only
|
|
@@ -194,7 +208,7 @@ print(dict(config["tracer"]["atmos_mod"]["sphum"]))
|
|
|
194
208
|
|
|
195
209
|
This prints:
|
|
196
210
|
|
|
197
|
-
```
|
|
211
|
+
```text
|
|
198
212
|
{'longname': 'specific humidity', 'profile_type': [{'value': 'fixed', 'surface_value': 3e-06}]}
|
|
199
213
|
```
|
|
200
214
|
A record is read only. To change it, assign a dict to its place in the list. A new field is written as a whole entry,
|
|
@@ -208,10 +222,10 @@ print(config)
|
|
|
208
222
|
|
|
209
223
|
This prints:
|
|
210
224
|
|
|
211
|
-
```
|
|
225
|
+
```text
|
|
212
226
|
"TRACER", "atmos_mod", "sphum"
|
|
213
227
|
"longname", "specific humidity"
|
|
214
|
-
"profile_type", "fixed", "surface_value=
|
|
228
|
+
"profile_type", "fixed", "surface_value=1.e-5" /
|
|
215
229
|
"TRACER", "atmos_mod", "liq_wat"
|
|
216
230
|
"longname", "cloud liquid specific humidity" /
|
|
217
231
|
```
|
|
@@ -237,7 +251,7 @@ print(config)
|
|
|
237
251
|
|
|
238
252
|
This prints:
|
|
239
253
|
|
|
240
|
-
```
|
|
254
|
+
```text
|
|
241
255
|
{
|
|
242
256
|
"name": "run",
|
|
243
257
|
"levels": [1, 2, 3, 4],
|
|
@@ -249,6 +263,29 @@ This prints:
|
|
|
249
263
|
}
|
|
250
264
|
```
|
|
251
265
|
|
|
266
|
+
### Parallelisation layouts
|
|
267
|
+
|
|
268
|
+
Everything a layout search needs is imported from `access.config`. Describe the model as a tree of components, and
|
|
269
|
+
iterate over the layouts that fit a number of cores:
|
|
270
|
+
```python
|
|
271
|
+
from access.config import Domain, FixedAllocation, ParallelComponent, RootAllocation, iter_layouts
|
|
272
|
+
|
|
273
|
+
model = ParallelComponent(
|
|
274
|
+
"model",
|
|
275
|
+
subcomponents=(
|
|
276
|
+
ParallelComponent("atm", domain=Domain((192, 144))),
|
|
277
|
+
ParallelComponent("ocn", domain=Domain((360, 300))),
|
|
278
|
+
),
|
|
279
|
+
)
|
|
280
|
+
allocations = RootAllocation(subcomponents={"atm": FixedAllocation(4)})
|
|
281
|
+
for layout in iter_layouts(model, 8, allocations=allocations):
|
|
282
|
+
ocean = layout.find("ocn")
|
|
283
|
+
print(ocean.n_cores, ocean.decomposition.grid.shape)
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
The search is lazy, because a model can have millions of layouts. A layout is turned into plain data, for example to
|
|
287
|
+
store it as JSON, with `layout.to_dict()`, and back with `ComponentLayout.from_dict`.
|
|
288
|
+
|
|
252
289
|
## Development installation
|
|
253
290
|
|
|
254
291
|
If you intend to contribute or modify the package, it is recommended to work inside a virtual environment.
|
|
@@ -57,7 +57,17 @@ pip install .
|
|
|
57
57
|
|
|
58
58
|
Here is a simple example of how to parse a text and modify its contents.
|
|
59
59
|
|
|
60
|
-
To
|
|
60
|
+
To read a file, call the `load` method of the appropriate parser. Edit the configuration like a Python dict, and
|
|
61
|
+
write it back with `save`:
|
|
62
|
+
```python
|
|
63
|
+
from access.config import FortranNMLParser
|
|
64
|
+
|
|
65
|
+
config = FortranNMLParser().load("input.nml")
|
|
66
|
+
config["fms_nml"]["domains_stack_size"] = 8000000
|
|
67
|
+
config.save("input.nml")
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
To parse a text that you already have, call the `parse` method instead:
|
|
61
71
|
```python
|
|
62
72
|
from access.config import FortranNMLParser
|
|
63
73
|
|
|
@@ -72,7 +82,7 @@ print(config)
|
|
|
72
82
|
|
|
73
83
|
This prints:
|
|
74
84
|
|
|
75
|
-
```
|
|
85
|
+
```text
|
|
76
86
|
&data_nml
|
|
77
87
|
parameterA = 1
|
|
78
88
|
parameterB = 'abc'
|
|
@@ -88,7 +98,7 @@ print(config)
|
|
|
88
98
|
|
|
89
99
|
This prints:
|
|
90
100
|
|
|
91
|
-
```
|
|
101
|
+
```text
|
|
92
102
|
&data_nml
|
|
93
103
|
parameterA = 2
|
|
94
104
|
parameterB = 'abc'
|
|
@@ -106,7 +116,7 @@ print(config)
|
|
|
106
116
|
|
|
107
117
|
This prints:
|
|
108
118
|
|
|
109
|
-
```
|
|
119
|
+
```text
|
|
110
120
|
&data_nml
|
|
111
121
|
parameterA = 2
|
|
112
122
|
parameterB = 'abc'
|
|
@@ -136,7 +146,7 @@ print(config)
|
|
|
136
146
|
|
|
137
147
|
This prints:
|
|
138
148
|
|
|
139
|
-
```
|
|
149
|
+
```text
|
|
140
150
|
&data_nml
|
|
141
151
|
parameterD = 1,
|
|
142
152
|
2,
|
|
@@ -145,10 +155,14 @@ parameterD = 1,
|
|
|
145
155
|
```
|
|
146
156
|
|
|
147
157
|
A few caveats on the dict and list behaviour:
|
|
148
|
-
- A list keeps at least two elements, since a single value is a scalar
|
|
149
|
-
become a list or the other way round.
|
|
158
|
+
- A list keeps at least two elements, since a single value is a scalar. A scalar does not
|
|
159
|
+
become a list, or the other way round, unless the parser takes a change of type (below).
|
|
150
160
|
- A list whose elements are all of one type keeps them so: a new element of another type raises
|
|
151
161
|
`TypeError`.
|
|
162
|
+
- A value of another type raises `TypeError`, unless the parser was made to take it:
|
|
163
|
+
`FortranNMLParser(type_changes="shape")` lets a scalar become a list and a list a scalar of the
|
|
164
|
+
same type, and `type_changes="any"` lets any value take the place of any other. The new value is
|
|
165
|
+
written where the old one was, the rest of its line kept.
|
|
152
166
|
- A list written with repeat counts (`3*1.0`), array qualifiers (`x(2) = …`) or skipped
|
|
153
167
|
positions, or assigned more than once, can have its elements changed but not its length:
|
|
154
168
|
delete the key and assign it again instead. The elements a repeat count stands for can only
|
|
@@ -173,7 +187,7 @@ print(dict(config["tracer"]["atmos_mod"]["sphum"]))
|
|
|
173
187
|
|
|
174
188
|
This prints:
|
|
175
189
|
|
|
176
|
-
```
|
|
190
|
+
```text
|
|
177
191
|
{'longname': 'specific humidity', 'profile_type': [{'value': 'fixed', 'surface_value': 3e-06}]}
|
|
178
192
|
```
|
|
179
193
|
A record is read only. To change it, assign a dict to its place in the list. A new field is written as a whole entry,
|
|
@@ -187,10 +201,10 @@ print(config)
|
|
|
187
201
|
|
|
188
202
|
This prints:
|
|
189
203
|
|
|
190
|
-
```
|
|
204
|
+
```text
|
|
191
205
|
"TRACER", "atmos_mod", "sphum"
|
|
192
206
|
"longname", "specific humidity"
|
|
193
|
-
"profile_type", "fixed", "surface_value=
|
|
207
|
+
"profile_type", "fixed", "surface_value=1.e-5" /
|
|
194
208
|
"TRACER", "atmos_mod", "liq_wat"
|
|
195
209
|
"longname", "cloud liquid specific humidity" /
|
|
196
210
|
```
|
|
@@ -216,7 +230,7 @@ print(config)
|
|
|
216
230
|
|
|
217
231
|
This prints:
|
|
218
232
|
|
|
219
|
-
```
|
|
233
|
+
```text
|
|
220
234
|
{
|
|
221
235
|
"name": "run",
|
|
222
236
|
"levels": [1, 2, 3, 4],
|
|
@@ -228,6 +242,29 @@ This prints:
|
|
|
228
242
|
}
|
|
229
243
|
```
|
|
230
244
|
|
|
245
|
+
### Parallelisation layouts
|
|
246
|
+
|
|
247
|
+
Everything a layout search needs is imported from `access.config`. Describe the model as a tree of components, and
|
|
248
|
+
iterate over the layouts that fit a number of cores:
|
|
249
|
+
```python
|
|
250
|
+
from access.config import Domain, FixedAllocation, ParallelComponent, RootAllocation, iter_layouts
|
|
251
|
+
|
|
252
|
+
model = ParallelComponent(
|
|
253
|
+
"model",
|
|
254
|
+
subcomponents=(
|
|
255
|
+
ParallelComponent("atm", domain=Domain((192, 144))),
|
|
256
|
+
ParallelComponent("ocn", domain=Domain((360, 300))),
|
|
257
|
+
),
|
|
258
|
+
)
|
|
259
|
+
allocations = RootAllocation(subcomponents={"atm": FixedAllocation(4)})
|
|
260
|
+
for layout in iter_layouts(model, 8, allocations=allocations):
|
|
261
|
+
ocean = layout.find("ocn")
|
|
262
|
+
print(ocean.n_cores, ocean.decomposition.grid.shape)
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
The search is lazy, because a model can have millions of layouts. A layout is turned into plain data, for example to
|
|
266
|
+
store it as JSON, with `layout.to_dict()`, and back with `ComponentLayout.from_dict`.
|
|
267
|
+
|
|
231
268
|
## Development installation
|
|
232
269
|
|
|
233
270
|
If you intend to contribute or modify the package, it is recommended to work inside a virtual environment.
|
|
@@ -40,8 +40,12 @@ omit = ["src/access/config/__init__.py"]
|
|
|
40
40
|
|
|
41
41
|
[tool.ruff]
|
|
42
42
|
line-length = 120
|
|
43
|
-
#
|
|
44
|
-
|
|
43
|
+
# documentation/hooks: copied verbatim from the ACCESS-NRI documentation template, and kept that way so it can be
|
|
44
|
+
# updated from there. *.md: ruff >= 0.16 would rewrite the hand-laid-out examples in the python code blocks of the
|
|
45
|
+
# documentation, which the ruff pinned in pre-commit never formats. force-exclude applies both to the paths named on
|
|
46
|
+
# the command line too, as an editor's format-on-save passes them.
|
|
47
|
+
extend-exclude = ["documentation/hooks", "*.md"]
|
|
48
|
+
force-exclude = true
|
|
45
49
|
|
|
46
50
|
[tool.ruff.lint]
|
|
47
51
|
select = ["E", "F", "B", "C4", "SIM", "PTH", "UP", "I", "N", "C901", "W505"]
|
|
@@ -137,5 +137,7 @@ If the constraint is meant to prune a real enumeration, also add an integration
|
|
|
137
137
|
- Update the module docstring's list of families: add what the new rule checks to its family's
|
|
138
138
|
line (as `EqualCoresGroupConstraint` did for core distribution), or add a family.
|
|
139
139
|
- Update the constraint count in the repository layout of `AGENTS.md`.
|
|
140
|
+
- Export the constraint from `access.config`, in the imports and the `__all__` of
|
|
141
|
+
`src/access/config/__init__.py`, and update the count of constraints in `tests/test_init.py`.
|
|
140
142
|
- Any `Examples:` block you add runs as a doctest (`tests/test_parallel_doctests.py`).
|
|
141
143
|
- Run the gate in [`skills/check/SKILL.md`](../check/SKILL.md).
|
|
@@ -45,7 +45,10 @@ Equivalently, for the formatting half: `pre-commit run --all-files`.
|
|
|
45
45
|
- If you broke code on purpose to check that a test binds, clear the bytecode afterwards:
|
|
46
46
|
`find . -name __pycache__ -type d -not -path "./.git/*" | xargs rm -rf` (`AGENTS.md` says why).
|
|
47
47
|
- `ruff format .` rewrites files. Run it before `ruff check .` so the check sees the formatted
|
|
48
|
-
result, and re-read any file you had open before editing it further.
|
|
48
|
+
result, and re-read any file you had open before editing it further. It never touches
|
|
49
|
+
Markdown, not even a file named on the command line: `pyproject.toml` excludes `*.md`, with
|
|
50
|
+
`force-exclude`, because ruff 0.16 and later would otherwise rewrite the hand-laid-out
|
|
51
|
+
examples in the documentation. A `.md` file in its report means that exclusion was lost.
|
|
49
52
|
- Line length is 120 and the enabled rules include `C901` (complexity). If `C901` fires, prefer
|
|
50
53
|
splitting the function; only use `# noqa: C901`, with a reason, when the complexity is
|
|
51
54
|
irreducible. The package has no such site today.
|