A set[str] field of a fragment with validate_on_load=False loads the stored list as a list, not a set
Maintainer thường phản hồi trong vòng 1 ngày
Một pull request liên quan đã được merge.
- #204 của @jasperblues — đã merge
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 67/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 1
- Fork
- 0
- Merge trung bình
- 1 giờ 13 phút
- Pull request đã merge (30 ngày)
- 109
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của liberation-data/drivine-python
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
liberation-data/drivine-python#209 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
CI: three Oracle-only tests in test_cypher_compiled.py never run, as -k oracle doesn't select themĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
liberation-data/drivine-python#178 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
liberation-data/drivine-python#219 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 57/100
liberation-data/drivine-python#218 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
liberation-data/drivine-python#215 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của liberation-data/drivine-python
Issue tương tự
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
glossyio/traffic-monitor#264 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add self-hostĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
Atarity/deploy-your-own-saas#102 ·
-
[Bug]: RDFlex silently drops the covariate adjustment when the outcome or treatment column is integer-typedCó thể đã có người làm @vrjdev đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
DoubleML/doubleml-for-py#424 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agentic-dmx docs enhancement
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 86/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
521xueweihan/HelloGitHub#4150 ·