From 0da72781811f09dfaa272e46b65ff889abdd940c Mon Sep 17 00:00:00 2001 From: Moritz Makowski Date: Tue, 26 Dec 2023 06:44:11 +0000 Subject: [PATCH] Do not request data from std sites (8) Sort queries and improve prints --- src/profiles/generate_queries.py | 5 +++-- src/profiles/upload_logic.py | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/profiles/generate_queries.py b/src/profiles/generate_queries.py index c8e91780..d2c4dd94 100644 --- a/src/profiles/generate_queries.py +++ b/src/profiles/generate_queries.py @@ -173,7 +173,8 @@ def remove_std_site_data( set[datetime.date]] = copy.deepcopy(missing_data) for std_site_config in config.profiles.GGG2020_standard_sites: location = ProfilesQueryLocation( - lat=std_site_config.lat, lon=std_site_config.lon + lat=round(std_site_config.lat), + lon=round(std_site_config.lon), ) if location in filtered_data.keys(): filtered_data[location].difference_update( @@ -257,4 +258,4 @@ def generate_download_queries( ) for tp in compute_time_periods(dates) ]) - return download_queries + return sorted(download_queries, key=lambda q: q.from_date) diff --git a/src/profiles/upload_logic.py b/src/profiles/upload_logic.py index b696a018..e13dad27 100644 --- a/src/profiles/upload_logic.py +++ b/src/profiles/upload_logic.py @@ -76,6 +76,7 @@ def upload_requests( # job every minute, so we need to wait for the cron job to # finish before we can upload the next request request_time = (t2 - t1) - if request_time < 65: - progress.print(f"Sleeping for {65 - request_time} seconds") - time.sleep(65 - request_time) + sleep_time = max(round(65 - request_time, 3), 0) + if sleep_time > 0: + progress.print(f"Sleeping for {sleep_time} seconds") + time.sleep(sleep_time)