Repository navigation
test(diagram): reference model and properties for Diagram.expand - #1621
Draft
dimitri-yatsenko wants to merge 57 commits into
Draft
dimitri-yatsenko wants to merge 57 commits into
dimitri-yatsenko wants to merge 57 commits into
Conversation
Add hypothesis to the test dependency group and to the test and dev extras, for the property tests of Diagram.expand. tests/conftest.py registers three profiles, selected with HYPOTHESIS_PROFILE (default: ci when CI is set, else dev): - dev: 50 examples, for fast local runs; - ci: 500 examples, derandomized, no deadline; - thorough: 2000 random examples, with failing examples saved under the gitignored .hypothesis/ directory. pixi.lock is re-solved. Besides hypothesis and sortedcontainers in the test and dev environments, it now records the test-py310 and test-py314 environments that pyproject.toml already declares, and packaging in the default environment; no existing package changes version.
Add an executable reference model of Diagram.expand (L0 of the test
program) that needs no database:
- tests/unit/expand_model.py: TableSpec, FK and Schema; databases as
{table: {pk_tuple: row}}; ref_e under MATCH SIMPLE (A2); the owning
reference (A1), with parts that violate it traversed as plain tables;
the row relations child, parent, inst, down and up; D, D1, U and both
as breadth-first closures; the checkers ri_ok, group_whole,
group_closed, lift_closed and q_acyclic; apply_delete; the
self.upstream of a row not inserted yet; and the Dependencies graph
built the way Dependencies.load builds it.
- tests/unit/test_expand_spec.py: Hypothesis generators for schemas and
consistent databases, and properties for T1-T8. Minimality (T4, T5) is
checked by brute force on databases of at most eight rows. T8 calls
datajoint.dependencies.topo_sort with MySQL and PostgreSQL quoting.
Two examples show that T8 needs A1, and parametrized checks confirm
that the generators reach each shape the properties rely on.
- tests/unit/test_expand_shapes_model.py: one test per shape (S1-S7,
G1-G6, K1, K2, K5, K6) with the expected rows written by hand.
Rewrite tests/unit/test_expand_shapes_model.py to mirror the Traversal
Shape Catalog (traversal-shapes.md) one to one: each shape's schema,
rows and seeds, the rows it states, and its node set, including the
tables listed as none. The catalog's claims about copies, relabeling,
delete modes and the rounds of an iterating group are checked too. The
seed evaluations that need a database (string seeds, Top, the warning)
and X1 are left to the integration suite; X2's cycle in Q is checked.
Extend the reference model:
- inst(r) = {r} for a row in no group, as diagram.md defines it;
- table_reach, the node set of an expanded diagram;
- RowGraph.delete with the three part_integrity modes;
- one_pass, the computation over Q evaluated on rows, with the
iteration rule of diagram.md or the exact one;
- condition semantics for the R1 copy rule and for relabeling keys;
- Schema(..., a1="chain"), A1 generalized to owning chains with
renames (#1429), with the owning attributes composed along the chain.
In test_expand_spec.py, T1-T8 now run under both readings of A1, T1 and
T2 include D1, and T6 checks monotonicity and minimality. New properties
check the one pass, the copy rule and relabeling. Three strict xfails
record where diagram.md's rules disagree with the definitions: a sibling
FK that does not carry the master key links instances without renaming
it; relabeling drops a key on a secondary attribute of the parent; and
a NULL key value on a nullable FK relabels to the NULL child rows.
Follow the revised traversal specification (datajoint-docs#249): - A1 is ownership: a part is owned if an FK in its primary key references the master or an owned part of the same master, renames allowed. Its owning attributes come from that chain, preferring an unrenamed -> master and otherwise the first owning reference. This replaces the strict reading and the a1 switch; a part that references its master only below the line is no longer in its group. - The lift goes through the owning attributes, and a group iterates if and only if some FK inside it does not map owning attributes onto owning attributes. The relabel rule is the revised one. - The shape catalog gains the rewritten G6 (a part its master does not own) and G7 (an owned part-of-part with renamed attributes, #1429). The three xfails for the spec's iteration and relabel rules are gone: the docs now state the model's rules, and the tests assert them. Two strict xfails remain for T8: topo_sort still groups every part with its master by name, while the spec makes a part that is not owned a plain table (#1619). test_expand_spec.py opens with a description of the test layers and of the Hypothesis profiles.
dimitri-yatsenko
requested review from
MilagrosMarin,
lum-agilyti and
ttngu207
October 17, 2026 22:47
This was referenced Oct 17, 2026
…otes for the backend Signed-off-by: mayuriphad <mayuriphad656@gmail.com>
This was referenced Oct 20, 2026
dimitri-yatsenko
marked this pull request as draft
October 21, 2026 16:46
For s3, gcs and azure stores, full_path built <protocol>://<bucket>/<path> and left out the store's location, so it pointed to a path where the object is not when location is set. Use StorageBackend.get_url(), which builds the URL from the same _full_path the backend writes to. Fixes #1646
# Conflicts: # pixi.lock
Dependabot rejects time "9:00" (must match ^\d\d:\d\d$), so the config failed to parse and no GitHub Actions updates were scheduled.
Adds a pip entry for pyproject.toml alongside the github-actions one. increase-if-necessary keeps minimum-version requirements unchanged when they already admit a new release; security updates are grouped.
numpy, pandas, pyparsing, tqdm, networkx, pydot, and packaging had no version specifier. GitHub's dependency graph omits such requirements, so they were missing from the SBOM and from Dependabot alerts. The minimums were verified by running the full test suite on Python 3.10 with each dependency at its minimum. pyparsing 3.1.0 and pydot 2.x fail it: pyparsing 3.1.0 strips the quotes from quoted defaults, and pydot 2.x produces DOT that graphviz rejects. tqdm>=4.66.3 excludes CVE-2024-34062.
pyproject.toml keeps deepdiff<9 for Python 3.15 on purpose: deepdiff 9 requires cachebox<6, which has no 3.15 wheels. With increase-if-necessary, Dependabot would propose widening that cap at every new deepdiff major, so ignore semver-major updates for deepdiff. Also state that version updates stay one PR per package, since each raises an upper bound and deserves its own test run and review.
Pin every action in the lint, test, and stale workflows to the commit its current tag resolves to, so a moved or compromised tag cannot change what runs. Lint and test get a read-only GITHUB_TOKEN, and their checkouts do not persist the token in the working copy.
- pandas>=2.2.2: pandas does not cap numpy, so pandas 1.5.3 with numpy 2 installs and then fails on import (numpy.dtype size changed). 2.2.2 is the first pandas built against numpy 2; 2.2.1 still requires numpy<2. - deepdiff>=6.6.0: DeepHash(ignore_iterable_order=...) first appears in 6.4, and deepdiff before 6.6 uses np.float_, which numpy 2 removed. - pymysql>=1.0.0: connections pass ssl_disabled, which pymysql 0.x does not accept, so every MySQL connection fails on 0.7.2 through 0.10.1. Full suite on Python 3.10 with every core dependency at its minimum passes, and again with numpy 2.2.6 in place of numpy 1.22.4.
Dependabot rejects time "9:00" (must match ^\d\d:\d\d$), so the config failed to parse and no GitHub Actions updates were scheduled. (cherry picked from commit 247125c)
pre-commit/action calls actions/cache by tag and installs an unpinned pre-commit. Run the same steps directly: pre-commit pinned to a version and actions/cache pinned by SHA.
PR 1588 adds a workflow_call trigger just before jobs:, where the permissions block was, so the two PRs conflicted.
…nimums A new test job runs the full suite on Python 3.10 with every runtime dependency pinned at the minimum pyproject.toml declares. .github/scripts/minimum_requirements.py derives the pins and fails when a runtime dependency declares no minimum. deepdiff and pymysql now start at the first release without known vulnerabilities rather than the oldest that works: deepdiff>=8.6.2 (CVE-2025-58367, CVE-2026-33155; was 6.6.0) and pymysql>=1.1.1 (CVE-2024-36039; was 1.0.0). pixi.lock moves deepdiff from 8.6.1 to 9.1.0 where Python < 3.15.
CVE-2025-58367 and CVE-2026-33155 are in deepdiff's Delta class and pickle_load. datajoint uses only DeepHash, so the oldest working version stays the minimum and Dependabot reports the advisories. pymysql stays at 1.1.1 for CVE-2024-36039.
…tions The reviewer asked for a case that pins the trailing-slash location. It asserts that full_path equals what the backend builds for reads and writes, so it holds whether or not _full_path ever normalizes the slash.
fix: Dependabot config fails to parse (schedule time must be HH:MM)
ci: Dependabot watches Python dependencies, not only GitHub Actions
fix: declare minimum versions for all core dependencies
ci: pin actions to commit SHAs and run workflows with read-only tokens
fix: aggr, extend and union keep unmatched rows when the right operand is restricted
fix: dj.Top is honored when a limited expression is used in another query
fix(heading): keep table_info in set_primary_key so a later rename quotes for the backend
…location fix: include the store location in ObjectRef.full_path
…ectories A world-writable secrets directory with the sticky bit, such as a Kubernetes secret volume mounted at /run/secrets/datajoint, no longer produces a "writable by all users" warning: each file in it is still checked when read. A world-writable secrets directory without the sticky bit still warns. Tests also cover running as root, another user's datajoint.json in a world-writable directory without the sticky bit, and a named pipe in place of a secret file.
… not given Connection now falls back to database.use_tls (DJ_USE_TLS) from its config when use_tls is None, as dj.conn and Schema already did. This covers dj.Instance, which passes its own config, and a direct dj.Connection. An explicit use_tls argument still wins. The docstrings for an existing connection now say it is reconnected with the requested TLS settings unless it already satisfies them.
- MySQL string literals double single quotes ('') instead of writing \',
so a literal stays closed even if the session's sql_mode includes
NO_BACKSLASH_ESCAPES. The value read back in the default sql_mode is
unchanged.
- On PostgreSQL, a list value whose text contains a backslash is
rendered as an E'...' literal, which reads the same whether or not
standard_conforming_strings is on. Plain string and JSON object values
are rendered as before.
ObjectRef.download of a folder object lists the keys under the object and refuses the whole download, before writing any file, if a key relative to the object is not made of plain file names (for example, one containing a ".." component). It no longer relies on the installed fsspec version to keep such keys inside the destination. Files still land at destination/<object name>/..., and fsspec still fetches them in one batch. The store-path error message now says that allow_filepath_outside_store applies to <filepath@> values only, and to use it only with trusted data.
The check for mentioned names used `if not self.heading.names`, which never refers to the attribute and is always false, so a rename or replicate of an attribute missing from the heading was silently dropped. Fixes #1677 Signed-off-by: mayuriphad <mayuriphad656@gmail.com>
With a file store whose location is "" or ".", a stored path is used as given, and fsspec reads a leading "file:" or "local:" as a protocol and expands a leading "~". Such a path passed the store-path check and then resolved outside the working directory. The full path is now also checked after fsspec resolves it, so it must lie inside the location whatever the location is.
Keep attachment and store paths inside their roots
fix(connection): require TLS when use_tls is set; honor use_tls certificate options
Render values in mapping restrictions as quoted literals
Parse foreign key references instead of evaluating them; cap blob decompression
fix(config): skip config files other users could place in shared directories
fsspec before 2024 leaves "." segments in a resolved path, so a store whose location is "" or "." rejected every path, including ones inside it. Compare normalized paths instead. The working-directory test now checks what the store does with each path: it is rejected, or fsspec resolves it inside the store and I/O stays there. Old fsspec does not read some "file:" and "local:" forms as a protocol, so it accepts them as names inside the store. The Windows download test accepts OSError, which Windows raises for a source path containing ":".
codespell flags "acter" in the char(?:acter)? pattern in condition.py; add it to the ignore list. mypy reports server_capabilities and _request_authentication on the TLS connection subclass, which are PyMySQL internals that types-PyMySQL does not declare; mark those three lines with targeted type-ignore codes. No behavior change.
fix(proj): raise for a rename or replicate of a missing attribute
fix(storage): accept paths in a file store located in the working directory on fsspec before 2024
Fix lint: codespell regex fragment and mypy errors in the MySQL TLS connection
Conflicts: - pixi.lock: took the merge/master-into-next lock and regenerated it with pixi lock against the merged pyproject.toml; the only addition is hypothesis (and its dependency sortedcontainers) for the test environments.
Member
Author
|
Merged The only conflict was |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first part of the test harness for
Diagram.expand: an executable reference model of the traversal specification in datajoint/datajoint-docs#249, and tests that need no database.What it adds
tests/unit/expand_model.py, the reference model. It definesD,D1,Uandbothas closures over rows, together with:tests/unit/test_expand_spec.pychecks the derived results T1–T8 and those rules with Hypothesis, on random schemas and databases.tests/unit/test_expand_shapes_model.pymirrors the Traversal Shape Catalog of docs(specs): normative spec of Diagram.expand, with a traversal shape catalog datajoint-docs#249 one to one, under the same shape IDs. Every expected row is copied from the catalog by hand, not computed by the model.Two T8 examples are strict
xfails, becausetopo_sortstill groups every part with its master by name (#1619). They start passing when #1620 merges, and the strict marker then flags them for removal.Running
HYPOTHESIS_PROFILEselects the profile:devciCIis setthorough.hypothesis/Dependencies
hypothesisjoins thetestdependency group and thetestanddevextras.pixi.lockis re-solved. The lock on master was stale, so the diff also records thetest-py310andtest-py314environments andpackaging. No package version changes in thedefault,devortestenvironments.Next
The database layers (L1–L3) follow in later PRs. They run the engine against the same model on MySQL and PostgreSQL.