diff --git a/CHANGELOG.md b/CHANGELOG.md index 9de84ce..053d5f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ of crashing) - `update_flexilims` correctly uploads tuples parameters - `update_flexilims` correctly uploads floats and np.float/np.int parameters +- `update_flexilims` can overwrite existing datasets (if `conflicts='overwrite'`) - Add filelock for token creation to avoid concurrent access and move token to their own file diff --git a/flexiznam/camp/sync_data.py b/flexiznam/camp/sync_data.py index 7051587..d7d331e 100644 --- a/flexiznam/camp/sync_data.py +++ b/flexiznam/camp/sync_data.py @@ -171,6 +171,7 @@ def upload_yaml( list of names of entities created/updated """ + output = [] # if there are errors, I cannot safely parse the yaml errors = find_xxerrorxx(yml_file=source_yaml) @@ -232,12 +233,17 @@ def upload_yaml( root_id = mouse["id"] # session datasets + # use "overwrite" as mode if conflict is "overwrite", otherwise use "safe" mode + if conflicts == "overwrite": + mode = "overwrite" + else: + mode = "safe" for ds_name, ds in session_data.get("datasets", {}).items(): ds.genealogy = [mouse["name"], session_data["session"], ds_name] ds.project = session_data["project"] ds.origin_id = root_id ds.flexilims_session = flexilims_session - ds.update_flexilims(mode="safe") + ds.update_flexilims(mode=mode) output.append(ds.full_name) # now deal with recordings @@ -276,7 +282,7 @@ def upload_yaml( ds.project = session_data["project"] ds.origin_id = rec_rep["id"] ds.flexilims_session = flexilims_session - ds.update_flexilims(mode="safe") + ds.update_flexilims(mode=mode) output.append(ds.full_name) # now deal with samples