Skip to content

Commit

Permalink
Merge pull request #113 from znamlab/change_overwrite_mode
Browse files Browse the repository at this point in the history
change update_flexilims to overwrite if conflicts is overwrite
  • Loading branch information
ablot authored Jul 27, 2023
2 parents 68a694f + d8cbad7 commit 34b2ca9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 8 additions & 2 deletions flexiznam/camp/sync_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 34b2ca9

Please sign in to comment.