From 6cde3c3117108be3af05b6c289479610f847bfbe Mon Sep 17 00:00:00 2001 From: Florian Spreckelsen <f.spreckelsen@indiscale.com> Date: Thu, 6 Feb 2025 18:09:04 +0100 Subject: [PATCH] ENH: Use separate event-adding module --- .../scripting/bin/crawl_sample_data_async.py | 22 ++----------------- .../sample_helpers/sample_upload_get_event.py | 2 +- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/sample-management-custom/caosdb-server/scripting/bin/crawl_sample_data_async.py b/sample-management-custom/caosdb-server/scripting/bin/crawl_sample_data_async.py index e538e64..063b153 100755 --- a/sample-management-custom/caosdb-server/scripting/bin/crawl_sample_data_async.py +++ b/sample-management-custom/caosdb-server/scripting/bin/crawl_sample_data_async.py @@ -47,6 +47,7 @@ from bis_utils import (get_do_not_insert_type_names, return_value_if_not_none, send_mail_with_defaults, SPECIAL_TREATMENT_SAMPLE) +from sample_helpers.sample_upload_get_event import add_event_to_sample from sample_helpers.sample_upload_get_person import get_person from sample_helpers.sample_upload_post_processing import post_process_samples from sample_helpers.utils import get_column_header_name, get_entity_name @@ -383,30 +384,10 @@ def update_sample_records(data, htmluserlog_public): sample = _update_property(entity=sample, property_id=db.get_entity_by_name("PI").id, property_name="PI", value=get_person(row["PI"])) - if "Nagoya case number" in row and return_value_if_not_none(row["Nagoya case number"]) is not None: - sample = _update_property(entity=sample, property_id=nagoya_case_property_id, - property_name="NagoyaCase", - value=get_nagoya_case(row)) if "Storage ID" in row and return_value_if_not_none(row["Storage ID"]) is not None: sample = _update_property(entity=sample, property_id=container_property_id, property_name="Container", value=get_container(row)) - if "Collection" in row and return_value_if_not_none(row["Collection"]) is not None: - sample = _update_property(entity=sample, - property_id=db.get_entity_by_name("Collection").id, - property_name="Collection", - datatype=db.LIST("Collection"), - value=[db.Record(name=el) - .add_parent(name="Collection") - for el in row["Collection"]]) - if "Sphere" in row and return_value_if_not_none(row["Sphere"]) is not None: - sample = _update_property(entity=sample, - property_id=db.get_entity_by_name("Sphere").id, - property_name="Sphere", - datatype=db.LIST("Sphere"), - value=[db.Record(name=el) - .add_parent(name="Sphere") - for el in row["Sphere"]]) if "PDFReport" in data.columns: sample = _update_property( @@ -435,6 +416,7 @@ def update_sample_records(data, htmluserlog_public): entity=sample, property_id=additional_property_ids[property_name], value=value, property_name=property_name) + sample = add_event_to_sample(sample, row) samples.append(sample) samples = post_process_samples(samples, data) diff --git a/sample-management-custom/caosdb-server/scripting/bin/sample_helpers/sample_upload_get_event.py b/sample-management-custom/caosdb-server/scripting/bin/sample_helpers/sample_upload_get_event.py index a149876..aa62498 100644 --- a/sample-management-custom/caosdb-server/scripting/bin/sample_helpers/sample_upload_get_event.py +++ b/sample-management-custom/caosdb-server/scripting/bin/sample_helpers/sample_upload_get_event.py @@ -31,7 +31,7 @@ def add_event_to_sample(sample: db.Record, data: pd.Series) -> db.Record: """ _perform_sanity_checks(sample, data) - + # TODO Add event-specific columns return sample -- GitLab