Skip to content
Snippets Groups Projects
Commit 29b2b317 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

FIX(sample_upload): Use correct column names in event sanity checks

parent cb62744a
No related branches found
No related tags found
1 merge request!2F sample name
......@@ -85,6 +85,7 @@ def add_event_to_sample(sample: db.Record, data: pd.Series) -> db.Record:
# only add if there was any event data at all:
if len(event.properties) > 0:
sample = update_property(sample, event_rt.id, event, property_name=event_rt.name)
return sample
......@@ -108,39 +109,39 @@ def _create_position(mode: str, lat: float, lng: float, ele: float):
def _perform_sanity_checks(sample, data):
if (get_column_header_name("end_date") in data and
return_value_if_not_none(data[get_column_header_name("end_date")]) is not None):
if (get_column_header_name("start_date") not in data or
return_value_if_not_none(data[get_column_header_name("start_date")]) is None):
if (get_column_header_name("end_date_prop") in data and
return_value_if_not_none(data[get_column_header_name("end_date_prop")]) is not None):
if (get_column_header_name("start_date_prop") not in data or
return_value_if_not_none(data[get_column_header_name("start_date_prop")]) is None):
raise DataInconsistencyError(
f"Sample with {get_entity_name('entity_id')} {sample.id} has a "
f"{get_column_header_name('end_date')} but no valid "
f"{get_column_header_name('start_date')}."
f"{get_column_header_name('end_date_prop')} but no valid "
f"{get_column_header_name('start_date_prop')}."
)
for name in ["start", "stop"]:
bool_list = [get_column_header_name(f"{val}_{name}") in data for val in [
"latitude", "longitude", "elevation"]]
bool_list = [get_column_header_name(f"{val} {name}") in data for val in [
"Latitude", "Longitude", "Elevation"]]
raise_error = False
if any(bool_list):
if not all(bool_list):
raise_error = True
elif any([return_value_if_not_none(data[get_column_header_name(f"{val}_{name}")]) is None for val in ["latitude", "longitude", "elevation"]]):
elif any([return_value_if_not_none(data[get_column_header_name(f"{val} {name}")]) is None for val in ["Latitude", "Longitude", "Elevation"]]):
raise_error = True
if raise_error:
raise DataInconsistencyError(
f"Sample with {get_entity_name('entity_id')} {sample.id} has an "
f"Sample with {get_column_header_name('entity_id')} {sample.id} has an "
f"invalid {name} position. Please make sure that latitude, longitude, "
"and elevation are provided."
)
# only need to check lat since we already checked that if lat is
# present, lng and ele are present, too
if (get_column_header_name("latitude_stop") in data and
return_value_if_not_none(data[get_column_header_name("latitude_stop")]) is not None):
if (get_column_header_name("latitude_start") not in data or
return_value_if_not_none(data[get_column_header_name("latitude_start")]) is not None):
if (get_column_header_name("Latitude stop") in data and
return_value_if_not_none(data[get_column_header_name("Latitude stop")]) is not None):
if (get_column_header_name("Latitude start") not in data or
return_value_if_not_none(data[get_column_header_name("Latitude start")]) is not None):
raise DataInconsistencyError(
f"Sample with {get_entity_name('entity_id')} {sample.id} has a "
f"{get_entity_name('StopPosition')} but no valid "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment