From 6d6a085481af11a61720d801996d5922c2b843c1 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Wed, 4 Sep 2024 09:40:39 +1200 Subject: [PATCH 1/2] Reinstate test_download_granules_without_subsetting (#581) Ensure that granules can be ordered from NSIDC and downloaded with the `subset=False` option. Also fix a possible race condition in case the NSIDC order status is completed right at the start (e.g. when order was cached/done already). Co-authored-by: Jessica Scheick --- icepyx/core/granules.py | 5 +++ icepyx/tests/test_behind_NSIDC_API_login.py | 47 ++++++++++++++++++--- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/icepyx/core/granules.py b/icepyx/core/granules.py index 37fda87ad..b29a147e1 100644 --- a/icepyx/core/granules.py +++ b/icepyx/core/granules.py @@ -396,6 +396,11 @@ def place_order( status = statuslist[0] print("Initial status of your order request at NSIDC is: ", status) + # If status is already finished without going into pending/processing + if status.startswith("complete"): + loop_response = self.session.get(statusURL) + loop_root = ET.fromstring(loop_response.content) + # Continue loop while request is still processing while status == "pending" or status == "processing": print( diff --git a/icepyx/tests/test_behind_NSIDC_API_login.py b/icepyx/tests/test_behind_NSIDC_API_login.py index b3824030e..f9fb49077 100644 --- a/icepyx/tests/test_behind_NSIDC_API_login.py +++ b/icepyx/tests/test_behind_NSIDC_API_login.py @@ -1,3 +1,8 @@ +""" +Integration tests that require authentication to Earthdata login. +""" + +import glob import json import os @@ -49,8 +54,40 @@ def test_download_granules_with_subsetting(reg, session): reg.download_granules(path) -# def test_download_granules_without_subsetting(reg_a, session): -# path = './downloads' -# reg_a.order_granules(session, subset=False) -# reg_a.download_granules(session, path) -# #check that the max extent of the downloaded granules isn't subsetted +def test_download_granules_without_subsetting(reg, session, capsys): + """ + Test that granules can be ordered from NSIDC and downloaded with the `subset=False` + option. + """ + path = "./downloads" + + reg.order_granules(verbose=False, subset=False, email=False) + out, err = capsys.readouterr() # capture stdout and stderr + assert out.startswith( + "Total number of data order requests is 1 for 3 granules.\n" + "Data request 1 of 1 is submitting to NSIDC\n" + ) + assert err == "" + + assert reg.reqparams == { + "client_string": "icepyx", + "include_meta": "Y", + "page_num": 0, + "page_size": 2000, + "request_mode": "async", + "short_name": "ATL06", + "version": "006", + } + assert len(reg.granules.orderIDs) == 2 + assert int(reg.granules.orderIDs[0]) >= 5_000_000_000_000 + + reg.download_granules(path=path) + # check that there are the right number of files of the correct size + assert len(glob.glob(pathname=f"{path}/ATL06_201902*.iso.xml")) == 3 + h5_paths = sorted(glob.glob(pathname=f"{path}/ATL06_201902*.h5")) + assert len(h5_paths) == 3 + assert [os.path.getsize(filename=p) for p in h5_paths] == [ + 53228429, # 50.8 MiB + 65120027, # 62.1 MiB + 49749227, # 47.4 MiB + ] From 418c9e7f294940831233ec9c3f9b055b4f2d5ca3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Sep 2024 18:00:18 -0400 Subject: [PATCH 2/2] Bump sangonzal/repository-traffic-action from 0.1.5 to 1 in the github-actions group (#596) --- .github/workflows/traffic_action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/traffic_action.yml b/.github/workflows/traffic_action.yml index 48db62741..333ec2d5a 100644 --- a/.github/workflows/traffic_action.yml +++ b/.github/workflows/traffic_action.yml @@ -23,7 +23,7 @@ jobs: # Calculates traffic and clones and stores in CSV file - name: GitHub traffic - uses: sangonzal/repository-traffic-action@v0.1.5 + uses: sangonzal/repository-traffic-action@v1 env: TRAFFIC_ACTION_TOKEN: ${{ secrets.TRAFFIC_ACTION_TOKEN }}