Skip to content

Commit 47b6131

Browse files
committed
clean also on server level
1 parent e151b48 commit 47b6131

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

_test_unstructured_client/unit/test_server_urls.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,29 +69,29 @@ class URLTestCase:
6969
URLTestCase(
7070
description="non UNST domain client-level URL, no path",
7171
sdk_endpoint_name="general.partition_async",
72-
client_url="http://localhost:8000",
72+
client_url="http://localhost:8000/",
7373
endpoint_url=None,
7474
expected_url="http://localhost:8000"
7575
),
7676
URLTestCase(
7777
description="non UNST domain client-level URL, with path",
7878
sdk_endpoint_name="general.partition_async",
79-
client_url="http://localhost:8000/my/endpoint",
79+
client_url="http://localhost:8000/my/endpoint/",
8080
endpoint_url=None,
8181
expected_url="http://localhost:8000/my/endpoint"
8282
),
8383
URLTestCase(
8484
description="non UNST domain endpoint-level URL, no path",
8585
sdk_endpoint_name="general.partition_async",
8686
client_url=None,
87-
endpoint_url="http://localhost:8000",
87+
endpoint_url="http://localhost:8000/",
8888
expected_url="http://localhost:8000"
8989
),
9090
URLTestCase(
9191
description="non UNST domain endpoint-level URL, with path",
9292
sdk_endpoint_name="general.partition_async",
9393
client_url=None,
94-
endpoint_url="http://localhost:8000/my/endpoint",
94+
endpoint_url="http://localhost:8000/my/endpoint/",
9595
expected_url="http://localhost:8000/my/endpoint"
9696
),
9797
URLTestCase(
@@ -162,28 +162,28 @@ async def test_async_endpoint_uses_correct_url(monkeypatch, case: URLTestCase):
162162
[
163163
URLTestCase(
164164
description="non UNST domain client-level URL, no path",
165-
sdk_endpoint_name="general.partition",
166-
client_url="http://localhost:8000",
165+
sdk_endpoint_name="destinations.create_destination",
166+
client_url="http://localhost:8000/",
167167
endpoint_url=None,
168168
expected_url="http://localhost:8000"
169169
),
170170
URLTestCase(
171171
description="non UNST domain client-level URL, with path",
172-
sdk_endpoint_name="general.partition",
173-
client_url="http://localhost:8000/my/endpoint",
172+
sdk_endpoint_name="sources.create_source",
173+
client_url="http://localhost:8000/my/endpoint/",
174174
endpoint_url=None,
175175
expected_url="http://localhost:8000/my/endpoint"
176176
),
177177
URLTestCase(
178178
description="non UNST domain endpoint-level URL, no path",
179-
sdk_endpoint_name="general.partition",
179+
sdk_endpoint_name="jobs.get_job",
180180
client_url=None,
181181
endpoint_url="http://localhost:8000",
182182
expected_url="http://localhost:8000"
183183
),
184184
URLTestCase(
185185
description="non UNST domain endpoint-level URL, with path",
186-
sdk_endpoint_name="general.partition",
186+
sdk_endpoint_name="workflows.create_workflow",
187187
client_url=None,
188188
endpoint_url="http://localhost:8000/my/endpoint",
189189
expected_url="http://localhost:8000/my/endpoint"

src/unstructured_client/_hooks/custom/clean_server_url_hook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def clean_server_url(base_url: str) -> str:
2929
# For other domains, we want to keep the path
3030
clean_url = urlunparse(parsed_url._replace(params="", query="", fragment=""))
3131

32-
return clean_url
32+
return clean_url.rstrip("/")
3333

3434

3535

src/unstructured_client/destinations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class Destinations(BaseSDK):
1111
def get_default_server_url(self) -> str:
1212
client_url, *_ = self.sdk_configuration.get_server_details()
13-
return client_url
13+
return clean_server_url(client_url)
1414

1515

1616
def create_destination(

src/unstructured_client/general.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ class PartitionAcceptEnum(str, Enum):
1818
class General(BaseSDK):
1919
def get_default_server_url(self) -> str:
2020
client_url, *_ = self.sdk_configuration.get_server_details()
21-
if client_url == utils.remove_suffix(SERVERS[SERVER_PLATFORM_API], "/"):
21+
if client_url == SERVERS[SERVER_PLATFORM_API].rstrip("/"):
2222
#Note(yuming):get_server_details will set the default server to platform-api
2323
return operations.PARTITION_SERVERS[
2424
operations.PARTITION_SERVER_SAAS_API
25-
]
26-
return client_url
25+
].rstrip("/")
26+
return clean_server_url(client_url)
2727

2828
def partition(
2929
self,

src/unstructured_client/jobs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class Jobs(BaseSDK):
1111
def get_default_server_url(self) -> str:
1212
client_url, *_ = self.sdk_configuration.get_server_details()
13-
return client_url
13+
return clean_server_url(client_url)
1414

1515
def cancel_job(
1616
self,

src/unstructured_client/sources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class Sources(BaseSDK):
1111
def get_default_server_url(self) -> str:
1212
client_url, *_ = self.sdk_configuration.get_server_details()
13-
return client_url
13+
return clean_server_url(client_url)
1414

1515
def create_source(
1616
self,

src/unstructured_client/workflows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
class Workflows(BaseSDK):
1212
def get_default_server_url(self) -> str:
1313
client_url, *_ = self.sdk_configuration.get_server_details()
14-
return client_url
14+
return clean_server_url(client_url)
1515

1616
def create_workflow(
1717
self,

0 commit comments

Comments
 (0)