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

ObjectRef.full_path leaves out the store's location for s3, gcs and azure stores

Đang mở Phù hợp với người mới
#1,646 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 4 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu tại objectref.py, ở ObjectRef.full_path, rồi so sánh các đường dẫn s3, gcs và azure với StorageBackend._full_path và nhánh file. Kết quả tái hiện cho thấy các lệnh gọi ref.fs.exists(ref.full_path) và ref.fs.open(ref.full_path) bị lỗi, trong khi ref.read() và ref.fsmap hoạt động. Hoàn tất khi full_path bao gồm vị trí lưu trữ và các lệnh gọi hệ thống tệp này có thể tìm và mở đối tượng.

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

Mô tả

bug

Summary

On an s3, gcs or azure store with a location, ObjectRef.full_path points to a path where the object is not. ref.fs.exists(ref.full_path) returns False and ref.fs.open(ref.full_path) raises FileNotFoundError, although ref.read() returns the object.

The backend stores an object under <bucket>/<location>/<path> (StorageBackend._full_path). full_path builds s3://<bucket>/<path>, and the same for gs:// and az://, without the location. Its docstring says it includes the "bucket/location", and its file branch does add location.

ref.fsmap builds its root with _full_path, so it is not affected. On a store with an empty location, full_path is correct.

Reproduction

DataJoint 2.3.4 and master, MySQL 8.0, MinIO:

import pathlib
import tempfile

import datajoint as dj

dj.config.stores["outbox"] = {
    "protocol": "s3", "endpoint": "localhost:9000", "bucket": "bkt", "location": "proj/outbox",
    "access_key": "datajoint", "secret_key": "datajoint", "secure": False,
}
schema = dj.Schema("scratch_full_path")


@schema
class Result(dj.Manual):
    definition = """
    result_id : int32
    ---
    data : <object@outbox>
    """


src = pathlib.Path(tempfile.mkdtemp()) / "result.txt"
src.write_text("hello")
Result.insert1({"result_id": 1, "data": str(src)})

ref = (Result & {"result_id": 1}).fetch1("data")
ref.read()                       # b'hello'
ref.full_path                    # 's3://bkt/_schema/scratch_full_path/result/result_id=1/data_....txt'
ref.fs.exists(ref.full_path)     # False
ref.fs.exists(ref.fsmap.root)    # True
ref.fs.open(ref.full_path)       # FileNotFoundError

Workaround

Use ref.open(), ref.read() or ref.fsmap instead of ref.fs with ref.full_path.

Expected behavior

full_path includes the store's location, so ref.fs.open(ref.full_path) opens the object. For s3, gcs and azure it could return self._backend.get_url(self.path), which already prefixes the protocol to _full_path.

Where

ObjectRef.full_path in objectref.py.

Ngôn ngữ chính
Python
Star
197
Fork
101
Merge trung bình
3 ngày 8 giờ
Pull request đã merge (30 ngày)
28

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 datajoint/datajoint-python

Tất cả issue của datajoint/datajoint-python

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.