Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭 适合新手
#1,646 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 4 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
backend

调研方向

从 objectref.py 中的 ObjectRef.full_path 开始,然后将其 s3、gcs 和 azure 路径与 StorageBackend._full_path 及 file 分支进行比较。复现结果显示,ref.fs.exists(ref.full_path) 和 ref.fs.open(ref.full_path) 调用失败,而 ref.read() 和 ref.fsmap 可以正常工作。完成条件是 full_path 包含存储位置,并且这些文件系统调用能够找到并打开对象。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Python
星标
197
派生
101
平均合并
3 天 8 小时
30 天内合并 PR
28

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

datajoint/datajoint-python 的其他 Issue

查看 datajoint/datajoint-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。