Parameter loader turns __pycache__ directories into parameter nodes
维护者通常 2 天内回复
评估
调研方向
Read policyengine_core/parameters/parameter_node.py, focusing on the subdirectory branch and the existing EXCLUDED_PARAMETER_CHILD_NAMES checks. Reproduce the issue with a parameter directory containing __pycache__ or a hidden subdirectory, then check the parameter tree excludes both. A linked pull request (#637) is already open.
由索引模型根据 Issue 内容生成。
描述
Problem
ParameterNode(directory_path=...) makes every subdirectory of a parameter directory a child node. EXCLUDED_PARAMETER_CHILD_NAMES in policyengine_core/parameters/parameter_node.py already lists __pycache__, but only the YAML-file branch and the inline-data branch check it. The subdirectory branch does not, so a __pycache__ directory becomes an empty <directory>.__pycache__ node.
Python writes __pycache__ into a parameter directory whenever that directory is also a Python package that gets imported. The loaded parameter tree therefore depends on whether bytecode has been written to disk.
Effect
policyengine-us 2.2.1 has six parameter directories that hold only an __init__.py and CSV files, and US variable modules import them:
gov.hhs.medicaid.geographygov.hud.fmrgov.hud.income_limitsgov.hud.payment_standardsgov.states.fl.doe.sr.rates.reimbursementgov.states.tx.twc.ccs.payment.rates_expanded_age_groups
Without bytecode caches, each of these nodes has no children. With caches, each has one empty __pycache__ child. policyengine.py skips parameter nodes with no children, so its US parameter-node count changes by 6 depending on whether the caches exist: 28,559 without them and 28,565 with them, measured with policyengine-us 2.2.1 and policyengine-core 3.33.3.
The Public API's v2 catalog takes its parameter nodes from policyengine.py. Its exact-count integration test (tests/integration/test_v2_catalog_installed.py) reports 29,361 parameter nodes on macOS with PYTHONDONTWRITEBYTECODE=1 and 29,367 elsewhere. The count follows the files on disk, not the environment variable: once caches have been written, for example by pip install's bytecode compilation or an earlier run, PYTHONDONTWRITEBYTECODE=1 still gives the higher count.
Hidden directories have the same problem. A .ipynb_checkpoints directory inside a parameter directory loads copies of the YAML files next to it as extra parameters, under names that are not valid dotted paths.
Expected
The loaded parameter tree should not depend on bytecode caches or on hidden tool directories. Subdirectories named __pycache__, and hidden subdirectories, should not become parameter nodes.
- 主要语言
- Python
- 星标
- 22
- 派生
- 30
- 平均合并
- 4 天 20 小时
- 30 天内合并 PR
- 26
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
PolicyEngine/policyengine-core 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
PolicyEngine/policyengine-core#605 · 1 条评论 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
PolicyEngine/policyengine-core#549 ·
维护者通常 2 天内回复
-
`restore_simulation` silently drops memberless group entities可能已有人在做 @Adelagric 于 57 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
PolicyEngine/policyengine-core#547 ·
维护者通常 2 天内回复
-
A reform applied after holders exist leaves them on the old variable, so a variable's default depends on who else is in the simulation可能已有人在做 @MaxGhenis 于 1 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 35/100
PolicyEngine/policyengine-core#644 ·
维护者通常 2 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
PolicyEngine/policyengine-core#636 ·
维护者通常 2 天内回复
查看 PolicyEngine/policyengine-core 的全部 Issue
相似的 Issue
-
binding:python bug
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
The Browser tab fails with a Wayland error when Open Terminal runs from a Wayland desktop session未关闭
难度 2/5 1-3 小时 新手友好度 78/100
open-webui/open-terminal#210 ·
-
triage/confirmed
难度 2/5 1-3 小时 新手友好度 78/100
agentscope-ai/agentscope#3807 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
NousResearch/hermes-agent#150542 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 91/100
triton-inference-server/server#9069 ·
维护者通常 1 天内回复