Skip to content

Commit

Permalink
Merge pull request #276 from ASFHyP3/develop
Browse files Browse the repository at this point in the history
Release v6.2.0
  • Loading branch information
jtherrmann authored May 17, 2024
2 parents 62c4312 + edded00 commit c26e8fc
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 85 deletions.
13 changes: 9 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 1 addition & 20 deletions .github/workflows/distribute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,7 @@ jobs:
python -m build
- name: upload to PyPI.org
uses: pypa/[email protected].11
uses: pypa/[email protected].14
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 }}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ 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
* Unapproved `hyp3-sdk` users receive an error message when connecting to `HyP3`

## [6.1.0]

### Added
Expand Down
14 changes: 14 additions & 0 deletions src/hyp3_sdk/hyp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ 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:
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.'
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}')
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}')

def find_jobs(self,
start: Optional[datetime] = None,
Expand Down
3 changes: 3 additions & 0 deletions src/hyp3_sdk/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()})'
Expand Down Expand Up @@ -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):
Expand Down
19 changes: 19 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
import shutil
from datetime import datetime
from pathlib import Path
from unittest.mock import patch
from uuid import uuid4

import pytest
import requests

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)
Expand All @@ -22,6 +40,7 @@ def default_job(
thumbnail_images=None,
expiration_time=None,
credit_cost=None,
priority=None,
):
if job_parameters is None:
job_parameters = {'param1': 'value1'}
Expand Down
Loading

0 comments on commit c26e8fc

Please sign in to comment.