A set[str] field of a fragment with validate_on_load=False loads the stored list as a list, not a set
Maintainer antworten meist innerhalb von 1 Tag
Ein zugehöriger Pull Request wurde bereits gemerged.
- #204 von @jasperblues — gemerged
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 67/100
Rechercherichtung
Start with drivine/mapper/graph_object_mapper.py and inspect _properties, _collected, and _instance; the issue describes how validate_on_load=False skips coercion. Port the listed unit and integration cases from SetFields.spec.ts and StatelessGraphObjectManager.sets.spec.ts, covering fragments, views, relationships, paths, nulls, and absent values. Done means declared set fields load as sets without changing absent or null values, and loaded sets save back as lists.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Port of liberation-data/drivine#280.
What happens here now: a set[str] field of a fragment declared with validate_on_load=False loads the list the store holds as a list, not a set. A validated fragment is fine: Pydantic's model_validate coerces the list to the field's set.
GraphObjectMapper._properties (drivine/mapper/graph_object_mapper.py:84-114) copies each stored value as it is, and only an empty_when_absent field passes through _collected (line 111-113). fragment() then builds the instance with _instance(..., model.validate_on_load) (line 45), and _instance (line 122-123) uses model_construct when validation is off, which coerces nothing. So the same field loads as set() when the node holds nothing for it (@EmptyWhenAbsent), and as a list when it holds items. A tuple[...] field has the same gap. Relationship and path collections already go through _collected with their kind, validated or not (lines 53-62).
Checked against main (987f07f):
class U(NodeFragment, labels=["U"], validate_on_load=False):
id: Annotated[str, NodeId()]
codes: set[str] = set()
mapper.fragment(registry.fragment(U), {"props": {"id": "1", "codes": ["x", "y"]}, "labels": ["U"]}).codes
# ['x', 'y'], a list; the same class without validate_on_load=False gives {'x', 'y'}
What the fix in drivine does: the registry records which fields hold a Set (FieldMapping.sets), and the mapper turns the list a store holds for such a field into a Set, in fragments, views, the fragments and views they hold, relationship fragments and paths. A field the node holds nothing for, or holds null, is left as it is unless it has @EmptyWhenAbsent. A {} a set was held as before sets were stored as lists loads as an empty set.
Suggested fix here: have _properties pass a stored list through _collected for any field whose FieldShape is a set or tuple, so model_construct gets the declared collection too.
Tests to port: drivine's test/1.Unit/mapper/SetFields.spec.ts (a load gives a set; absent stays absent; null stays null; in a view, a nested view, a relationship fragment and a path) and test/2.Integration/manager/StatelessGraphObjectManager.sets.spec.ts (store as a list, load as a set, save the loaded set back as a list, on every store), each with validate_on_load=False.
- Vorherrschende Sprache
- Python
- Sterne
- 1
- Forks
- 0
- Ø Merge
- 1 Std. 19 Min.
- Gemergte PRs (30 T.)
- 122
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus liberation-data/drivine-python
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
liberation-data/drivine-python#252 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
liberation-data/drivine-python#250 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
liberation-data/drivine-python#209 ·
Maintainer antworten meist innerhalb von 1 Tag
-
CI: three Oracle-only tests in test_cypher_compiled.py never run, as -k oracle doesn't select themOffen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
liberation-data/drivine-python#178 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 58/100
liberation-data/drivine-python#243 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in liberation-data/drivine-python
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
microsoft/agent-lightning#661 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
area/profiles comp/cli P3 type/feature
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
NousResearch/hermes-agent#146372 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[BUG] OpenAI-compatible embedding model alias breaks embedder constructionEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
Maintainer antworten meist innerhalb von 1 Tag
-
[oblt-aw][autodoc] Document obs-aw-automerge contract and fix automerge doc inconsistenciesEvtl. vergeben @github-actions hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
-
GeoSeries scale and skew tests fail with pytest 9.2.0Evtl. vergeben @jiayuasu hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag