Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Caching a box resuts in read error

オープン
#260 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

@DSeaStar がすでに取り組んでいます。

2026年8月14日 から。

  • #322 @DSeaStar による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
tooling

調査の方向性

まず、提供された Python MWE を Box 7.1.1 および joblib 1.3.2 で再現し、次に box/box.py:592 周辺の Box の実装と、そのシリアライズの挙動を調査します。joblib で読み込んだ Box が box_dots=True を保持し、ドット付きキーへのアクセスが再び機能するようになり、示された失敗に対する回帰テストがある状態が完了です。

索引モデルが issue の本文から書いたものです。

説明

bug

I have a use case where I want to cache boxes and read them back again. Below is a MWE using joblib for caching but I also found it doesn't work Flask caching. I think some metadata is lost when caching the box, so the retrieved box somehow is not a box with box_dots = True.

Code


import box
print(box.__version__)
from box import Box
import joblib
print(joblib.__version__)
b2 = Box(
    {
        "l1": {
            "time_range_selected_utc": {
                "left": "2023-03-01 10:00:00",
                "right": "2023-06-01 10:00:00",
            }
        }
    },
    box_dots=True,
    conversion_box=False,
    frozen_box=False,
)
print(b2.l1.time_range_selected_utc.left)
print(b2["l1.time_range_selected_utc.right"])
print(b2["l1.time_range_selected_utc.left"])

joblib.dump(b2, "boxdump.joblib")

b3 = joblib.load("boxdump.joblib")
print(b3.l1.time_range_selected_utc.left)
print(b3["l1.time_range_selected_utc.right"]) # this will fail
print(b3["l1.time_range_selected_utc.left"])

Output

7.1.1
1.3.2
2023-03-01 10:00:00
2023-06-01 10:00:00
2023-03-01 10:00:00
2023-03-01 10:00:00
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
File [~/opt/miniconda3/envs/om3/lib/python3.9/site-packages/box/box.py:592](https://file+.vscode-resource.vscode-cdn.net/Users/sriki/Documents/cpnet/OmegaMuller/~/opt/miniconda3/envs/om3/lib/python3.9/site-packages/box/box.py:592), in box.box.Box.__getitem__()

KeyError: 'l1.time_range_selected_utc.right'

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
File [~/opt/miniconda3/envs/om3/lib/python3.9/site-packages/box/box.py:592](https://file+.vscode-resource.vscode-cdn.net/Users/sriki/Documents/cpnet/OmegaMuller/~/opt/miniconda3/envs/om3/lib/python3.9/site-packages/box/box.py:592), in box.box.Box.__getitem__()

KeyError: 'time_range_selected_utc.right'

...
主要言語
Python
スター
2.8k
フォーク
145
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

cdgriffith/Box のほかの issue

cdgriffith/Box の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。