Skip to content

Commit 0abbdf7

Browse files
author
Ubuntu
committed
Fix indexing integration test, and improve core error messaging
1 parent adf5ac8 commit 0abbdf7

File tree

4 files changed

+15
-20
lines changed

4 files changed

+15
-20
lines changed

nucleus/__init__.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,13 +1147,6 @@ def create_custom_index(
11471147
requests_command=requests.post,
11481148
)
11491149

1150-
def check_index_status(self, job_id: str):
1151-
return self.make_request(
1152-
{},
1153-
f"indexing/{job_id}",
1154-
requests_command=requests.get,
1155-
)
1156-
11571150
def delete_custom_index(self, dataset_id: str):
11581151
return self.make_request(
11591152
{},

nucleus/dataset.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,6 @@ def add_taxonomy(
466466
requests_command=requests.post,
467467
)
468468

469-
def check_index_status(self, job_id: str):
470-
return self._client.check_index_status(job_id)
471-
472469
def items_and_annotations(
473470
self,
474471
) -> List[Dict[str, Union[DatasetItem, Dict[str, List[Annotation]]]]]:

nucleus/errors.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
"scale-nucleus"
55
).version
66

7+
INFRA_FLAKE_MESSAGES = [
8+
"downstream duration timeout",
9+
"upstream connect error or disconnect/reset before headers. reset reason: local reset",
10+
]
11+
712

813
class ModelCreationError(Exception):
914
def __init__(self, message="Could not create the model"):
@@ -35,7 +40,7 @@ class NucleusAPIError(Exception):
3540
def __init__(
3641
self, endpoint, command, requests_response=None, aiohttp_response=None
3742
):
38-
message = f"Your client is on version {nucleus_client_version}. Before reporting this error, please make sure you update to the latest version of the client by running pip install --upgrade scale-nucleus\n"
43+
message = f"Your client is on version {nucleus_client_version}. If you have not recently done so, please make sure you have updated to the latest version of the client by running pip install --upgrade scale-nucleus\n"
3944
if requests_response is not None:
4045
message += f"Tried to {command.__name__} {endpoint}, but received {requests_response.status_code}: {requests_response.reason}."
4146
if hasattr(requests_response, "text"):
@@ -50,4 +55,10 @@ def __init__(
5055
if data:
5156
message += f"\nThe detailed error is:\n{data}"
5257

58+
if any(
59+
infra_flake_message in message
60+
for infra_flake_message in INFRA_FLAKE_MESSAGES
61+
):
62+
message += "\n This likely indicates temporary downtime of the API, please try again in a minute or two"
63+
5364
super().__init__(message)

tests/test_indexing.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,14 @@ def dataset(CLIENT):
4141
@pytest.mark.integration
4242
def test_index_integration(dataset):
4343
signed_embeddings_url = TEST_INDEX_EMBEDDINGS_FILE
44-
create_response = dataset.create_custom_index(
45-
[signed_embeddings_url], embedding_dim=3
46-
)
47-
job = AsyncJob.from_json(create_response, client="Nucleus Client")
44+
job = dataset.create_custom_index([signed_embeddings_url], embedding_dim=3)
4845
assert job.job_id
4946
assert job.job_last_known_status
5047
assert job.job_type
5148
assert job.job_creation_time
52-
assert MESSAGE_KEY in create_response
53-
job_id = create_response[JOB_ID_KEY]
49+
job.sleep_until_complete()
5450

55-
# Job can error because pytest dataset fixture gets deleted
56-
# As a workaround, we'll just check htat we got some response
57-
job_status_response = dataset.check_index_status(job_id)
51+
job_status_response = job.status()
5852
assert STATUS_KEY in job_status_response
5953
assert JOB_ID_KEY in job_status_response
6054
assert MESSAGE_KEY in job_status_response

0 commit comments

Comments
 (0)