Skip to content

Commit 27218d8

Browse files
BenjaminCharmesml-evs
authored andcommitted
Add raw data to .eln
1 parent 1085c0e commit 27218d8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pydatalab/src/pydatalab/export_utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,19 @@ def create_eln_file(collection_id: str, output_path: str) -> None:
153153

154154
if item.get("file_ObjectIds"):
155155
for file_id in item.get("file_ObjectIds", []):
156-
file_data = flask_mongo.db.files.find_one({"_id": ObjectId(file_id)})
156+
file_id_obj = ObjectId(file_id) if isinstance(file_id, str) else file_id
157+
file_data = flask_mongo.db.files.find_one({"_id": file_id_obj})
157158
if file_data:
158159
source_path = Path(file_data["location"])
159160
if source_path.exists():
160161
dest_file = item_folder / file_data["name"]
161162
shutil.copy2(source_path, dest_file)
162163
else:
163164
print(f"Warning: File not found on disk: {file_data['location']}")
165+
else:
166+
print(
167+
f"Warning: File metadata not found in database for file_id: {file_id}"
168+
)
164169

165170
with zipfile.ZipFile(output_path, "w", zipfile.ZIP_DEFLATED) as zipf:
166171
for file_path in root_folder.rglob("*"):

0 commit comments

Comments
 (0)