Skip to content

Commit c95650f

Browse files
authored
get_job from job_id (#206)
* add get_job * add inttest * bump ver and update changelog * release is blocked on deploy * retry ci * fix inttest breaking ci
1 parent a3c4e9d commit c95650f

File tree

4 files changed

+48
-6
lines changed

4 files changed

+48
-6
lines changed

CHANGELOG.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,41 @@ All notable changes to the [Nucleus Python Client](https://github.com/scaleapi/n
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [0.5.1](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.5.1) - 2021-01-11
7+
## [0.5.4](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.5.4) - 2022-01-28
8+
9+
### Added
10+
- Add `NucleusClient.get_job` to retrieve `AsyncJob`s by job ID
11+
12+
## [0.5.3](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.5.3) - 2022-01-25
13+
14+
### Added
15+
- Add average precision to polygon metrics
16+
- Add mean average precision to polygon metrics
17+
18+
## [0.5.2](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.5.2) - 2022-01-20
19+
20+
### Added
21+
- Add `Dataset.delete_scene`
22+
23+
### Fixed
24+
- Removed `Shapely` dependency
25+
26+
## [0.5.1](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.5.1) - 2022-01-11
827

928
### Fixed
1029
- Updated dependencies for full Python 3.6 compatibility
1130

12-
## [0.5.0](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.5.0) - 2021-01-10
31+
## [0.5.0](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.5.0) - 2022-01-10
1332

1433
### Added
1534
- `nucleus.metrics` module for computing metrics between Nucleus `Annotation` and `Prediction` objects.
1635

17-
## [0.4.5](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.4.5) - 2021-01-07
36+
## [0.4.5](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.4.5) - 2022-01-07
1837

1938
### Added
2039
- `Dataset.scenes` property that fetches the Scale-generated ID, reference ID, type, and metadata of all scenes in the Dataset.
2140

22-
## [0.4.4](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.4.4) - 2021-01-04
41+
## [0.4.4](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.4.4) - 2022-01-04
2342

2443
### Added
2544
- `Slice.export_raw_items()` method that fetches accessible (signed) URLs for all items in the Slice.

nucleus/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,22 @@ def get_dataset(self, dataset_id: str) -> Dataset:
275275
"""
276276
return Dataset(dataset_id, self)
277277

278+
def get_job(self, job_id: str) -> AsyncJob:
279+
"""Fetches a dataset by its ID.
280+
281+
Parameters:
282+
job_id: The ID of the dataset to fetch.
283+
284+
Returns:
285+
:class:`AsyncJob`: The Nucleus async job as an object.
286+
"""
287+
payload = self.make_request(
288+
payload={},
289+
route=f"job/{job_id}/info",
290+
requests_command=requests.get,
291+
)
292+
return AsyncJob.from_json(payload=payload, client=self)
293+
278294
def get_model(self, model_id: str) -> Model:
279295
"""Fetches a model by its ID.
280296

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ exclude = '''
2121

2222
[tool.poetry]
2323
name = "scale-nucleus"
24-
version = "0.5.3"
24+
version = "0.5.4"
2525
description = "The official Python client library for Nucleus, the Data Platform for AI"
2626
license = "MIT"
2727
authors = ["Scale AI Nucleus Team <nucleusapi@scaleapi.com>"]

tests/test_jobs.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@ def test_repr(test_object: any):
2323
)
2424

2525

26-
def test_job_creation_and_listing(CLIENT):
26+
def test_job_creation_and_listing_and_retrieval(CLIENT):
2727
jobs = CLIENT.list_jobs()
2828

29+
if not jobs:
30+
return
31+
2932
for job in jobs:
3033
assert eval(str(job)) == job
34+
35+
fetch_id = jobs[0].job_id
36+
fetched_job = CLIENT.get_job(fetch_id)
37+
assert fetched_job.status() == jobs[0].status()

0 commit comments

Comments
 (0)