Skip to content

Commit 47750b4

Browse files
standardize exception classes across the repo (#583)
the purpose is to standardize exception classes across the repo and make downstream services easier to handle exceptions. downstream services only need to catch unstructured-ingest.error.UnstructuredIngestError, because any exception thrown from ingest is a subclass of UnstructuredIngestError. downstream services no longer need to wrap_error
1 parent a69d6d8 commit 47750b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+309
-178
lines changed

CHANGELOG.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,42 @@
1+
## 1.2.10
2+
3+
* **o11y: standardize exception classes across the repo**:
4+
15
## 1.2.9
26

37
**Fix**: enable s3fs cache_regions for bucket region detection
48

59
## 1.2.8
610

7-
**Fix**: Fix artifact url
11+
**Fix: Fix artifact url**
812

913
## 1.2.7
1014

11-
**Fix**: Fix artifact url
15+
**Fix: Fix artifact url**
1216

1317
## 1.2.6
1418

1519
**Publish to both pypi and artifacts**
1620

1721
## 1.2.5
1822

19-
**Fix**: move S3 ambient_credentials out of AccessConfig
23+
**Fix: move S3 ambient_credentials out of AccessConfig**
2024

2125
## 1.2.4
2226

23-
**Fix**: properly handle Together API 5xx errors as ProviderError instead of UserError
27+
**Fix: properly handle Together API 5xx errors as ProviderError instead of UserError**
2428

2529
## 1.2.3
2630

27-
* **Feature**: allow environment credentials for S3
31+
* **Feature: allow environment credentials for S3**
2832

2933
## 1.2.2
3034

31-
* **Fix**: prevent S3 path conflicts using tempfile for directory isolation
35+
* **Fix: prevent S3 path conflicts using tempfile for directory isolation**
3236

3337
## 1.2.1
3438

35-
* **Fix**: Embeddings are properly assigned when embedding in batches
39+
* **Fix: Embeddings are properly assigned when embedding in batches**
3640

3741
## 1.2.0
3842
* **Drop Python 3.9 support**

test/integration/connectors/databricks/test_volumes_native.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
)
2323
from test.integration.utils import requires_env
2424
from unstructured_ingest.data_types.file_data import FileData, SourceIdentifiers
25-
from unstructured_ingest.errors_v2 import UserAuthError, UserError
25+
from unstructured_ingest.error import UserAuthError, UserError
2626
from unstructured_ingest.processes.connectors.databricks.volumes_native import (
2727
CONNECTOR_TYPE,
2828
DatabricksNativeVolumesAccessConfig,

test/integration/connectors/discord/test_discord.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
source_filedata_display_name_set_check,
1414
)
1515
from test.integration.utils import requires_env
16-
from unstructured_ingest.error import SourceConnectionError
16+
from unstructured_ingest.error import UserAuthError, ValueError
1717
from unstructured_ingest.processes.connectors.discord import (
1818
CONNECTOR_TYPE,
1919
DiscordAccessConfig,
@@ -76,7 +76,7 @@ def test_discord_source_precheck_fail_no_token():
7676

7777
connection_config = DiscordConnectionConfig(access_config=DiscordAccessConfig(token=""))
7878
indexer = DiscordIndexer(connection_config=connection_config, index_config=indexer_config)
79-
with pytest.raises(SourceConnectionError):
79+
with pytest.raises(UserAuthError):
8080
indexer.precheck()
8181

8282

@@ -89,5 +89,5 @@ def test_discord_source_precheck_fail_no_channels():
8989
access_config=DiscordAccessConfig(token=get_env_data().token)
9090
)
9191
indexer = DiscordIndexer(connection_config=connection_config, index_config=indexer_config)
92-
with pytest.raises(SourceConnectionError):
92+
with pytest.raises(ValueError):
9393
indexer.precheck()

test/integration/connectors/test_s3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
)
2020
from test.integration.utils import requires_env
2121
from unstructured_ingest.data_types.file_data import FileData, SourceIdentifiers
22-
from unstructured_ingest.errors_v2 import UserAuthError, UserError
22+
from unstructured_ingest.error import UserAuthError, UserError
2323
from unstructured_ingest.processes.connectors.fsspec.s3 import (
2424
CONNECTOR_TYPE,
2525
S3AccessConfig,

test/integration/connectors/test_sharepoint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def _create_indexer(client_cred=None, site=None, path=None):
376376
)
377377
async def test_sharepoint_precheck_error_scenarios(indexer_factory, error_scenario, expected_error):
378378
"""Parametrized test for different SharePoint precheck error scenarios."""
379-
from unstructured_ingest.errors_v2 import UserAuthError, UserError
379+
from unstructured_ingest.error import UserAuthError, UserError
380380

381381
error_class_map = {"UserAuthError": UserAuthError, "UserError": UserError}
382382

@@ -427,7 +427,7 @@ async def test_sharepoint_precheck_insufficient_permissions(
427427
base_sharepoint_config,
428428
):
429429
"""Test precheck with credentials that have insufficient permissions."""
430-
from unstructured_ingest.errors_v2 import UserAuthError
430+
from unstructured_ingest.error import UserAuthError
431431

432432
access_config = SharepointAccessConfig(client_cred=insufficient_perms_config.client_cred)
433433
connection_config = SharepointConnectionConfig(

test/integration/connectors/test_zendesk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
source_filedata_display_name_set_check,
1111
)
1212
from test.integration.utils import requires_env
13-
from unstructured_ingest.errors_v2 import UserAuthError
13+
from unstructured_ingest.error import UserAuthError
1414
from unstructured_ingest.processes.connectors.zendesk.zendesk import (
1515
CONNECTOR_TYPE,
1616
ZendeskAccessConfig,

test/integration/connectors/utils/validation/source.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,14 @@ def run_expected_download_files_validation(
168168

169169
def run_directory_structure_validation(expected_output_dir: Path, download_files: list[str]):
170170
s3_keys_file = expected_output_dir / "expected_s3_keys.json"
171-
171+
172172
if s3_keys_file.exists():
173173
with s3_keys_file.open("r") as f:
174174
s3_keys = json.load(f)["s3_keys"]
175-
175+
176176
expected_filenames = {Path(s3_key).name for s3_key in s3_keys}
177177
actual_filenames = {Path(download_file).name for download_file in download_files}
178-
178+
179179
assert expected_filenames == actual_filenames, (
180180
f"Expected filenames: {sorted(expected_filenames)}, "
181181
f"Got filenames: {sorted(actual_filenames)}"

test/integration/connectors/weaviate/test_cloud.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
2-
from pydantic import ValidationError
32

43
from test.integration.connectors.utils.constants import DESTINATION_TAG, VECTOR_DB_TAG
4+
from unstructured_ingest.error import ValueError
55
from unstructured_ingest.processes.connectors.weaviate.cloud import (
66
CONNECTOR_TYPE,
77
CloudWeaviateAccessConfig,
@@ -11,7 +11,7 @@
1111

1212
@pytest.mark.tags(CONNECTOR_TYPE, DESTINATION_TAG, VECTOR_DB_TAG)
1313
def test_weaviate_failing_connection_config():
14-
with pytest.raises(ValidationError):
14+
with pytest.raises(ValueError):
1515
CloudWeaviateConnectionConfig(
1616
access_config=CloudWeaviateAccessConfig(api_key="my key", password="password"),
1717
username="username",

test/integration/embedders/test_bedrock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
BedrockEmbeddingConfig,
1616
BedrockEmbeddingEncoder,
1717
)
18-
from unstructured_ingest.errors_v2 import UserAuthError, UserError
18+
from unstructured_ingest.error import UserAuthError, UserError
1919
from unstructured_ingest.processes.embedder import Embedder, EmbedderConfig
2020

2121

test/integration/embedders/test_octoai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
OctoAiEmbeddingConfig,
1616
OctoAIEmbeddingEncoder,
1717
)
18-
from unstructured_ingest.errors_v2 import UserAuthError, UserError
18+
from unstructured_ingest.error import UserAuthError, UserError
1919
from unstructured_ingest.processes.embedder import Embedder, EmbedderConfig
2020

2121
API_KEY = "OCTOAI_API_KEY"

0 commit comments

Comments
 (0)