Skip to content

Commit 7c79470

Browse files
authored
Merge pull request #46 from scaleapi/sasha/force_fix
Sasha/force fix
2 parents cac9564 + 22afdae commit 7c79470

File tree

7 files changed

+49
-6
lines changed

7 files changed

+49
-6
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,24 @@ A response code of 200 indicates successful deletion.
156156
```python
157157
client.delete_model_run("model_run_id")
158158
```
159+
160+
## For Developers
161+
162+
Please install the pre-commit hooks by running the following commands:
163+
```python
164+
pip install pre-commit
165+
pre-commit install
166+
```
167+
168+
**Best practices for testing:**
169+
(1). Before running pytest, please make sure to authenticate into AWS, since some of the unit tests rely on AWs resources:
170+
```
171+
gimme_okta_aws_creds
172+
```
173+
174+
(2). Please run pytest from the root directory of the repo, i.e.
175+
```
176+
pytest tests/test_dataset.py
177+
```
178+
179+

nucleus/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ def _process_append_requests_local(
374374
self,
375375
dataset_id: str,
376376
payload: dict,
377+
update: bool,
377378
local_batch_size: int = 10,
378379
size: int = 10,
379380
):
@@ -920,9 +921,7 @@ def get_slice(self, slice_id: str) -> Slice:
920921
"""
921922
return Slice(slice_id, self)
922923

923-
def slice_info(
924-
self, slice_id: str
925-
) -> dict:
924+
def slice_info(self, slice_id: str) -> dict:
926925
"""
927926
This endpoint provides information about specified slice.
928927

nucleus/prediction.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def from_json(cls, payload: dict):
3737
],
3838
reference_id=payload.get(REFERENCE_ID_KEY, None),
3939
item_id=payload.get(ITEM_ID_KEY, None),
40+
annotation_id=payload.get(ANNOTATION_ID_KEY, None),
4041
)
4142

4243

tests/__init__.py

Whitespace-only changes.

tests/helpers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
DatasetItem(TEST_IMG_URLS[2], "3"),
3030
DatasetItem(TEST_IMG_URLS[3], "4"),
3131
]
32+
33+
LOCAL_FILENAME = "tests/test_img.jpg"
3234
TEST_PREDS = [
3335
BoxPrediction("[Pytest Box Prediction 1]", 0, 0, 100, 100, "1"),
3436
BoxPrediction("[Pytest Box Prediction 2]", 0, 0, 100, 100, "2"),
@@ -60,7 +62,6 @@ def s3_sign(bucket, key):
6062
ExpiresIn=PRESIGN_EXPIRY_SECONDS,
6163
)
6264

63-
6465
def reference_id_from_url(url):
6566
return Path(url).name
6667

tests/test_dataset.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
TEST_SLICE_NAME,
55
TEST_DATASET_NAME,
66
TEST_IMG_URLS,
7+
LOCAL_FILENAME,
78
reference_id_from_url,
89
)
910

@@ -84,6 +85,19 @@ def check_is_expected_response(response):
8485
check_is_expected_response(response)
8586

8687

88+
def test_dataset_append_local(CLIENT, dataset):
89+
ds_items_local = [DatasetItem(image_location=LOCAL_FILENAME)]
90+
response = dataset.append(ds_items_local)
91+
assert isinstance(response, UploadResponse)
92+
resp_json = response.json()
93+
assert resp_json[DATASET_ID_KEY] == dataset.id
94+
assert resp_json[NEW_ITEMS] == 1
95+
assert resp_json[UPDATED_ITEMS] == 0
96+
assert resp_json[IGNORED_ITEMS] == 0
97+
assert resp_json[ERROR_ITEMS] == 0
98+
assert ERROR_PAYLOAD not in resp_json
99+
100+
87101
def test_dataset_list_autotags(CLIENT, dataset):
88102
# Creation
89103
# List of Autotags should be empty
@@ -119,7 +133,10 @@ def test_slice_create_and_delete_and_list(dataset):
119133
assert response["dataset_id"] == dataset.id
120134
assert len(response["dataset_items"]) == 2
121135
for item in ds_items[:2]:
122-
assert item.reference_id == response["dataset_items"][0]["reference_id"] or item.reference_id == response["dataset_items"][1]["reference_id"]
136+
assert (
137+
item.reference_id == response["dataset_items"][0]["ref_id"]
138+
or item.reference_id == response["dataset_items"][1]["ref_id"]
139+
)
123140

124141

125142
def test_slice_append(dataset):
@@ -147,4 +164,8 @@ def test_slice_append(dataset):
147164
response = slc.info()
148165
assert len(response["dataset_items"]) == 3
149166
for item in ds_items[:3]:
150-
assert item.reference_id == response["dataset_items"][0]["reference_id"] or item.reference_id == response["dataset_items"][1]["reference_id"] or item.reference_id == response["dataset_items"][2]["reference_id"]
167+
assert (
168+
item.reference_id == response["dataset_items"][0]["ref_id"]
169+
or item.reference_id == response["dataset_items"][1]["ref_id"]
170+
or item.reference_id == response["dataset_items"][2]["ref_id"]
171+
)

tests/test_img.jpg

87.6 KB
Loading

0 commit comments

Comments
 (0)