Skip to content

Commit

Permalink
add exception handling and const string
Browse files Browse the repository at this point in the history
  • Loading branch information
CamronStaley committed Feb 21, 2025
1 parent 60f183b commit 0da0267
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions fiftyone/migrations/revisions/v1_4_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
|
"""

LOG_FILE_SUFFIX = ".log"


def up(db, dataset_name):
_migrate_field_bulk(db, dataset_name, "run_link", "log_path")
Expand All @@ -33,9 +35,15 @@ def _migrate_field_bulk(db, dataset_name, source_field, target_field):
db.delegated_ops.update_many(
{
"dataset_id": dataset_id,
f"{source_field}": {"$regex": "\\.log$", "$exists": True},
f"{source_field}": {
"$regex": f"\\{LOG_FILE_SUFFIX}$",
"$exists": True,
},
},
{"$rename": {f"{source_field}": f"{target_field}"}},
)
except Exception:
return
except Exception as e:
raise RuntimeError(
f"Failed to replace '{target_field}' with '{source_field}' "
f"for dataset '{dataset_name}'. Reason: {e}"
)

0 comments on commit 0da0267

Please sign in to comment.