Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Caching a box resuts in read error

Đang mở
#260 1 bình luận 1 reaction 0 người được giao Xem trên GitHub

@DSeaStar đang làm issue này rồi.

Từ ngày 14/8/2026.

  • #322 của @DSeaStar — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện Python MWE được cung cấp với Box 7.1.1 và joblib 1.3.2, sau đó kiểm tra phần triển khai của Box xung quanh box/box.py:592 và hành vi tuần tự hóa của nó. Công việc được xem là hoàn tất khi một Box được tải bằng joblib vẫn giữ box_dots=True, để việc truy cập các key có dấu chấm hoạt động trở lại, và có một regression test cho lỗi đã được minh họa.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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'

...
Ngôn ngữ chính
Python
Star
2.8k
Fork
145
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của cdgriffith/Box

Tất cả issue của cdgriffith/Box

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.