Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging persists when 'quiet' parameter is reverted from True to False in Client class #82

Open
evteevakb opened this issue Oct 5, 2023 · 0 comments · May be fixed by #83
Open

Logging persists when 'quiet' parameter is reverted from True to False in Client class #82

evteevakb opened this issue Oct 5, 2023 · 0 comments · May be fixed by #83
Labels
bug Something isn't working

Comments

@evteevakb
Copy link

What happened?

As I understand, in the cdsapi.Client class, the quiet parameter is designed to control the logging behavior. When set to True, the class should not print logs, and when set to False, it should print logs. However, there is a specific scenario where the logging continues even after changing the quiet parameter from True back to False.

Expected Behavior:
When the quiet parameter is set to True, logging should be suppressed. When the quiet parameter is set to False, logs should be printed. The logging behavior should correctly reflect the value of the quiet parameter at all times.

Actual Behavior:
Logs continue to be printed even when the quiet parameter is set to False after a previous setting of True.

Proposed Solution:
I have identified the root cause of this issue and have a patch ready to resolve it. I will submit a PR shortly.

What are the steps to reproduce the bug?

  1. Set quiet parameter to True.
  2. Perform actions using the cdsapi.Client class.
  3. Change the quiet parameter back to False.
  4. Observe that logs are still being printed, even though quiet is now False.

I have used the following piece of code to reproduce this behavior:

import cdsapi

test_request = {
    "format": "netcdf",
    "area": [54.38114355887211, 106.45068311010317, 53.440375558872105, 107.39145111010319],
    "variable": ["10m_u_component_of_wind", "10m_v_component_of_wind",
                 "2m_temperature", "total_precipitation"],
    "year": 2022,
    "month": [5],
    "day": list(range(6, 10)),
    "time": ["00:00", "03:00", "06:00", "09:00", "12:00", "15:00", "18:00", "21:00"]
    }


def test_logs(quiet: bool):
    print(f"QUIET: {quiet}")
    cds_client = cdsapi.Client(quiet=quiet)
    cds_client.retrieve(
        name="reanalysis-era5-land",
        request=test_request,
        target="./cds_test.nc")


test_logs(quiet=True)
test_logs(quiet=False)
test_logs(quiet=True)
test_logs(quiet=False)

Version

v0.6.1

Platform (OS and architecture)

Windows 11 Home (22H2 version, 64-bit)

Relevant log output

QUIET: True

QUIET: False
2023-10-05 16:21:23,692 INFO Welcome to the CDS
2023-10-05 16:21:23,692 INFO Sending request to https://cds.climate.copernicus.eu/api/v2/resources/reanalysis-era5-land
2023-10-05 16:21:23,773 INFO Request is queued
2023-10-05 16:21:24,849 INFO Request is completed
2023-10-05 16:21:24,849 INFO Downloading https://download-0012-clone.copernicus-climate.eu/cache-compute-0012/cache/data0/adaptor.mars.internal-1696501013.798142-21806-11-09e10a51-2661-43a7-9100-13c4f5256cca.nc to ./cds_test.nc (27K)
2023-10-05 16:21:25,008 INFO Download rate 168.8K/s

QUIET: True
2023-10-05 16:21:25,155 INFO Welcome to the CDS
2023-10-05 16:21:25,155 INFO Sending request to https://cds.climate.copernicus.eu/api/v2/resources/reanalysis-era5-land
2023-10-05 16:21:25,256 INFO Request is queued
2023-10-05 16:21:26,334 INFO Request is completed
2023-10-05 16:21:26,334 INFO Downloading https://download-0012-clone.copernicus-climate.eu/cache-compute-0012/cache/data0/adaptor.mars.internal-1696501013.798142-21806-11-09e10a51-2661-43a7-9100-13c4f5256cca.nc to ./cds_test.nc (27K)
2023-10-05 16:21:26,488 INFO Download rate 175.8K/s

QUIET: False
2023-10-05 16:21:26,642 INFO Welcome to the CDS
2023-10-05 16:21:26,658 INFO Sending request to https://cds.climate.copernicus.eu/api/v2/resources/reanalysis-era5-land
2023-10-05 16:21:26,766 INFO Request is queued
2023-10-05 16:21:27,836 INFO Request is completed
2023-10-05 16:21:27,851 INFO Downloading https://download-0012-clone.copernicus-climate.eu/cache-compute-0012/cache/data0/adaptor.mars.internal-1696501013.798142-21806-11-09e10a51-2661-43a7-9100-13c4f5256cca.nc to ./cds_test.nc (27K)
2023-10-05 16:21:28,002 INFO Download rate 180.6K/s

Accompanying data

No response

Organisation

No response

@evteevakb evteevakb added the bug Something isn't working label Oct 5, 2023
evteevakb pushed a commit to evteevakb/cdsapi that referenced this issue Oct 5, 2023
@evteevakb evteevakb linked a pull request Oct 5, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant