From 0559aabe80eb1a9cdfa6c3a9f31ece819712cdff Mon Sep 17 00:00:00 2001 From: Carsten Hinz <c.hinz@fz-juelich.de> Date: Tue, 7 May 2024 09:53:10 +0200 Subject: [PATCH] started documenting benchmark.py --- README.md | 3 ++- tests/benchmark.py | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2f04d66..515ff8d 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ The request to the database also allows a statistical analysis of the requested The mean and standard deviation of all stations within a cell are computed. The tool handles the request to the database over the REST API and the subsequent processing. -The results are provided as xarray objects for subsequent processing by the user. +The results of the gridding are provided as xarray objects for subsequent processing by the user. This project is in beta with the intended basic functionalities. The documentation is work in progress. @@ -70,6 +70,7 @@ quality_controll.ipynb ``` Notebook for downloading and visualization of data. The data are downloaded and reused for subsequent executions of this notebook. +The gridding is done on the downloaded data. Gridded data are not saved to disc. # Supported Grids diff --git a/tests/benchmark.py b/tests/benchmark.py index 7390b17..71fb5b4 100644 --- a/tests/benchmark.py +++ b/tests/benchmark.py @@ -16,6 +16,8 @@ TEST_ROOT = Path(__file__).parent def get_toar_response(start, end): + """manual request to the TOAR database + """ end_with_padding = end + timedelta(1) response = requests.get( @@ -35,6 +37,8 @@ def get_toar_response(start, end): def wait_for_data(response): + """waiting for data of a manual request + """ tries = 0 while True: print(f"n tries: {tries}") @@ -53,6 +57,8 @@ def wait_for_data(response): def time_toar_response(start, end): + """benchmark with manual creation of request to TOAR database + """ print(f"starting request for {start}-{end}") timer_start = datetime.now() @@ -64,6 +70,8 @@ def time_toar_response(start, end): def wait_for_client_response(client, sample): + """waiting for response. get_data throws exception after 30min, if results are not available. + """ for half_hours in range(20): try: client.get_data(sample) @@ -74,10 +82,15 @@ def wait_for_client_response(client, sample): def time_rest_client_response(start, end): print(f"starting request for {start}-{end}") + path_cache = TEST_ROOT / "temp_data_cache" + path_data = TEST_ROOT / "temp_data" + path_cache.mkdir(parents=True, exist_ok=True) + path_data.mkdir(parents=True, exist_ok=True) + rest_client = AnalysisServiceDownload( STATISTICS_ENDPOINT, - TEST_ROOT / "temp_data_cache", - TEST_ROOT / "temp_data", + path_cache, + path_data, use_downloaded=False, ) time_window = TimeSample(start, end, SAMPLING) -- GitLab