model_copy(deep=True) follows __rune_parent links, producing an attached copy instead of a detached subtree.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 58/100
Hướng nghiên cứu
Start with rune/runtime/cow.py and the BaseDataClass definition, then inspect how model_copy(deep=True) handles dict and PARENT_PROP. Run the included regression test for _clone_for_write and check whether a deep copy omits the parent link while preserving the copied subtree. Done means the clone has no rune parent and deep nested graphs avoid copying their ancestors.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug Report
Steps to Reproduce:
- Build a parent–child object graph (any nested CDM types where fields are
set via normal assignment, which calls _set_rune_parent). - Call a generated Rune function that writes to a nested field — the function
body calls _clone_for_write, which calls value.model_copy(deep=True). - For a graph of depth d, observe O(d²) object allocations; for deep CDM
graphs, observe RecursionError.
Expected Result:
_clone_for_write returns a detached copy with no __rune_parent (the clone is
independent of the original tree).
Actual Result:
model_copy(deep=True) uses copy.deepcopy on dict, which follows the
PARENT_PROP (__rune_parent) pointer up the tree. The clone retains the
original parent reference, and copies of the entire ancestor chain are made.
Environment:
rune-python-runtime 2.2.2, pydantic 2.14.1, Python 3.11
Additional Context:
cow.py _clone_for_write has no special handling for the back-link.
Fix: add a deepcopy override to BaseDataClass that excludes PARENT_PROP
so model_copy(deep=True) produces a detached subtree.
import pytest
import finos._bundle
from finos.cdm.base.staticdata.asset.common.Security import Security
from rune.runtime.cow import _clone_for_write
def test_r3_clone_for_write_copies_rune_parent():
'''_clone_for_write(child) should produce a detached copy with no
rune_parent. Currently model_copy(deep=True) copies the parent link,
so the clone remains attached to the original parent.'''
parent = Security.model_construct()
child = Security.model_construct()
child._set_rune_parent(parent)
assert child.get_rune_parent() is parent # confirm setup
clone = _clone_for_write(child)
# A detached clone must not carry the original parent reference.
# Bug: clone.get_rune_parent() returns the original parent object.
assert clone.get_rune_parent() is None, (
'_clone_for_write should produce a detached copy (no rune_parent); '
f'got {clone.get_rune_parent()}'
)
- Ngôn ngữ chính
- Python
- Star
- 0
- Fork
- 4
- Merge trung bình
- 1 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
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 finos/rune-python-runtime
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
finos/rune-python-runtime#43 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
finos/rune-python-runtime#42 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 62/100
finos/rune-python-runtime#27 ·
-
`typeAlias` missing features.Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
finos/rune-python-runtime#16 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
finos/rune-python-runtime#15 · 1 bình luận ·
Tất cả issue của finos/rune-python-runtime
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
-
[Bug]: Responses API 500s on assistant message with empty content listCó thể đã có người làm @shadowmodder đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
vllm-project/vllm#64940 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
limits
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
agent-ready area: docs documentation good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Soneso/stellar-agent-wallet#524 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Keybind quest outdatedĐang mởStatus: Triage Type: Quest
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
GTNewHorizons/GT-New-Horizons-Modpack#27490 ·
Maintainer thường phản hồi trong vòng 1 ngày