Skip to content

Commit 5512659

Browse files
Remove 'objects' literal from schema-addressed storage paths
- Removed hardcoded 'objects' directory level from build_object_path() - Updated path pattern comment to reflect new structure - Updated all test expectations to match new path format Previous path: {schema}/{table}/objects/{key}/{file} New path: {schema}/{table}/{key}/{file} The 'objects' literal was a legacy remnant intended for future tabular storage alongside objects. Removing it simplifies the path structure and aligns with documented behavior. Verified: - All test_object.py tests pass (43 tests) - All test_npy_codec.py tests pass (22 tests) - All test_hash_storage.py tests pass (14 tests)
1 parent 35a2c60 commit 5512659

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/datajoint/storage.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,12 @@ def build_object_path(
253253
pk_parts.append(f"{attr}={encode_pk_value(value)}")
254254

255255
# Construct full path
256-
# Pattern: {partition_attrs}/{schema}/{table}/objects/{remaining_pk}/{filename}
256+
# Pattern: {partition_attrs}/{schema}/{table}/{remaining_pk}/{filename}
257257
parts = []
258258
if partition_parts:
259259
parts.extend(partition_parts)
260260
parts.append(schema)
261261
parts.append(table)
262-
parts.append("objects")
263262
if pk_parts:
264263
parts.extend(pk_parts)
265264
parts.append(filename)

tests/integration/test_object.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ def test_build_object_path_basic(self):
8383
)
8484
assert "myschema" in path
8585
assert "MyTable" in path
86-
assert "objects" in path
8786
assert "id=123" in path
8887
assert "data_file_" in path
8988
assert path.endswith(".dat")
@@ -134,7 +133,7 @@ def test_from_json_string(self):
134133
"""Test creating ObjectRef from JSON string."""
135134
json_str = json.dumps(
136135
{
137-
"path": "schema/Table/objects/id=1/data_abc123.dat",
136+
"path": "schema/Table/id=1/data_abc123.dat",
138137
"size": 1024,
139138
"hash": None,
140139
"ext": ".dat",
@@ -143,7 +142,7 @@ def test_from_json_string(self):
143142
}
144143
)
145144
obj = ObjectRef.from_json(json_str)
146-
assert obj.path == "schema/Table/objects/id=1/data_abc123.dat"
145+
assert obj.path == "schema/Table/id=1/data_abc123.dat"
147146
assert obj.size == 1024
148147
assert obj.hash is None
149148
assert obj.ext == ".dat"
@@ -152,7 +151,7 @@ def test_from_json_string(self):
152151
def test_from_json_dict(self):
153152
"""Test creating ObjectRef from dict."""
154153
data = {
155-
"path": "schema/Table/objects/id=1/data_abc123.zarr",
154+
"path": "schema/Table/id=1/data_abc123.zarr",
156155
"size": 5678,
157156
"hash": None,
158157
"ext": ".zarr",
@@ -161,23 +160,23 @@ def test_from_json_dict(self):
161160
"item_count": 42,
162161
}
163162
obj = ObjectRef.from_json(data)
164-
assert obj.path == "schema/Table/objects/id=1/data_abc123.zarr"
163+
assert obj.path == "schema/Table/id=1/data_abc123.zarr"
165164
assert obj.size == 5678
166165
assert obj.is_dir is True
167166
assert obj.item_count == 42
168167

169168
def test_from_json_zarr_style(self):
170169
"""Test creating ObjectRef from Zarr-style JSON with null size."""
171170
data = {
172-
"path": "schema/Recording/objects/id=1/neural_data_abc123.zarr",
171+
"path": "schema/Recording/id=1/neural_data_abc123.zarr",
173172
"size": None,
174173
"hash": None,
175174
"ext": ".zarr",
176175
"is_dir": True,
177176
"timestamp": "2025-01-15T10:30:00+00:00",
178177
}
179178
obj = ObjectRef.from_json(data)
180-
assert obj.path == "schema/Recording/objects/id=1/neural_data_abc123.zarr"
179+
assert obj.path == "schema/Recording/id=1/neural_data_abc123.zarr"
181180
assert obj.size is None
182181
assert obj.hash is None
183182
assert obj.ext == ".zarr"
@@ -189,15 +188,15 @@ def test_to_json(self):
189188
from datetime import datetime, timezone
190189

191190
obj = ObjectRef(
192-
path="schema/Table/objects/id=1/data.dat",
191+
path="schema/Table/id=1/data.dat",
193192
size=1024,
194193
hash=None,
195194
ext=".dat",
196195
is_dir=False,
197196
timestamp=datetime(2025, 1, 15, 10, 30, tzinfo=timezone.utc),
198197
)
199198
data = obj.to_json()
200-
assert data["path"] == "schema/Table/objects/id=1/data.dat"
199+
assert data["path"] == "schema/Table/id=1/data.dat"
201200
assert data["size"] == 1024
202201
assert data["is_dir"] is False
203202

0 commit comments

Comments
 (0)