Skip to content

Commit 6ef4548

Browse files
dsblankDouglas Blankclaude
authored
Fix model-element assets getting duplicated directory on copy (#18)
When copying model-element assets, log_model() was called with the file's basename as the model name (e.g., "model.onnx"), causing a duplicate folder structure like model.onnx/model.onnx. Instead, use _log_asset() directly with the correct grouping_name extracted from the asset's "dir" metadata field, stripping the "models/" prefix that the backend adds automatically. Co-authored-by: Douglas Blank <doug@comet.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4865340 commit 6ef4548

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

cometx/cli/copy.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,10 +1356,27 @@ def _log_asset(
13561356
else:
13571357
asset_map[old_asset_id] = result["assetId"]
13581358
elif asset_type == "model-element":
1359-
name = os.path.basename(filename)
1360-
result = experiment.log_model(name, filename)
1359+
dir_name = assets_metadata[log_filename].get("dir", "")
1360+
# The dir field includes a "models/" prefix added by the
1361+
# backend; strip it to get the actual model name.
1362+
if dir_name.startswith("models/"):
1363+
model_name = dir_name[len("models/"):]
1364+
else:
1365+
model_name = dir_name
1366+
binary_io = open(filename, "rb")
1367+
result = experiment._log_asset(
1368+
binary_io,
1369+
file_name=log_as_filename or log_filename,
1370+
copy_to_tmp=True,
1371+
asset_type=asset_type,
1372+
metadata=metadata,
1373+
step=step,
1374+
grouping_name=model_name,
1375+
)
13611376
if result is None:
1362-
print(f"ERROR: Unable to log {asset_type} asset {name}; skipping")
1377+
print(
1378+
f"ERROR: Unable to log {asset_type} asset {log_as_filename or log_filename}; skipping"
1379+
)
13631380
else:
13641381
asset_map[old_asset_id] = result["assetId"]
13651382
else:

0 commit comments

Comments
 (0)