ObjectRef.full_path leaves out the store's location for s3, gcs and azure stores
维护者通常 4 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 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 内容生成。
描述
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 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
datajoint/datajoint-python 的其他 Issue
-
len() of an expression with an empty primary key generates invalid SQL可能已有人在做 @dimitri-yatsenko 于 6 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
datajoint/datajoint-python#1581 ·
维护者通常 4 天内回复
-
dj.Diagram theme: make the font configurable可能已有人在做 @dimitri-yatsenko 于 6 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
datajoint/datajoint-python#1539 · 3 条评论 ·
维护者通常 4 天内回复
-
enhancement
难度 4/5 3-5 天 新手友好度 55/100
datajoint/datajoint-python#1644 · 1 条评论 ·
维护者通常 4 天内回复
-
bug
难度 4/5 1-2 天 新手友好度 68/100
datajoint/datajoint-python#1641 ·
维护者通常 4 天内回复
-
A join on namesake secondary attributes raises the stale-`~lineage` error on a freshly declared schema可能已有人在做 @dimitri-yatsenko 于 6 天前认领。 未关闭bug
难度 3/5 1-2 天 新手友好度 82/100
datajoint/datajoint-python#1640 · 1 条评论 ·
维护者通常 4 天内回复
查看 datajoint/datajoint-python 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
-
bug
难度 2/5 1-3 小时 新手友好度 77/100
AstrBotDevs/AstrBot#10720 ·
维护者通常 1 天内回复
-
cause/upstream comp/cli P2 provider/other tool/file type/bug
难度 2/5 1-3 小时 新手友好度 78/100
NousResearch/hermes-agent#143900 ·
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 85/100
WLAN-Pi/wlanpi-profiler#341 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复