From 59eae8124f67c54bc003e574018fe1214779a4cd Mon Sep 17 00:00:00 2001 From: mflierm Date: Tue, 15 Oct 2024 12:12:52 +0200 Subject: [PATCH] Check for delete_daq if data is on dcache and stbc --- amstrax/auto_processing/delete_live.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/amstrax/auto_processing/delete_live.py b/amstrax/auto_processing/delete_live.py index 2a850e5b..37e6850d 100644 --- a/amstrax/auto_processing/delete_live.py +++ b/amstrax/auto_processing/delete_live.py @@ -90,16 +90,29 @@ def check_data_safety(run_doc, ssh_host, args): num_files = count_files_in_directory(path, run_id, is_remote=(host != 'daq'), ssh_host=ssh_host) log.info(f"Found {num_files} files in {path} on {host} for run {run_id}") result[host] = num_files + + num_files_daq = result['daq'] + log.info(f"File count is {num_files_daq} for run {run_id} on all hosts, safe to delete") + + if 'delete_daq' in run_doc['tags.name']: + if not result['dcache']: + dcache_path = next((d['location'] for d in run_doc['data'] if d['host'] == 'dcache'), None) + result['dcache'] = count_files_in_directory(dcache_path, run_id, is_remote=(host != 'daq'), ssh_host=ssh_host) + + if result['dcache'] == result['stbc']: + log.info(f"Run {run_id} has a delete_daq tag and data exists on dcache and stbc, safe to delete") + return True + + else: + log.info(f"Run {run_id} has a delete_daq tag and data does not exist on dcache and (!) stbc! Not safe to delete") + return False # Check if the file counts match if (result['stbc'] != result.get('dcache', -9) and not args.only_stoomboot) or result['daq'] != result['stbc']: log.warning(f"Mismatch in file count for run {run_id}") return False - - num_files_daq = result['daq'] - log.info(f"File count is {num_files_daq} for run {run_id} on all hosts, safe to delete") - + return True