Skip to content

Commit ac0a0ab

Browse files
fix: unable to convert DeltaTableConnectionConfig to json schema (#566)
A bump to the pydantic library now requires typing for Secrets. As a result, In its current form, running ```python from unstructured_ingest.processes.connectors.delta_table import DeltaTableConnectionConfig DeltaTableConnectionConfig(table_uri="").model_json_schema() ``` results in ``` raise TypeError( TypeError: Can't get secret type from Secret. Please use Secret[<type>], or subclass from Secret[<type>] instead. ``` In addition to the fix, this PR adds tests to iterate over all connectors and validate that the json schema can be generated from them.
1 parent 02e6fc4 commit ac0a0ab

File tree

4 files changed

+69
-2
lines changed

4 files changed

+69
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.1.2
2+
3+
* **Fix**: DeltaTableConnectionConfig default assignment is compliant with stricter typing in Pydantic
4+
15
## 1.1.1
26

37
* **Fix: Update examples**
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import pytest
2+
3+
from unstructured_ingest.processes.connector_registry import (
4+
destination_registry,
5+
source_registry,
6+
)
7+
8+
9+
def test_all_source_connector_configs_json_schema():
10+
failed_connectors = []
11+
12+
for connector_type, connector_entry in source_registry.items():
13+
try:
14+
if connector_entry.connection_config:
15+
schema = connector_entry.connection_config.model_json_schema()
16+
assert schema is not None, f"Schema is None for {connector_type} connection_config"
17+
18+
if connector_entry.indexer_config:
19+
schema = connector_entry.indexer_config.model_json_schema()
20+
assert schema is not None, f"Schema is None for {connector_type} indexer_config"
21+
22+
if connector_entry.downloader_config:
23+
schema = connector_entry.downloader_config.model_json_schema()
24+
assert schema is not None, f"Schema is None for {connector_type} downloader_config"
25+
26+
except Exception as e:
27+
failed_connectors.append((connector_type, str(e)))
28+
29+
if failed_connectors:
30+
error_msg = "Failed to generate JSON schema for source connectors:\n"
31+
for connector_type, error in failed_connectors:
32+
error_msg += f" - {connector_type}: {error}\n"
33+
pytest.fail(error_msg)
34+
35+
36+
def test_all_destination_connector_configs_json_schema():
37+
failed_connectors = []
38+
39+
for connector_type, connector_entry in destination_registry.items():
40+
try:
41+
if connector_entry.connection_config:
42+
schema = connector_entry.connection_config.model_json_schema()
43+
assert schema is not None, f"Schema is None for {connector_type} connection_config"
44+
45+
if connector_entry.uploader_config:
46+
schema = connector_entry.uploader_config.model_json_schema()
47+
assert schema is not None, f"Schema is None for {connector_type} uploader_config"
48+
49+
if connector_entry.upload_stager_config:
50+
schema = connector_entry.upload_stager_config.model_json_schema()
51+
assert schema is not None, (
52+
f"Schema is None for {connector_type} upload_stager_config"
53+
)
54+
55+
except Exception as e:
56+
failed_connectors.append((connector_type, str(e)))
57+
58+
if failed_connectors:
59+
error_msg = "Failed to generate JSON schema for destination connectors:\n"
60+
for connector_type, error in failed_connectors:
61+
error_msg += f" - {connector_type}: {error}\n"
62+
pytest.fail(error_msg)

unstructured_ingest/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.1.1" # pragma: no cover
1+
__version__ = "1.1.2" # pragma: no cover

unstructured_ingest/processes/connectors/delta_table.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class DeltaTableAccessConfig(AccessConfig):
4848

4949
class DeltaTableConnectionConfig(ConnectionConfig):
5050
access_config: Secret[DeltaTableAccessConfig] = Field(
51-
default=Secret(DeltaTableAccessConfig()), validate_default=True
51+
default_factory=lambda: Secret[DeltaTableAccessConfig](DeltaTableAccessConfig()),
52+
validate_default=True,
5253
)
5354
aws_region: Optional[str] = Field(default=None, description="AWS Region")
5455
table_uri: str = Field(

0 commit comments

Comments
 (0)