From 3429a0721c89a1842d2c3f334ad1ae3d40e0c098 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 Feb 2024 03:18:29 +0000 Subject: [PATCH 01/21] Bump pypa/gh-action-pypi-publish from 1.8.11 to 1.8.12 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.11 to 1.8.12. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.8.11...v1.8.12) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/distribute.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/distribute.yml b/.github/workflows/distribute.yml index 80beefc..a58a769 100644 --- a/.github/workflows/distribute.yml +++ b/.github/workflows/distribute.yml @@ -29,7 +29,7 @@ jobs: python -m build - name: upload to PyPI.org - uses: pypa/gh-action-pypi-publish@v1.8.11 + uses: pypa/gh-action-pypi-publish@v1.8.12 with: user: __token__ password: ${{ secrets.TOOLS_PYPI_PAK }} From 861a67643e8b5c5488c6262fe7bd10263895d797 Mon Sep 17 00:00:00 2001 From: Joseph H Kennedy Date: Wed, 28 Feb 2024 11:26:03 -0900 Subject: [PATCH 02/21] Drop verify step for PyPI distribution --- .github/workflows/distribute.yml | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/.github/workflows/distribute.yml b/.github/workflows/distribute.yml index 80beefc..8a7ae02 100644 --- a/.github/workflows/distribute.yml +++ b/.github/workflows/distribute.yml @@ -33,22 +33,3 @@ jobs: with: user: __token__ password: ${{ secrets.TOOLS_PYPI_PAK }} - - verify-distribution: - runs-on: ubuntu-latest - needs: - - call-version-info-workflow - - distribute - defaults: - run: - shell: bash -l {0} - steps: - - uses: actions/checkout@v4 - - - uses: mamba-org/setup-micromamba@v1 - with: - environment-file: environment.yml - - - name: Ensure hyp3_sdk v${{ needs.call-version-info-workflow.outputs.version }}} is pip installable - run: | - python -m pip install hyp3_sdk==${{ needs.call-version-info-workflow.outputs.version_tag }} From 8da85d5704d1584b0fae910748dd712f9046784b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Mar 2024 03:38:39 +0000 Subject: [PATCH 03/21] Bump pypa/gh-action-pypi-publish from 1.8.12 to 1.8.14 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.12 to 1.8.14. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.8.12...v1.8.14) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/distribute.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/distribute.yml b/.github/workflows/distribute.yml index f14c2c8..00323de 100644 --- a/.github/workflows/distribute.yml +++ b/.github/workflows/distribute.yml @@ -29,7 +29,7 @@ jobs: python -m build - name: upload to PyPI.org - uses: pypa/gh-action-pypi-publish@v1.8.12 + uses: pypa/gh-action-pypi-publish@v1.8.14 with: user: __token__ password: ${{ secrets.TOOLS_PYPI_PAK }} From 1712171cdee94381f8890322cb999ab755202a5b Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Mon, 22 Apr 2024 10:56:06 -0800 Subject: [PATCH 04/21] add priority --- src/hyp3_sdk/jobs.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hyp3_sdk/jobs.py b/src/hyp3_sdk/jobs.py index 5a6a09d..3e11548 100644 --- a/src/hyp3_sdk/jobs.py +++ b/src/hyp3_sdk/jobs.py @@ -32,6 +32,7 @@ def __init__( expiration_time: Optional[datetime] = None, processing_times: Optional[List[float]] = None, credit_cost: Optional[float] = None, + priority: Optional[int] = None, ): self.job_id = job_id self.job_type = job_type @@ -47,6 +48,7 @@ def __init__( self.expiration_time = expiration_time self.processing_times = processing_times self.credit_cost = credit_cost + self.priority = priority def __repr__(self): return f'Job.from_dict({self.to_dict()})' @@ -75,6 +77,7 @@ def from_dict(input_dict: dict): expiration_time=expiration_time, processing_times=input_dict.get('processing_times'), credit_cost=input_dict.get('credit_cost'), + priority=input_dict.get('priority'), ) def to_dict(self, for_resubmit: bool = False): From df8ef8c865ee7c42c4045509a20ab18f087a1130 Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Mon, 22 Apr 2024 11:08:44 -0800 Subject: [PATCH 05/21] update tests --- tests/conftest.py | 1 + tests/test_jobs.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index fdb2895..fa693da 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -22,6 +22,7 @@ def default_job( thumbnail_images=None, expiration_time=None, credit_cost=None, + priority=None, ): if job_parameters is None: job_parameters = {'param1': 'value1'} diff --git a/tests/test_jobs.py b/tests/test_jobs.py index 02c2640..e679e79 100644 --- a/tests/test_jobs.py +++ b/tests/test_jobs.py @@ -25,6 +25,7 @@ "thumbnail_images": ["https://PAIR_PROCESS_thumb.png"], "user_id": "asf_hyp3", "credit_cost": 1, + "priority": 9999, } FAILED_JOB = { @@ -42,6 +43,7 @@ "status_code": "FAILED", "user_id": "asf_hyp3", "credit_cost": 1, + "priority": 9999, } From 0acf3a1cfda1c6bce0530ce165587c993a750e7f Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Mon, 22 Apr 2024 11:15:56 -0800 Subject: [PATCH 06/21] changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bfd7a6..b8f866a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/) and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [6.2.0] + +### Added +* `Job.priority` attribute + ## [6.1.0] ### Added From 91e70bc63bde284dbdc4f29d67d2c47c6f9d4b00 Mon Sep 17 00:00:00 2001 From: Andrew Johnston Date: Tue, 30 Apr 2024 10:57:20 -0800 Subject: [PATCH 07/21] Update dependabot.yml to weekly --- .github/dependabot.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f2494b1..82990ed 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,8 +1,13 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + version: 2 updates: - - package-ecosystem: "github-actions" - directory: "/" + - package-ecosystem: github-actions + directory: / schedule: - interval: "daily" + interval: weekly labels: - - "bumpless" + - bumpless From 3527ebc160105301a48af498399859cc4cac2132 Mon Sep 17 00:00:00 2001 From: jacquelynsmale Date: Mon, 13 May 2024 15:53:20 -0800 Subject: [PATCH 08/21] first commit --- src/hyp3_sdk/hyp3.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/hyp3_sdk/hyp3.py b/src/hyp3_sdk/hyp3.py index 4f653cc..e94c74c 100644 --- a/src/hyp3_sdk/hyp3.py +++ b/src/hyp3_sdk/hyp3.py @@ -46,6 +46,13 @@ def __init__(self, api_url: str = PROD_API, username: Optional[str] = None, pass self.session = hyp3_sdk.util.get_authenticated_session(username, password) self.session.headers.update({'User-Agent': f'{hyp3_sdk.__name__}/{hyp3_sdk.__version__}'}) + self._check_application_status() + + def _check_application_status(self) -> None: + info = self.my_info() + if info['application_status'] != 'APPROVED': + warnings.warn(f'User {info["user_id"]} has not yet applied for a monthly credit allotment.' + ' Please visit to submit your application.') def find_jobs(self, start: Optional[datetime] = None, From aecdf926094bd8314b84bea2d208a40905bc46e1 Mon Sep 17 00:00:00 2001 From: jacquelynsmale Date: Mon, 13 May 2024 16:26:00 -0800 Subject: [PATCH 09/21] add in check_app_status test --- tests/test_hyp3.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_hyp3.py b/tests/test_hyp3.py index e1cb2cb..132f883 100644 --- a/tests/test_hyp3.py +++ b/tests/test_hyp3.py @@ -439,6 +439,23 @@ def test_check_credits(): assert math.isclose(api.check_credits(), 25.) +@responses.activate +def test_check_application_status(): + api_response = { + 'application_status': 'APPROVED', + 'job_names': [ + 'name1', + 'name2' + ], + 'remaining_credits': 25., + 'user_id': 'someUser' + } + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() + responses.add(responses.GET, urljoin(api.url, '/user'), json=api_response) + response = api.my_info() + assert response == api_response + @responses.activate def test_costs(): api_response = {'foo': 5} From bf0befd755aa84c1a9f267de2cb2b29dc15a0d38 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Tue, 14 May 2024 13:17:27 -0500 Subject: [PATCH 10/21] fixed tests to work with _check_application_status --- tests/test_hyp3.py | 130 +++++++++++++++++++++++++++------------------ 1 file changed, 77 insertions(+), 53 deletions(-) diff --git a/tests/test_hyp3.py b/tests/test_hyp3.py index 132f883..7bf5c54 100644 --- a/tests/test_hyp3.py +++ b/tests/test_hyp3.py @@ -11,14 +11,18 @@ from hyp3_sdk import HyP3, Job +def mock_my_info(self): + return {'application_status': 'APPROVED'} + def mock_get_authenticated_session(username, password): return requests.Session() @responses.activate def test_session_headers(): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() responses.add(responses.GET, urljoin(api.url, '/user'), json={'foo': 'bar'}) @@ -42,8 +46,9 @@ def test_find_jobs(get_mock_job): ] } - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() responses.add(responses.GET, urljoin(api.url, '/jobs'), json=api_response_mock) responses.add(responses.GET, urljoin(api.url, '/jobs'), json={'jobs': []}) @@ -57,8 +62,9 @@ def test_find_jobs(get_mock_job): @responses.activate def test_find_jobs_paging(get_mock_job): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() api_response_mock_1 = { 'jobs': [ @@ -84,8 +90,9 @@ def test_find_jobs_paging(get_mock_job): @responses.activate def test_find_jobs_user_id(get_mock_job): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() responses.add(responses.GET, urljoin(api.url, '/jobs?user_id=foo'), json={'jobs': []}, match_querystring=True) @@ -102,8 +109,9 @@ def test_find_jobs_user_id(get_mock_job): @responses.activate def test_find_jobs_start(): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() responses.add(responses.GET, urljoin(api.url, '/jobs?start=2021-01-01T00%3A00%3A00%2B00%3A00'), json={'jobs': []}, match_querystring=True) @@ -117,8 +125,9 @@ def test_find_jobs_start(): @responses.activate def test_find_jobs_end(): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() responses.add(responses.GET, urljoin(api.url, '/jobs?end=2021-01-02T00%3A00%3A00%2B00%3A00'), json={'jobs': []}, match_querystring=True) @@ -132,8 +141,9 @@ def test_find_jobs_end(): @responses.activate def test_find_jobs_status_code(): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() responses.add(responses.GET, urljoin(api.url, '/jobs?status_code=RUNNING'), json={'jobs': []}, match_querystring=True) @@ -149,8 +159,9 @@ def test_find_jobs_status_code(): @responses.activate def test_get_job_by_id(get_mock_job): job = get_mock_job() - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() responses.add(responses.GET, urljoin(api.url, f'/jobs/{job.job_id}'), json=job.to_dict()) response = api.get_job_by_id(job.job_id) assert response == job @@ -161,8 +172,9 @@ def test_watch(get_mock_job): incomplete_job = get_mock_job() complete_job = Job.from_dict(incomplete_job.to_dict()) complete_job.status_code = 'SUCCEEDED' - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() for ii in range(3): responses.add(responses.GET, urljoin(api.url, f'/jobs/{incomplete_job.job_id}'), json=incomplete_job.to_dict()) @@ -179,8 +191,9 @@ def test_refresh(get_mock_job): new_job = Job.from_dict(job.to_dict()) new_job.status_code = 'SUCCEEDED' - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() responses.add(responses.GET, urljoin(api.url, f'/jobs/{job.job_id}'), json=new_job.to_dict()) response = api.refresh(job) @@ -198,8 +211,9 @@ def test_submit_prepared_jobs(get_mock_job): ] } - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() responses.add(responses.POST, urljoin(api.url, '/jobs'), json=api_response) @@ -338,8 +352,9 @@ def test_submit_autorift_job(get_mock_job): job.to_dict() ] } - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() responses.add(responses.POST, urljoin(api.url, '/jobs'), json=api_response) batch = api.submit_autorift_job('g1', 'g2') assert batch.jobs[0] == job @@ -353,8 +368,9 @@ def test_submit_rtc_job(get_mock_job): job.to_dict() ] } - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() responses.add(responses.POST, urljoin(api.url, '/jobs'), json=api_response) batch = api.submit_rtc_job('g1') assert batch.jobs[0] == job @@ -368,8 +384,9 @@ def test_submit_insar_job(get_mock_job): job.to_dict() ] } - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() responses.add(responses.POST, urljoin(api.url, '/jobs'), json=api_response) batch = api.submit_insar_job('g1', 'g2') assert batch.jobs[0] == job @@ -383,8 +400,9 @@ def test_submit_insar_isce_burst_job(get_mock_job): job.to_dict() ] } - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() responses.add(responses.POST, urljoin(api.url, '/jobs'), json=api_response) batch = api.submit_insar_isce_burst_job('g1', 'g2') assert batch.jobs[0] == job @@ -398,8 +416,9 @@ def test_resubmit_previous_job(get_mock_job): job.to_dict() ] } - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() responses.add(responses.POST, urljoin(api.url, '/jobs'), json=api_response) batch = api.submit_prepared_jobs(job.to_dict(for_resubmit=True)) assert batch.jobs[0] == job @@ -415,8 +434,9 @@ def test_my_info(): 'remaining_credits': 25., 'user_id': 'someUser' } - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() responses.add(responses.GET, urljoin(api.url, '/user'), json=api_response) response = api.my_info() assert response == api_response @@ -432,35 +452,39 @@ def test_check_credits(): 'remaining_credits': 25., 'user_id': 'someUser' } - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() responses.add(responses.GET, urljoin(api.url, '/user'), json=api_response) assert math.isclose(api.check_credits(), 25.) @responses.activate -def test_check_application_status(): - api_response = { - 'application_status': 'APPROVED', - 'job_names': [ - 'name1', - 'name2' - ], - 'remaining_credits': 25., - 'user_id': 'someUser' - } - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() - responses.add(responses.GET, urljoin(api.url, '/user'), json=api_response) - response = api.my_info() - assert response == api_response +def test_check_application_status_approved(): + with warnings.catch_warnings(record=True) as w: + with patch('hyp3_sdk.hyp3.HyP3.my_info', lambda x: {'user_id': 'someUser', 'application_status': 'APPROVED'}): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() + assert len(w) == 0 + + +@responses.activate +def test_check_application_status_not_approved(): + with warnings.catch_warnings(record=True) as w: + with patch('hyp3_sdk.hyp3.HyP3.my_info', lambda x: {'user_id': 'someUser', 'application_status': 'PENDING'}): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() + assert len(w) == 1 + assert 'not yet applied for a monthly credit allotment' in str(w[0].message) + @responses.activate def test_costs(): api_response = {'foo': 5} - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + api = HyP3() responses.add(responses.GET, urljoin(api.url, '/costs'), json=api_response) assert api.costs() == {'foo': 5} From 2d830083e07d4079986105513b335c816150ec65 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Tue, 14 May 2024 13:18:48 -0500 Subject: [PATCH 11/21] flake8 --- tests/test_hyp3.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_hyp3.py b/tests/test_hyp3.py index 7bf5c54..bea80ac 100644 --- a/tests/test_hyp3.py +++ b/tests/test_hyp3.py @@ -14,6 +14,7 @@ def mock_my_info(self): return {'application_status': 'APPROVED'} + def mock_get_authenticated_session(username, password): return requests.Session() @@ -465,7 +466,7 @@ def test_check_application_status_approved(): with warnings.catch_warnings(record=True) as w: with patch('hyp3_sdk.hyp3.HyP3.my_info', lambda x: {'user_id': 'someUser', 'application_status': 'APPROVED'}): with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + _ = HyP3() assert len(w) == 0 @@ -474,7 +475,7 @@ def test_check_application_status_not_approved(): with warnings.catch_warnings(record=True) as w: with patch('hyp3_sdk.hyp3.HyP3.my_info', lambda x: {'user_id': 'someUser', 'application_status': 'PENDING'}): with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + _ = HyP3() assert len(w) == 1 assert 'not yet applied for a monthly credit allotment' in str(w[0].message) From 0984f6a79a32bc519f6c539a31c10f7a79446e5f Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Tue, 14 May 2024 13:48:07 -0500 Subject: [PATCH 12/21] added hyp3 instance as fixture --- tests/conftest.py | 16 ++++++ tests/test_hyp3.py | 124 +++++++++++++++------------------------------ 2 files changed, 58 insertions(+), 82 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index fdb2895..ceaaa0e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,11 +1,27 @@ +import requests import shutil from datetime import datetime from pathlib import Path +from unittest.mock import patch from uuid import uuid4 import pytest from hyp3_sdk import Job +from hyp3_sdk.hyp3 import HyP3 + + +@pytest.fixture(autouse=True) +def get_mock_hyp3(): + def mock_my_info(self): + return {'application_status': 'APPROVED'} + def mock_get_authenticated_session(username, password): + return requests.Session() + def default_hyp3(): + with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): + with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + return HyP3() + return default_hyp3 @pytest.fixture(autouse=True) diff --git a/tests/test_hyp3.py b/tests/test_hyp3.py index bea80ac..7c19568 100644 --- a/tests/test_hyp3.py +++ b/tests/test_hyp3.py @@ -20,10 +20,8 @@ def mock_get_authenticated_session(username, password): @responses.activate -def test_session_headers(): - with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() +def test_session_headers(get_mock_hyp3): + api = get_mock_hyp3() responses.add(responses.GET, urljoin(api.url, '/user'), json={'foo': 'bar'}) @@ -35,7 +33,7 @@ def test_session_headers(): @responses.activate -def test_find_jobs(get_mock_job): +def test_find_jobs(get_mock_hyp3, get_mock_job): api_response_mock = { 'jobs': [ get_mock_job(name='job1').to_dict(), @@ -47,9 +45,7 @@ def test_find_jobs(get_mock_job): ] } - with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + api = get_mock_hyp3() responses.add(responses.GET, urljoin(api.url, '/jobs'), json=api_response_mock) responses.add(responses.GET, urljoin(api.url, '/jobs'), json={'jobs': []}) @@ -62,10 +58,8 @@ def test_find_jobs(get_mock_job): @responses.activate -def test_find_jobs_paging(get_mock_job): - with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() +def test_find_jobs_paging(get_mock_hyp3, get_mock_job): + api = get_mock_hyp3() api_response_mock_1 = { 'jobs': [ @@ -90,10 +84,8 @@ def test_find_jobs_paging(get_mock_job): @responses.activate -def test_find_jobs_user_id(get_mock_job): - with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() +def test_find_jobs_user_id(get_mock_hyp3, get_mock_job): + api = get_mock_hyp3() responses.add(responses.GET, urljoin(api.url, '/jobs?user_id=foo'), json={'jobs': []}, match_querystring=True) @@ -109,10 +101,8 @@ def test_find_jobs_user_id(get_mock_job): @responses.activate -def test_find_jobs_start(): - with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() +def test_find_jobs_start(get_mock_hyp3): + api = get_mock_hyp3() responses.add(responses.GET, urljoin(api.url, '/jobs?start=2021-01-01T00%3A00%3A00%2B00%3A00'), json={'jobs': []}, match_querystring=True) @@ -125,10 +115,8 @@ def test_find_jobs_start(): @responses.activate -def test_find_jobs_end(): - with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() +def test_find_jobs_end(get_mock_hyp3): + api = get_mock_hyp3() responses.add(responses.GET, urljoin(api.url, '/jobs?end=2021-01-02T00%3A00%3A00%2B00%3A00'), json={'jobs': []}, match_querystring=True) @@ -141,10 +129,8 @@ def test_find_jobs_end(): @responses.activate -def test_find_jobs_status_code(): - with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() +def test_find_jobs_status_code(get_mock_hyp3): + api = get_mock_hyp3() responses.add(responses.GET, urljoin(api.url, '/jobs?status_code=RUNNING'), json={'jobs': []}, match_querystring=True) @@ -158,24 +144,20 @@ def test_find_jobs_status_code(): @responses.activate -def test_get_job_by_id(get_mock_job): +def test_get_job_by_id(get_mock_hyp3, get_mock_job): job = get_mock_job() - with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + api = get_mock_hyp3() responses.add(responses.GET, urljoin(api.url, f'/jobs/{job.job_id}'), json=job.to_dict()) response = api.get_job_by_id(job.job_id) assert response == job @responses.activate -def test_watch(get_mock_job): +def test_watch(get_mock_hyp3, get_mock_job): incomplete_job = get_mock_job() complete_job = Job.from_dict(incomplete_job.to_dict()) complete_job.status_code = 'SUCCEEDED' - with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + api = get_mock_hyp3() for ii in range(3): responses.add(responses.GET, urljoin(api.url, f'/jobs/{incomplete_job.job_id}'), json=incomplete_job.to_dict()) @@ -187,14 +169,12 @@ def test_watch(get_mock_job): @responses.activate -def test_refresh(get_mock_job): +def test_refresh(get_mock_hyp3, get_mock_job): job = get_mock_job() new_job = Job.from_dict(job.to_dict()) new_job.status_code = 'SUCCEEDED' - with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + api = get_mock_hyp3() responses.add(responses.GET, urljoin(api.url, f'/jobs/{job.job_id}'), json=new_job.to_dict()) response = api.refresh(job) @@ -202,7 +182,7 @@ def test_refresh(get_mock_job): @responses.activate -def test_submit_prepared_jobs(get_mock_job): +def test_submit_prepared_jobs(get_mock_hyp3, get_mock_job): rtc_job = get_mock_job('RTC_GAMMA', job_parameters={'granules': ['g1']}) insar_job = get_mock_job('INSAR_GAMMA', job_parameters={'granules': ['g1', 'g2']}) api_response = { @@ -212,9 +192,7 @@ def test_submit_prepared_jobs(get_mock_job): ] } - with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + api = get_mock_hyp3() responses.add(responses.POST, urljoin(api.url, '/jobs'), json=api_response) @@ -346,87 +324,77 @@ def test_deprecated_warning(): @responses.activate -def test_submit_autorift_job(get_mock_job): +def test_submit_autorift_job(get_mock_hyp3, get_mock_job): job = get_mock_job('AUTORIFT', job_parameters={'granules': ['g1', 'g2']}) api_response = { 'jobs': [ job.to_dict() ] } - with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + api = get_mock_hyp3() responses.add(responses.POST, urljoin(api.url, '/jobs'), json=api_response) batch = api.submit_autorift_job('g1', 'g2') assert batch.jobs[0] == job @responses.activate -def test_submit_rtc_job(get_mock_job): +def test_submit_rtc_job(get_mock_hyp3, get_mock_job): job = get_mock_job('RTC_GAMMA', job_parameters={'granules': ['g1']}) api_response = { 'jobs': [ job.to_dict() ] } - with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + api = get_mock_hyp3() responses.add(responses.POST, urljoin(api.url, '/jobs'), json=api_response) batch = api.submit_rtc_job('g1') assert batch.jobs[0] == job @responses.activate -def test_submit_insar_job(get_mock_job): +def test_submit_insar_job(get_mock_hyp3, get_mock_job): job = get_mock_job('INSAR_GAMMA', job_parameters={'granules': ['g1', 'g2']}) api_response = { 'jobs': [ job.to_dict() ] } - with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + api = get_mock_hyp3() responses.add(responses.POST, urljoin(api.url, '/jobs'), json=api_response) batch = api.submit_insar_job('g1', 'g2') assert batch.jobs[0] == job @responses.activate -def test_submit_insar_isce_burst_job(get_mock_job): +def test_submit_insar_isce_burst_job(get_mock_hyp3, get_mock_job): job = get_mock_job('INSAR_ISCE_BURST', job_parameters={'granules': ['g1', 'g2']}) api_response = { 'jobs': [ job.to_dict() ] } - with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + api = get_mock_hyp3() responses.add(responses.POST, urljoin(api.url, '/jobs'), json=api_response) batch = api.submit_insar_isce_burst_job('g1', 'g2') assert batch.jobs[0] == job @responses.activate -def test_resubmit_previous_job(get_mock_job): +def test_resubmit_previous_job(get_mock_hyp3, get_mock_job): job = get_mock_job() api_response = { 'jobs': [ job.to_dict() ] } - with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + api = get_mock_hyp3() responses.add(responses.POST, urljoin(api.url, '/jobs'), json=api_response) batch = api.submit_prepared_jobs(job.to_dict(for_resubmit=True)) assert batch.jobs[0] == job @responses.activate -def test_my_info(): +def test_my_info(get_mock_hyp3): api_response = { 'job_names': [ 'name1', @@ -435,16 +403,14 @@ def test_my_info(): 'remaining_credits': 25., 'user_id': 'someUser' } - with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + api = get_mock_hyp3() responses.add(responses.GET, urljoin(api.url, '/user'), json=api_response) response = api.my_info() assert response == api_response @responses.activate -def test_check_credits(): +def test_check_credits(get_mock_hyp3): api_response = { 'job_names': [ 'name1', @@ -453,39 +419,33 @@ def test_check_credits(): 'remaining_credits': 25., 'user_id': 'someUser' } - with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + api = get_mock_hyp3() responses.add(responses.GET, urljoin(api.url, '/user'), json=api_response) assert math.isclose(api.check_credits(), 25.) @responses.activate -def test_check_application_status_approved(): +def test_check_application_status_approved(get_mock_hyp3): with warnings.catch_warnings(record=True) as w: - with patch('hyp3_sdk.hyp3.HyP3.my_info', lambda x: {'user_id': 'someUser', 'application_status': 'APPROVED'}): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - _ = HyP3() + _ = get_mock_hyp3() assert len(w) == 0 @responses.activate -def test_check_application_status_not_approved(): +def test_check_application_status_not_approved(get_mock_hyp3): with warnings.catch_warnings(record=True) as w: with patch('hyp3_sdk.hyp3.HyP3.my_info', lambda x: {'user_id': 'someUser', 'application_status': 'PENDING'}): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): + with patch('hyp3_sdk.util.get_authenticated_session', lambda username, password: requests.Session()): _ = HyP3() assert len(w) == 1 assert 'not yet applied for a monthly credit allotment' in str(w[0].message) @responses.activate -def test_costs(): +def test_costs(get_mock_hyp3): api_response = {'foo': 5} - with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): - with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): - api = HyP3() + api = get_mock_hyp3() responses.add(responses.GET, urljoin(api.url, '/costs'), json=api_response) assert api.costs() == {'foo': 5} From 24ec80a2de3ea1d6bf3771230e015be9cd67b0aa Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Tue, 14 May 2024 13:54:20 -0500 Subject: [PATCH 13/21] flake8 --- tests/conftest.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index ceaaa0e..ef14b0b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,11 +1,11 @@ -import requests import shutil from datetime import datetime from pathlib import Path -from unittest.mock import patch from uuid import uuid4 import pytest +import requests +from unittest.mock import patch from hyp3_sdk import Job from hyp3_sdk.hyp3 import HyP3 @@ -15,8 +15,10 @@ def get_mock_hyp3(): def mock_my_info(self): return {'application_status': 'APPROVED'} + def mock_get_authenticated_session(username, password): return requests.Session() + def default_hyp3(): with patch('hyp3_sdk.hyp3.HyP3.my_info', mock_my_info): with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): From d77bfbeba70441523fce3715d00958b0a47107a2 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Tue, 14 May 2024 13:56:16 -0500 Subject: [PATCH 14/21] flake8 --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index ef14b0b..95c7870 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,11 +1,11 @@ import shutil from datetime import datetime from pathlib import Path +from unittest.mock import patch from uuid import uuid4 import pytest import requests -from unittest.mock import patch from hyp3_sdk import Job from hyp3_sdk.hyp3 import HyP3 From 2e324d01e44d2866b7616714c4aeac5ce9dfbce3 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Tue, 14 May 2024 13:57:37 -0500 Subject: [PATCH 15/21] removed unused function definitions --- tests/test_hyp3.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/test_hyp3.py b/tests/test_hyp3.py index 7c19568..90ca0bf 100644 --- a/tests/test_hyp3.py +++ b/tests/test_hyp3.py @@ -11,14 +11,6 @@ from hyp3_sdk import HyP3, Job -def mock_my_info(self): - return {'application_status': 'APPROVED'} - - -def mock_get_authenticated_session(username, password): - return requests.Session() - - @responses.activate def test_session_headers(get_mock_hyp3): api = get_mock_hyp3() From cf1607db499be5909f62753d7b7133e6f48e2598 Mon Sep 17 00:00:00 2001 From: jacquelynsmale Date: Wed, 15 May 2024 11:38:06 -0800 Subject: [PATCH 16/21] update CHANGELOG and add url --- CHANGELOG.md | 5 +++++ src/hyp3_sdk/hyp3.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bfd7a6..4dfc5b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/) and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [6.1.1] + +### Added +* Unapproved `hyp3-sdk` users receive an error message when connecting to `HyP3` + ## [6.1.0] ### Added diff --git a/src/hyp3_sdk/hyp3.py b/src/hyp3_sdk/hyp3.py index e94c74c..81ec4a9 100644 --- a/src/hyp3_sdk/hyp3.py +++ b/src/hyp3_sdk/hyp3.py @@ -52,7 +52,7 @@ def _check_application_status(self) -> None: info = self.my_info() if info['application_status'] != 'APPROVED': warnings.warn(f'User {info["user_id"]} has not yet applied for a monthly credit allotment.' - ' Please visit to submit your application.') + ' Please visit https://hyp3.asf.alaska.edu/request_access to submit your application.') def find_jobs(self, start: Optional[datetime] = None, From 8d23ec6be6749b75f7026b6941d1490961fc1311 Mon Sep 17 00:00:00 2001 From: jacquelynsmale Date: Wed, 15 May 2024 13:38:41 -0800 Subject: [PATCH 17/21] add in exceptions --- src/hyp3_sdk/hyp3.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/hyp3_sdk/hyp3.py b/src/hyp3_sdk/hyp3.py index 81ec4a9..d893195 100644 --- a/src/hyp3_sdk/hyp3.py +++ b/src/hyp3_sdk/hyp3.py @@ -16,7 +16,6 @@ PROD_API = 'https://hyp3-api.asf.alaska.edu' TEST_API = 'https://hyp3-test-api.asf.alaska.edu' - class HyP3: """A python wrapper around the HyP3 API. @@ -49,10 +48,17 @@ def __init__(self, api_url: str = PROD_API, username: Optional[str] = None, pass self._check_application_status() def _check_application_status(self) -> None: + help_url = 'https://hyp3.asf.alaska.edu/request_access' info = self.my_info() - if info['application_status'] != 'APPROVED': + if info['application_status'] == 'NOT_STARTED': warnings.warn(f'User {info["user_id"]} has not yet applied for a monthly credit allotment.' - ' Please visit https://hyp3.asf.alaska.edu/request_access to submit your application.') + f' Please visit {help_url} to submit your application.') + if info['application_status'] == 'PENDING': + warnings.warn(f'User {info["user_id"]}\'s request for access is pending review For more information, ' + f'visit {help_url}') + elif info['application_status'] != 'APPROVED': + warnings.warn(f'{info["user_id"]}\'s request for access has been rejected. For more information, ' + f'visit {help_url}') def find_jobs(self, start: Optional[datetime] = None, From 1bc4d4e95adc3c96f0de47d01225c355093eda3c Mon Sep 17 00:00:00 2001 From: jacquelynsmale Date: Wed, 15 May 2024 13:54:48 -0800 Subject: [PATCH 18/21] fix logic and add test --- src/hyp3_sdk/hyp3.py | 4 ++-- tests/test_hyp3.py | 26 ++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/hyp3_sdk/hyp3.py b/src/hyp3_sdk/hyp3.py index d893195..eb8930a 100644 --- a/src/hyp3_sdk/hyp3.py +++ b/src/hyp3_sdk/hyp3.py @@ -54,9 +54,9 @@ def _check_application_status(self) -> None: warnings.warn(f'User {info["user_id"]} has not yet applied for a monthly credit allotment.' f' Please visit {help_url} to submit your application.') if info['application_status'] == 'PENDING': - warnings.warn(f'User {info["user_id"]}\'s request for access is pending review For more information, ' + warnings.warn(f'User {info["user_id"]}\'s request for access is pending review. For more information, ' f'visit {help_url}') - elif info['application_status'] != 'APPROVED': + if info['application_status'] == 'REJECTED': warnings.warn(f'{info["user_id"]}\'s request for access has been rejected. For more information, ' f'visit {help_url}') diff --git a/tests/test_hyp3.py b/tests/test_hyp3.py index 90ca0bf..38cb58d 100644 --- a/tests/test_hyp3.py +++ b/tests/test_hyp3.py @@ -425,14 +425,36 @@ def test_check_application_status_approved(get_mock_hyp3): @responses.activate -def test_check_application_status_not_approved(get_mock_hyp3): +def test_check_application_status_errors(get_mock_hyp3): + application_status = 'NOT_STARTED' with warnings.catch_warnings(record=True) as w: - with patch('hyp3_sdk.hyp3.HyP3.my_info', lambda x: {'user_id': 'someUser', 'application_status': 'PENDING'}): + with patch('hyp3_sdk.hyp3.HyP3.my_info', lambda x: {'user_id': 'someUser', + 'application_status': application_status}): with patch('hyp3_sdk.util.get_authenticated_session', lambda username, password: requests.Session()): _ = HyP3() assert len(w) == 1 assert 'not yet applied for a monthly credit allotment' in str(w[0].message) + application_status = 'PENDING' + with warnings.catch_warnings(record=True) as w: + with patch('hyp3_sdk.hyp3.HyP3.my_info', lambda x: {'user_id': 'someUser', + 'application_status': application_status}): + with patch('hyp3_sdk.util.get_authenticated_session', lambda username, password: requests.Session()): + _ = HyP3() + assert len(w) == 1 + assert 'request for access is pending review' in str(w[0].message) + + application_status = 'REJECTED' + with warnings.catch_warnings(record=True) as w: + with patch('hyp3_sdk.hyp3.HyP3.my_info', lambda x: {'user_id': 'someUser', + 'application_status': application_status}): + with patch('hyp3_sdk.util.get_authenticated_session', lambda username, password: requests.Session()): + _ = HyP3() + assert len(w) == 1 + assert 'request for access has been rejected' in str(w[0].message) + + + @responses.activate def test_costs(get_mock_hyp3): From 4162490e48826c163547f7293a305dc8827ec2ab Mon Sep 17 00:00:00 2001 From: jacquelynsmale Date: Wed, 15 May 2024 13:57:12 -0800 Subject: [PATCH 19/21] fix blank space --- src/hyp3_sdk/hyp3.py | 1 + tests/test_hyp3.py | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hyp3_sdk/hyp3.py b/src/hyp3_sdk/hyp3.py index eb8930a..6f312c0 100644 --- a/src/hyp3_sdk/hyp3.py +++ b/src/hyp3_sdk/hyp3.py @@ -16,6 +16,7 @@ PROD_API = 'https://hyp3-api.asf.alaska.edu' TEST_API = 'https://hyp3-test-api.asf.alaska.edu' + class HyP3: """A python wrapper around the HyP3 API. diff --git a/tests/test_hyp3.py b/tests/test_hyp3.py index 38cb58d..aa60407 100644 --- a/tests/test_hyp3.py +++ b/tests/test_hyp3.py @@ -454,8 +454,6 @@ def test_check_application_status_errors(get_mock_hyp3): assert 'request for access has been rejected' in str(w[0].message) - - @responses.activate def test_costs(get_mock_hyp3): api_response = {'foo': 5} From 55e2617452edfbaa29722bdb8e602d13b36ef05a Mon Sep 17 00:00:00 2001 From: Forrest Williams <31411324+forrestfwilliams@users.noreply.github.com> Date: Thu, 16 May 2024 07:02:14 -0500 Subject: [PATCH 20/21] Update src/hyp3_sdk/hyp3.py --- src/hyp3_sdk/hyp3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hyp3_sdk/hyp3.py b/src/hyp3_sdk/hyp3.py index 6f312c0..403bf0a 100644 --- a/src/hyp3_sdk/hyp3.py +++ b/src/hyp3_sdk/hyp3.py @@ -49,7 +49,7 @@ def __init__(self, api_url: str = PROD_API, username: Optional[str] = None, pass self._check_application_status() def _check_application_status(self) -> None: - help_url = 'https://hyp3.asf.alaska.edu/request_access' + help_url = 'https://hyp3-docs.asf.alaska.edu/using/requesting_access' info = self.my_info() if info['application_status'] == 'NOT_STARTED': warnings.warn(f'User {info["user_id"]} has not yet applied for a monthly credit allotment.' From aa1fbb5a844178deccb920de764454b0b8d1558a Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Fri, 17 May 2024 09:21:28 -0800 Subject: [PATCH 21/21] remove extra space --- src/hyp3_sdk/hyp3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hyp3_sdk/hyp3.py b/src/hyp3_sdk/hyp3.py index 403bf0a..ab9d97a 100644 --- a/src/hyp3_sdk/hyp3.py +++ b/src/hyp3_sdk/hyp3.py @@ -55,7 +55,7 @@ def _check_application_status(self) -> None: warnings.warn(f'User {info["user_id"]} has not yet applied for a monthly credit allotment.' f' Please visit {help_url} to submit your application.') if info['application_status'] == 'PENDING': - warnings.warn(f'User {info["user_id"]}\'s request for access is pending review. For more information, ' + warnings.warn(f'User {info["user_id"]}\'s request for access is pending review. For more information, ' f'visit {help_url}') if info['application_status'] == 'REJECTED': warnings.warn(f'{info["user_id"]}\'s request for access has been rejected. For more information, '