model_copy(deep=True) follows __rune_parent links, producing an attached copy instead of a detached subtree.
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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()}'
)
- 主要言語
- Python
- スター
- 0
- フォーク
- 4
- 平均マージ
- 1日 17時間
- マージ済み PR(30日)
- 2
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
finos/rune-python-runtime のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
finos/rune-python-runtime#43 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
finos/rune-python-runtime#42 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
finos/rune-python-runtime#27 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
finos/rune-python-runtime#16 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
finos/rune-python-runtime#15 · コメント 1 件 ·
finos/rune-python-runtime の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
BCDA-APS/polar-bits#93 ·
-
infer_audio_type only recognises one MPEG Layer III frame header, so most MP3 files are rejected対応中かも @Steve-20-ai が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
[BUG] - ssh_config `Match tagged` statement always applies対応中かも @AtharvRG が今日担当しました。 オープンBug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
paramiko/paramiko#2715 · コメント 1 件 ·
メンテナーはふだん 9 日以内に返信
-
auto-rejected intake mcp-intake needs-salvage priority:high type:feature
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
Ikalus1988/MisakaNet#4221 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信