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

Add Job.priority attribute #271

Merged
merged 4 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ 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]
## [6.2.0]

### Added
* `Job.priority` attribute
* Unapproved `hyp3-sdk` users receive an error message when connecting to `HyP3`

## [6.1.0]
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
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,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
2 changes: 2 additions & 0 deletions tests/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"thumbnail_images": ["https://PAIR_PROCESS_thumb.png"],
"user_id": "asf_hyp3",
"credit_cost": 1,
"priority": 9999,
}

FAILED_JOB = {
Expand All @@ -42,6 +43,7 @@
"status_code": "FAILED",
"user_id": "asf_hyp3",
"credit_cost": 1,
"priority": 9999,
}


Expand Down
Loading