From 03d16339c3acbe8f30e40ec4e286337b54b9f552 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Dec 2023 04:01:53 +0000 Subject: [PATCH 1/7] Bump ASFHyP3/actions from 0.8.3 to 0.9.0 Bumps [ASFHyP3/actions](https://github.com/asfhyp3/actions) from 0.8.3 to 0.9.0. - [Release notes](https://github.com/asfhyp3/actions/releases) - [Changelog](https://github.com/ASFHyP3/actions/blob/develop/CHANGELOG.md) - [Commits](https://github.com/asfhyp3/actions/compare/v0.8.3...v0.9.0) --- updated-dependencies: - dependency-name: ASFHyP3/actions dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/changelog.yml | 2 +- .github/workflows/create-jira-issue.yml | 2 +- .github/workflows/distribute.yml | 2 +- .github/workflows/labeled-pr.yml | 2 +- .github/workflows/release-template-comment.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/static-analysis.yml | 4 ++-- .github/workflows/tag-version.yml | 2 +- .github/workflows/test.yml | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index b53663a..79cde0c 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -12,6 +12,6 @@ on: jobs: call-changelog-check-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-changelog-check.yml@v0.8.3 + uses: ASFHyP3/actions/.github/workflows/reusable-changelog-check.yml@v0.9.0 secrets: USER_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/create-jira-issue.yml b/.github/workflows/create-jira-issue.yml index 3a138e9..e87e1c2 100644 --- a/.github/workflows/create-jira-issue.yml +++ b/.github/workflows/create-jira-issue.yml @@ -6,7 +6,7 @@ on: jobs: call-create-jira-issue-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-create-jira-issue.yml@v0.8.3 + uses: ASFHyP3/actions/.github/workflows/reusable-create-jira-issue.yml@v0.9.0 secrets: JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} diff --git a/.github/workflows/distribute.yml b/.github/workflows/distribute.yml index 8d10238..4785a3d 100644 --- a/.github/workflows/distribute.yml +++ b/.github/workflows/distribute.yml @@ -7,7 +7,7 @@ on: jobs: call-version-info-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.8.3 + uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.9.0 distribute: runs-on: ubuntu-latest diff --git a/.github/workflows/labeled-pr.yml b/.github/workflows/labeled-pr.yml index 103ae29..64b1b10 100644 --- a/.github/workflows/labeled-pr.yml +++ b/.github/workflows/labeled-pr.yml @@ -12,4 +12,4 @@ on: jobs: call-labeled-pr-check-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-labeled-pr-check.yml@v0.8.3 + uses: ASFHyP3/actions/.github/workflows/reusable-labeled-pr-check.yml@v0.9.0 diff --git a/.github/workflows/release-template-comment.yml b/.github/workflows/release-template-comment.yml index 5ecedad..e68c709 100644 --- a/.github/workflows/release-template-comment.yml +++ b/.github/workflows/release-template-comment.yml @@ -7,7 +7,7 @@ on: jobs: call-release-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-release-checklist-comment.yml@v0.8.3 + uses: ASFHyP3/actions/.github/workflows/reusable-release-checklist-comment.yml@v0.9.0 permissions: pull-requests: write secrets: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ab16a9e..89fb670 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,7 @@ on: jobs: call-release-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-release.yml@v0.8.3 + uses: ASFHyP3/actions/.github/workflows/reusable-release.yml@v0.9.0 with: release_prefix: HyP3 SDK secrets: diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index ae70063..91db6bd 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -4,9 +4,9 @@ on: push jobs: call-flake8-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-flake8.yml@v0.8.3 + uses: ASFHyP3/actions/.github/workflows/reusable-flake8.yml@v0.9.0 with: local_package_names: hyp3_sdk call-secrets-analysis-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-secrets-analysis.yml@v0.8.3 + uses: ASFHyP3/actions/.github/workflows/reusable-secrets-analysis.yml@v0.9.0 diff --git a/.github/workflows/tag-version.yml b/.github/workflows/tag-version.yml index 5130be2..b97e0a7 100644 --- a/.github/workflows/tag-version.yml +++ b/.github/workflows/tag-version.yml @@ -7,6 +7,6 @@ on: jobs: call-bump-version-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-bump-version.yml@v0.8.3 + uses: ASFHyP3/actions/.github/workflows/reusable-bump-version.yml@v0.9.0 secrets: USER_TOKEN: ${{ secrets.TOOLS_BOT_PAK }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 348b8c1..cd4e4c0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,6 +12,6 @@ on: jobs: call-pytest-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-pytest.yml@v0.8.3 + uses: ASFHyP3/actions/.github/workflows/reusable-pytest.yml@v0.9.0 with: local_package_name: hyp3_sdk From 454865aa74f50cbe6575a924a1123654c388799c Mon Sep 17 00:00:00 2001 From: Andrew Johnston Date: Thu, 25 Jan 2024 14:54:59 -0900 Subject: [PATCH 2/7] support introduction of credits in the HyP3 API --- CHANGELOG.md | 9 +++++++++ src/hyp3_sdk/hyp3.py | 4 ++-- src/hyp3_sdk/jobs.py | 3 +++ tests/conftest.py | 3 ++- tests/test_hyp3.py | 14 ++++---------- tests/test_jobs.py | 6 ++++-- 6 files changed, 24 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9848719..f1974ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,15 @@ 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). +## [5.1.0] +This release accommodates changes to the HyP3 API schema introduced in HyP3 v6.0.0 + +### Added +* `credit_cost` attribute to the `Job` class + +### Changed +* `HyP3.my_info()`: A new `reminaing_credits` field replaces the `quota` field in the return value + ## [5.0.0] ### Removed * `legacy` option for the `dem_name` argument of `HyP3.prepare_rtc_job()` and `HyP3.submit_rtc_job()`. diff --git a/src/hyp3_sdk/hyp3.py b/src/hyp3_sdk/hyp3.py index 84d9abf..463ff74 100644 --- a/src/hyp3_sdk/hyp3.py +++ b/src/hyp3_sdk/hyp3.py @@ -490,7 +490,7 @@ def my_info(self) -> dict: def check_quota(self) -> Optional[int]: """ Returns: - The number of jobs left in your quota, or None if you have no quota + Your remaining processing credits, or None if you have no processing limit """ info = self.my_info() - return info['quota']['remaining'] + return info['remaining_credits'] diff --git a/src/hyp3_sdk/jobs.py b/src/hyp3_sdk/jobs.py index c29541f..1a10b31 100644 --- a/src/hyp3_sdk/jobs.py +++ b/src/hyp3_sdk/jobs.py @@ -31,6 +31,7 @@ def __init__( thumbnail_images: Optional[List] = None, expiration_time: Optional[datetime] = None, processing_times: Optional[List[float]] = None, + credit_cost: Optional[float] = None, ): self.job_id = job_id self.job_type = job_type @@ -45,6 +46,7 @@ def __init__( self.thumbnail_images = thumbnail_images self.expiration_time = expiration_time self.processing_times = processing_times + self.credit_cost = credit_cost def __repr__(self): return f'Job.from_dict({self.to_dict()})' @@ -72,6 +74,7 @@ def from_dict(input_dict: dict): thumbnail_images=input_dict.get('thumbnail_images'), expiration_time=expiration_time, processing_times=input_dict.get('processing_times'), + credit_cost=input_dict.get('credit_cost'), ) def to_dict(self, for_resubmit: bool = False): diff --git a/tests/conftest.py b/tests/conftest.py index ade967b..fdb2895 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -20,7 +20,8 @@ def default_job( files=None, browse_images=None, thumbnail_images=None, - expiration_time=None + expiration_time=None, + credit_cost=None, ): if job_parameters is None: job_parameters = {'param1': 'value1'} diff --git a/tests/test_hyp3.py b/tests/test_hyp3.py index 96dc7f1..ab9d7a7 100644 --- a/tests/test_hyp3.py +++ b/tests/test_hyp3.py @@ -411,10 +411,7 @@ def test_my_info(): 'name1', 'name2' ], - 'quota': { - 'max_job_per_month': 50, - 'remaining': 25 - }, + 'remaining_credits': 25, 'user_id': 'someUser' } with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): @@ -431,14 +428,11 @@ def test_check_quota(): 'name1', 'name2' ], - 'quota': { - 'max_job_per_month': 50, - 'remaining': 25 - }, + '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.check_quota() - assert response == api_response['quota']['remaining'] + + assert api.check_quota() == 25 diff --git a/tests/test_jobs.py b/tests/test_jobs.py index 92d7691..64e8cac 100644 --- a/tests/test_jobs.py +++ b/tests/test_jobs.py @@ -23,7 +23,8 @@ "request_time": "2020-09-22T23:55:10+00:00", "status_code": "SUCCEEDED", "thumbnail_images": ["https://PAIR_PROCESS_thumb.png"], - "user_id": "asf_hyp3" + "user_id": "asf_hyp3", + "credit_cost": 1, } FAILED_JOB = { @@ -39,7 +40,8 @@ "name": "test_failure", "request_time": "2020-09-22T23:55:10+00:00", "status_code": "FAILED", - "user_id": "asf_hyp3" + "user_id": "asf_hyp3", + "credit_cost": 1, } From 7396151bc2b2f7c0aeea0a5c7c2d7899a20e9abe Mon Sep 17 00:00:00 2001 From: Andrew Johnston Date: Fri, 26 Jan 2024 09:37:05 -0900 Subject: [PATCH 3/7] Update CHANGELOG.md Co-authored-by: Jake Herrmann --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1974ba..4187fed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ This release accommodates changes to the HyP3 API schema introduced in HyP3 v6.0 * `credit_cost` attribute to the `Job` class ### Changed -* `HyP3.my_info()`: A new `reminaing_credits` field replaces the `quota` field in the return value +* `HyP3.my_info()`: A new `remaining_credits` field replaces the `quota` field in the return value ## [5.0.0] ### Removed From 6747b34dba45d451c20379ddbc2f9516104d942b Mon Sep 17 00:00:00 2001 From: Andrew Johnston Date: Wed, 31 Jan 2024 13:53:04 -0900 Subject: [PATCH 4/7] Update CHANGELOG.md Co-authored-by: Jake Herrmann --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4187fed..88c55c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ 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). -## [5.1.0] +## [6.0.0] This release accommodates changes to the HyP3 API schema introduced in HyP3 v6.0.0 ### Added From 3455de4ab0de39d5833436ffe18736c36221b7f3 Mon Sep 17 00:00:00 2001 From: Joseph H Kennedy Date: Thu, 1 Feb 2024 16:11:16 -0900 Subject: [PATCH 5/7] deprecate quota; add check credits --- CHANGELOG.md | 7 ++++++- src/hyp3_sdk/hyp3.py | 13 ++++++++++++- tests/test_hyp3.py | 9 +++++---- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88c55c4..99b7926 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,9 +11,14 @@ This release accommodates changes to the HyP3 API schema introduced in HyP3 v6.0 ### Added * `credit_cost` attribute to the `Job` class +* `HyP3.credits_credits` method to determine your remaining processing credits ### Changed -* `HyP3.my_info()`: A new `remaining_credits` field replaces the `quota` field in the return value +* `HyP3.my_info()`: A new `remaining_credits` field replaces the `quota` field in the return value +* `HyP3.check_quota` now returns a float instead of an integer if the user has processing credits + +### Deprecated +* `HyP3.check_quota` has been deprecated in favor of `hyp3.check_credits` ## [5.0.0] ### Removed diff --git a/src/hyp3_sdk/hyp3.py b/src/hyp3_sdk/hyp3.py index 463ff74..bc7774e 100644 --- a/src/hyp3_sdk/hyp3.py +++ b/src/hyp3_sdk/hyp3.py @@ -6,6 +6,7 @@ from getpass import getpass from typing import List, Literal, Optional, Union from urllib.parse import urljoin +from warnings import warn import hyp3_sdk import hyp3_sdk.util @@ -487,10 +488,20 @@ def my_info(self) -> dict: _raise_for_hyp3_status(response) return response.json() - def check_quota(self) -> Optional[int]: + def check_credits(self) -> Optional[float]: """ Returns: Your remaining processing credits, or None if you have no processing limit """ info = self.my_info() return info['remaining_credits'] + + def check_quota(self) -> Optional[float]: + """Deprecated method for checking your remaining processing credits; replaced by `HyP3.check_credits` + + Returns: + Your remaining processing credits, or None if you have no processing limit + """ + warn('This method is deprecated and will be removed in a future release.\n' + 'Please use `HyP3.check_credits` instead.', DeprecationWarning, stacklevel=2) + return self.check_credits() diff --git a/tests/test_hyp3.py b/tests/test_hyp3.py index ab9d7a7..4ef8f55 100644 --- a/tests/test_hyp3.py +++ b/tests/test_hyp3.py @@ -1,3 +1,4 @@ +import math import warnings from datetime import datetime, timedelta, timezone from unittest.mock import patch @@ -411,7 +412,7 @@ def test_my_info(): 'name1', 'name2' ], - 'remaining_credits': 25, + 'remaining_credits': 25., 'user_id': 'someUser' } with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session): @@ -422,17 +423,17 @@ def test_my_info(): @responses.activate -def test_check_quota(): +def test_check_credits(): api_response = { 'job_names': [ 'name1', 'name2' ], - 'remaining_credits': 25, + '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) - assert api.check_quota() == 25 + assert math.isclose(api.check_credits(), 25.) From 43a2444fd151dcec4af84a7fe54f9d9884902ed7 Mon Sep 17 00:00:00 2001 From: Joseph H Kennedy Date: Thu, 1 Feb 2024 16:34:11 -0900 Subject: [PATCH 6/7] better credits type hint for actual behavior from HyP3 --- CHANGELOG.md | 2 +- src/hyp3_sdk/hyp3.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99b7926..40b8659 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ This release accommodates changes to the HyP3 API schema introduced in HyP3 v6.0 ### Changed * `HyP3.my_info()`: A new `remaining_credits` field replaces the `quota` field in the return value -* `HyP3.check_quota` now returns a float instead of an integer if the user has processing credits +* `HyP3.check_quota` may return a float or an integer if the user has processing credits ### Deprecated * `HyP3.check_quota` has been deprecated in favor of `hyp3.check_credits` diff --git a/src/hyp3_sdk/hyp3.py b/src/hyp3_sdk/hyp3.py index bc7774e..c929782 100644 --- a/src/hyp3_sdk/hyp3.py +++ b/src/hyp3_sdk/hyp3.py @@ -488,7 +488,7 @@ def my_info(self) -> dict: _raise_for_hyp3_status(response) return response.json() - def check_credits(self) -> Optional[float]: + def check_credits(self) -> Union[float, int, None]: """ Returns: Your remaining processing credits, or None if you have no processing limit @@ -496,7 +496,7 @@ def check_credits(self) -> Optional[float]: info = self.my_info() return info['remaining_credits'] - def check_quota(self) -> Optional[float]: + def check_quota(self) -> Union[float, int, None]: """Deprecated method for checking your remaining processing credits; replaced by `HyP3.check_credits` Returns: From f449ed0ff850d34bc6d13070810256f69fad36fe Mon Sep 17 00:00:00 2001 From: Joseph H Kennedy Date: Thu, 1 Feb 2024 16:42:46 -0900 Subject: [PATCH 7/7] fix spelling --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40b8659..9e4284d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,14 +11,14 @@ This release accommodates changes to the HyP3 API schema introduced in HyP3 v6.0 ### Added * `credit_cost` attribute to the `Job` class -* `HyP3.credits_credits` method to determine your remaining processing credits +* `HyP3.check_credits` method to determine your remaining processing credits ### Changed * `HyP3.my_info()`: A new `remaining_credits` field replaces the `quota` field in the return value * `HyP3.check_quota` may return a float or an integer if the user has processing credits ### Deprecated -* `HyP3.check_quota` has been deprecated in favor of `hyp3.check_credits` +* `HyP3.check_quota` has been deprecated in favor of `HyP3.check_credits` ## [5.0.0] ### Removed