From 2ee0abf470748d1655bcfcb3f40373366ffc2e54 Mon Sep 17 00:00:00 2001 From: Yuming Long Date: Mon, 21 Apr 2025 09:08:59 -0700 Subject: [PATCH 01/21] pending clean_serer_url change --- .../_hooks/custom/clean_server_url_hook.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/unstructured_client/_hooks/custom/clean_server_url_hook.py b/src/unstructured_client/_hooks/custom/clean_server_url_hook.py index 3d0e0438..518dff0f 100644 --- a/src/unstructured_client/_hooks/custom/clean_server_url_hook.py +++ b/src/unstructured_client/_hooks/custom/clean_server_url_hook.py @@ -8,7 +8,7 @@ def clean_server_url(base_url: str) -> str: - """Fix url scheme and remove the '/general/v0/general' path.""" + """Fix url scheme and remove subpath for URLs under Unstructured domains.""" if not base_url: return "" @@ -19,12 +19,18 @@ def clean_server_url(base_url: str) -> str: parsed_url: ParseResult = urlparse(base_url) - if "api.unstructuredapp.io" in parsed_url.netloc: + if "unstructuredapp.io" in parsed_url.netloc: if parsed_url.scheme != "https": parsed_url = parsed_url._replace(scheme="https") + # We only want the base url for Unstructured domains + clean_url = urlunparse(parsed_url._replace(path="", params="", query="", fragment="")) + + else: + # For other domains, we want to keep the path + clean_url = urlunparse(parsed_url._replace(params="", query="", fragment="")) - # We only want the base url - return urlunparse(parsed_url._replace(path="", params="", query="", fragment="")) + return clean_url + def choose_server_url(endpoint_url: str | None, client_url: str, default_endpoint_url: str) -> str: From f971cf94be568e58b3e06ebf329784889e513fca Mon Sep 17 00:00:00 2001 From: Yuming Long Date: Mon, 21 Apr 2025 10:26:41 -0700 Subject: [PATCH 02/21] all endpoints --- src/unstructured_client/destinations.py | 95 +++++----------------- src/unstructured_client/general.py | 36 +++----- src/unstructured_client/jobs.py | 74 ++++------------- src/unstructured_client/sources.py | 90 ++++---------------- src/unstructured_client/workflows.py | 104 +++++------------------- 5 files changed, 85 insertions(+), 314 deletions(-) diff --git a/src/unstructured_client/destinations.py b/src/unstructured_client/destinations.py index 6eba26da..d29a42d7 100644 --- a/src/unstructured_client/destinations.py +++ b/src/unstructured_client/destinations.py @@ -6,9 +6,16 @@ from unstructured_client._hooks import HookContext from unstructured_client.models import errors, operations, shared from unstructured_client.types import BaseModel, OptionalNullable, UNSET - +from unstructured_client.sdkconfiguration import SERVER_PLATFORM_API, SERVERS class Destinations(BaseSDK): + def get_default_server_url(self) -> str: + client_url, *_ = self.sdk_configuration.get_server_details() + if client_url is None: + return utils.remove_suffix(SERVERS[SERVER_PLATFORM_API], "/") + return client_url + + def create_destination( self, *, @@ -31,18 +38,12 @@ def create_destination( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() + url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.CREATE_DESTINATION_SERVERS[ - operations.CREATE_DESTINATION_SERVER_PLATFORM_API - ] - if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.CreateDestinationRequest) request = cast(operations.CreateDestinationRequest, request) @@ -151,17 +152,11 @@ async def create_destination_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.CREATE_DESTINATION_SERVERS[ - operations.CREATE_DESTINATION_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.CreateDestinationRequest) @@ -271,17 +266,12 @@ def delete_destination( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.DELETE_DESTINATION_SERVERS[ - operations.DELETE_DESTINATION_SERVER_PLATFORM_API - ] + if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.DeleteDestinationRequest) @@ -382,17 +372,11 @@ async def delete_destination_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.DELETE_DESTINATION_SERVERS[ - operations.DELETE_DESTINATION_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.DeleteDestinationRequest) @@ -492,17 +476,11 @@ def get_destination( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.GET_DESTINATION_SERVERS[ - operations.GET_DESTINATION_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.GetDestinationRequest) @@ -604,17 +582,11 @@ async def get_destination_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.GET_DESTINATION_SERVERS[ - operations.GET_DESTINATION_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.GetDestinationRequest) @@ -717,18 +689,11 @@ def list_destinations( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.LIST_DESTINATIONS_SERVERS[ - operations.LIST_DESTINATIONS_SERVER_PLATFORM_API - ] - if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.ListDestinationsRequest) request = cast(operations.ListDestinationsRequest, request) @@ -831,18 +796,11 @@ async def list_destinations_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.LIST_DESTINATIONS_SERVERS[ - operations.LIST_DESTINATIONS_SERVER_PLATFORM_API - ] - if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.ListDestinationsRequest) request = cast(operations.ListDestinationsRequest, request) @@ -945,17 +903,11 @@ def update_destination( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.UPDATE_DESTINATION_SERVERS[ - operations.UPDATE_DESTINATION_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.UpdateDestinationRequest) @@ -1065,18 +1017,11 @@ async def update_destination_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.UPDATE_DESTINATION_SERVERS[ - operations.UPDATE_DESTINATION_SERVER_PLATFORM_API - ] - if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.UpdateDestinationRequest) request = cast(operations.UpdateDestinationRequest, request) diff --git a/src/unstructured_client/general.py b/src/unstructured_client/general.py index 9f04e4aa..74e6f6bf 100644 --- a/src/unstructured_client/general.py +++ b/src/unstructured_client/general.py @@ -5,7 +5,6 @@ from typing import Any, Dict, List, Mapping, Optional, Union, cast from unstructured_client import utils from unstructured_client._hooks import HookContext -from unstructured_client._hooks.custom.clean_server_url_hook import choose_server_url from unstructured_client.models import errors, operations, shared from unstructured_client.types import BaseModel, OptionalNullable, UNSET @@ -16,6 +15,14 @@ class PartitionAcceptEnum(str, Enum): class General(BaseSDK): + def get_default_server_url(self) -> str: + client_url, *_ = self.sdk_configuration.get_server_details() + if client_url is None: + return operations.PARTITION_SERVERS[ + operations.PARTITION_SERVER_SAAS_API + ] + return client_url + def partition( self, *, @@ -39,21 +46,12 @@ def partition( :param accept_header_override: Override the default accept header for this method :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() + url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - client_url, *_ = self.sdk_configuration.get_server_details() - - base_url = choose_server_url( - endpoint_url=server_url, - client_url=client_url, - default_endpoint_url=operations.PARTITION_SERVERS[ - operations.PARTITION_SERVER_SAAS_API - ] - ) - if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.PartitionRequest) request = cast(operations.PartitionRequest, request) @@ -170,22 +168,12 @@ async def partition_async( :param accept_header_override: Override the default accept header for this method :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() + url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - - client_url, *_ = self.sdk_configuration.get_server_details() - - base_url = choose_server_url( - endpoint_url=server_url, - client_url=client_url, - default_endpoint_url=operations.PARTITION_SERVERS[ - operations.PARTITION_SERVER_SAAS_API - ] - ) - if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.PartitionRequest) request = cast(operations.PartitionRequest, request) diff --git a/src/unstructured_client/jobs.py b/src/unstructured_client/jobs.py index 50eef1b4..36e246a9 100644 --- a/src/unstructured_client/jobs.py +++ b/src/unstructured_client/jobs.py @@ -6,9 +6,15 @@ from unstructured_client._hooks import HookContext from unstructured_client.models import errors, operations, shared from unstructured_client.types import BaseModel, OptionalNullable, UNSET - +from unstructured_client.sdkconfiguration import SERVER_PLATFORM_API, SERVERS class Jobs(BaseSDK): + def get_default_server_url(self) -> str: + client_url, *_ = self.sdk_configuration.get_server_details() + if client_url is None: + return utils.remove_suffix(SERVERS[SERVER_PLATFORM_API], "/") + return client_url + def cancel_job( self, *, @@ -30,17 +36,11 @@ def cancel_job( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.CANCEL_JOB_SERVERS[ - operations.CANCEL_JOB_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.CancelJobRequest) @@ -140,17 +140,11 @@ async def cancel_job_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.CANCEL_JOB_SERVERS[ - operations.CANCEL_JOB_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.CancelJobRequest) @@ -251,17 +245,12 @@ def download_job_output( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.DOWNLOAD_JOB_OUTPUT_SERVERS[ - operations.DOWNLOAD_JOB_OUTPUT_SERVER_PLATFORM_API - ] + if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.DownloadJobOutputRequest) @@ -362,17 +351,11 @@ async def download_job_output_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.DOWNLOAD_JOB_OUTPUT_SERVERS[ - operations.DOWNLOAD_JOB_OUTPUT_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.DownloadJobOutputRequest) @@ -470,17 +453,11 @@ def get_job( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.GET_JOB_SERVERS[ - operations.GET_JOB_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.GetJobRequest) @@ -580,17 +557,11 @@ async def get_job_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.GET_JOB_SERVERS[ - operations.GET_JOB_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.GetJobRequest) @@ -690,18 +661,11 @@ def list_jobs( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.LIST_JOBS_SERVERS[ - operations.LIST_JOBS_SERVER_PLATFORM_API - ] - if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.ListJobsRequest) request = cast(operations.ListJobsRequest, request) @@ -800,17 +764,11 @@ async def list_jobs_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.LIST_JOBS_SERVERS[ - operations.LIST_JOBS_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.ListJobsRequest) diff --git a/src/unstructured_client/sources.py b/src/unstructured_client/sources.py index 20d0d09d..e854e25e 100644 --- a/src/unstructured_client/sources.py +++ b/src/unstructured_client/sources.py @@ -6,9 +6,15 @@ from unstructured_client._hooks import HookContext from unstructured_client.models import errors, operations, shared from unstructured_client.types import BaseModel, OptionalNullable, UNSET - +from unstructured_client.sdkconfiguration import SERVER_PLATFORM_API, SERVERS class Sources(BaseSDK): + def get_default_server_url(self) -> str: + client_url, *_ = self.sdk_configuration.get_server_details() + if client_url is None: + return utils.remove_suffix(SERVERS[SERVER_PLATFORM_API], "/") + return client_url + def create_source( self, *, @@ -30,17 +36,11 @@ def create_source( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.CREATE_SOURCE_SERVERS[ - operations.CREATE_SOURCE_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.CreateSourceRequest) @@ -149,17 +149,11 @@ async def create_source_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.CREATE_SOURCE_SERVERS[ - operations.CREATE_SOURCE_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.CreateSourceRequest) @@ -268,18 +262,11 @@ def delete_source( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.DELETE_SOURCE_SERVERS[ - operations.DELETE_SOURCE_SERVER_PLATFORM_API - ] - if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.DeleteSourceRequest) request = cast(operations.DeleteSourceRequest, request) @@ -378,17 +365,11 @@ async def delete_source_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.DELETE_SOURCE_SERVERS[ - operations.DELETE_SOURCE_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.DeleteSourceRequest) @@ -488,17 +469,11 @@ def get_source( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.GET_SOURCE_SERVERS[ - operations.GET_SOURCE_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.GetSourceRequest) @@ -600,17 +575,11 @@ async def get_source_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.GET_SOURCE_SERVERS[ - operations.GET_SOURCE_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.GetSourceRequest) @@ -712,17 +681,11 @@ def list_sources( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.LIST_SOURCES_SERVERS[ - operations.LIST_SOURCES_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.ListSourcesRequest) @@ -824,18 +787,11 @@ async def list_sources_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.LIST_SOURCES_SERVERS[ - operations.LIST_SOURCES_SERVER_PLATFORM_API - ] - if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.ListSourcesRequest) request = cast(operations.ListSourcesRequest, request) @@ -936,17 +892,11 @@ def update_source( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.UPDATE_SOURCE_SERVERS[ - operations.UPDATE_SOURCE_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.UpdateSourceRequest) @@ -1055,17 +1005,11 @@ async def update_source_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.UPDATE_SOURCE_SERVERS[ - operations.UPDATE_SOURCE_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.UpdateSourceRequest) diff --git a/src/unstructured_client/workflows.py b/src/unstructured_client/workflows.py index 18822198..35d13690 100644 --- a/src/unstructured_client/workflows.py +++ b/src/unstructured_client/workflows.py @@ -6,9 +6,16 @@ from unstructured_client._hooks import HookContext from unstructured_client.models import errors, operations, shared from unstructured_client.types import BaseModel, OptionalNullable, UNSET +from unstructured_client.sdkconfiguration import SERVER_PLATFORM_API, SERVERS class Workflows(BaseSDK): + def get_default_server_url(self) -> str: + client_url, *_ = self.sdk_configuration.get_server_details() + if client_url is None: + return utils.remove_suffix(SERVERS[SERVER_PLATFORM_API], "/") + return client_url + def create_workflow( self, *, @@ -30,17 +37,11 @@ def create_workflow( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.CREATE_WORKFLOW_SERVERS[ - operations.CREATE_WORKFLOW_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.CreateWorkflowRequest) @@ -145,17 +146,11 @@ async def create_workflow_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.CREATE_WORKFLOW_SERVERS[ - operations.CREATE_WORKFLOW_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.CreateWorkflowRequest) @@ -260,17 +255,12 @@ def delete_workflow( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.DELETE_WORKFLOW_SERVERS[ - operations.DELETE_WORKFLOW_SERVER_PLATFORM_API - ] + if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.DeleteWorkflowRequest) @@ -370,17 +360,11 @@ async def delete_workflow_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.DELETE_WORKFLOW_SERVERS[ - operations.DELETE_WORKFLOW_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.DeleteWorkflowRequest) @@ -480,17 +464,11 @@ def get_workflow( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.GET_WORKFLOW_SERVERS[ - operations.GET_WORKFLOW_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.GetWorkflowRequest) @@ -592,17 +570,11 @@ async def get_workflow_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.GET_WORKFLOW_SERVERS[ - operations.GET_WORKFLOW_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.GetWorkflowRequest) @@ -704,17 +676,11 @@ def list_workflows( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.LIST_WORKFLOWS_SERVERS[ - operations.LIST_WORKFLOWS_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.ListWorkflowsRequest) @@ -816,17 +782,11 @@ async def list_workflows_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.LIST_WORKFLOWS_SERVERS[ - operations.LIST_WORKFLOWS_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.ListWorkflowsRequest) @@ -928,17 +888,11 @@ def run_workflow( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.RUN_WORKFLOW_SERVERS[ - operations.RUN_WORKFLOW_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.RunWorkflowRequest) @@ -1047,17 +1001,11 @@ async def run_workflow_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.RUN_WORKFLOW_SERVERS[ - operations.RUN_WORKFLOW_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.RunWorkflowRequest) @@ -1166,17 +1114,11 @@ def update_workflow( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.UPDATE_WORKFLOW_SERVERS[ - operations.UPDATE_WORKFLOW_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.UpdateWorkflowRequest) @@ -1281,17 +1223,11 @@ async def update_workflow_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = None + base_url = server_url if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - if server_url is not None: - base_url = server_url - else: - base_url = operations.UPDATE_WORKFLOW_SERVERS[ - operations.UPDATE_WORKFLOW_SERVER_PLATFORM_API - ] if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.UpdateWorkflowRequest) From 704666ef2cf78943858180c4380125c5e13f2d25 Mon Sep 17 00:00:00 2001 From: Yuming Long Date: Mon, 21 Apr 2025 10:27:09 -0700 Subject: [PATCH 03/21] no choose --- .../_hooks/custom/clean_server_url_hook.py | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/src/unstructured_client/_hooks/custom/clean_server_url_hook.py b/src/unstructured_client/_hooks/custom/clean_server_url_hook.py index 518dff0f..87b94352 100644 --- a/src/unstructured_client/_hooks/custom/clean_server_url_hook.py +++ b/src/unstructured_client/_hooks/custom/clean_server_url_hook.py @@ -33,33 +33,6 @@ def clean_server_url(base_url: str) -> str: -def choose_server_url(endpoint_url: str | None, client_url: str, default_endpoint_url: str) -> str: - """ - Helper function to fix a breaking change in the SDK past 0.30.0. - When we merged the partition and platform specs, the client server_url stopped working, - and users need to pass it in the endpoint function. - For now, call this helper in the generated code to set the correct url. - - Order of choices: - Endpoint server_url -> s.general.partition(server_url=...) - (Passed in as None if not set) - - Base client server_url -> s = UnstructuredClient(server_url=...) - (Passed as empty string if not set) - - Default endpoint URL as defined in the spec - """ - - # If the client doesn't get a server_url, it sets a default of platform - # This is not always the correct default - we need to make sure default_endpoint_url is used - # So, only use the client url if it has been set to something else - if client_url == "https://platform.unstructuredapp.io": - client_url = "" - - url = endpoint_url if endpoint_url is not None else (client_url or default_endpoint_url) - return clean_server_url(url) - - class CleanServerUrlSDKInitHook(SDKInitHook): """Hook fixing common mistakes by users in defining `server_url` in the unstructured-client""" From b96dc7416aad2804e5dabc0edc4e7ca31a8f6ef7 Mon Sep 17 00:00:00 2001 From: Yuming Long Date: Mon, 21 Apr 2025 10:27:21 -0700 Subject: [PATCH 04/21] test regen? --- .genignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.genignore b/.genignore index 9d61a0ac..4a87ab38 100644 --- a/.genignore +++ b/.genignore @@ -1,7 +1,7 @@ # https://www.speakeasyapi.dev/docs/customize-sdks/monkey-patching # ignore human-written files and directories -src/unstructured_client/_unstructured +# src/unstructured_client/_unstructured _jupyter _sample_docs _test_unstructured_client @@ -10,4 +10,4 @@ _test_unstructured_client Makefile # Ignore the general.partition code until we can fix the base_url issue -src/unstructured_client/general.py +# src/unstructured_client/general.py From e9d2cb6353d922be57b40f38e3328ea45ad1fd71 Mon Sep 17 00:00:00 2001 From: Yuming Long Date: Mon, 21 Apr 2025 10:57:15 -0700 Subject: [PATCH 05/21] update doc link --- .genignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.genignore b/.genignore index 4a87ab38..e5adb336 100644 --- a/.genignore +++ b/.genignore @@ -1,4 +1,4 @@ -# https://www.speakeasyapi.dev/docs/customize-sdks/monkey-patching +# https://www.speakeasy.com/docs/customize/code/monkey-patching # ignore human-written files and directories # src/unstructured_client/_unstructured From 08e276082d1abd7d05cfdf4e5811e2c271547def Mon Sep 17 00:00:00 2001 From: Yuming Long Date: Mon, 21 Apr 2025 13:50:40 -0700 Subject: [PATCH 06/21] fix all --- .../unit/test_server_urls.py | 272 ++++++------------ src/unstructured_client/destinations.py | 25 +- src/unstructured_client/general.py | 12 +- src/unstructured_client/jobs.py | 21 +- src/unstructured_client/sources.py | 25 +- src/unstructured_client/workflows.py | 29 +- 6 files changed, 142 insertions(+), 242 deletions(-) diff --git a/_test_unstructured_client/unit/test_server_urls.py b/_test_unstructured_client/unit/test_server_urls.py index 0d0ab2c8..435ac2ea 100644 --- a/_test_unstructured_client/unit/test_server_urls.py +++ b/_test_unstructured_client/unit/test_server_urls.py @@ -1,8 +1,6 @@ -import httpx import pytest - -from unstructured_client.models import operations -from unstructured_client import UnstructuredClient, basesdk, utils +from dataclasses import dataclass +from unstructured_client import UnstructuredClient, utils # Raise one of these from our mock to return to the test code @@ -53,195 +51,107 @@ def mock_build_request(*args, base_url, **kwargs): return endpoint_method - -@pytest.mark.parametrize( - "sdk_endpoint_name", - [ - ("general.partition"), - ], -) -def test_endpoint_uses_correct_url(monkeypatch, sdk_endpoint_name): - # Test 1 - # Pass server_url to the client, no path - s = UnstructuredClient(server_url="http://localhost:8000") - client_method = get_client_method_with_mock( - sdk_endpoint_name, - s, - "http://localhost:8000", - monkeypatch - ) - - try: - client_method(request={}) - except BaseUrlCorrect: - pass - except BaseUrlIncorrect as e: - pytest.fail(f"server_url was passed to client and ignored, got {e}") - - # Test 2 - # Pass server_url to the client, with path - s = UnstructuredClient(server_url="http://localhost:8000/my/endpoint") - client_method = get_client_method_with_mock( - sdk_endpoint_name, - s, - "http://localhost:8000", - monkeypatch - ) - - try: - client_method(request={}) - except BaseUrlCorrect: - pass - except BaseUrlIncorrect as e: - pytest.fail(f"server_url was passed to client and was not stripped, got {e}") - - # Test 3 - # Pass server_url to the endpoint, no path - s = UnstructuredClient() - client_method = get_client_method_with_mock( - sdk_endpoint_name, - s, - "http://localhost:8000", - monkeypatch - ) - - try: - client_method(request={}, server_url="http://localhost:8000") - except BaseUrlCorrect: - pass - except BaseUrlIncorrect as e: - pytest.fail(f"server_url was passed to endpoint and ignored, got {e}") - - # Test 4 - # Pass server_url to the endpoint, with path - s = UnstructuredClient() - client_method = get_client_method_with_mock( - sdk_endpoint_name, - s, - "http://localhost:8000", - monkeypatch - ) - - try: - client_method(request={}, server_url="http://localhost:8000/my/endpoint") - except BaseUrlCorrect: - pass - except BaseUrlIncorrect as e: - pytest.fail(f"server_url was passed to endpoint and ignored, got {e}") - - - # Test 5 - # No server_url, should take the default - server_url = "https://api.unstructuredapp.io" if "partition" in sdk_endpoint_name else "https://platform.unstructuredapp.io" - - s = UnstructuredClient() - client_method = get_client_method_with_mock( - sdk_endpoint_name, - s, - server_url, - monkeypatch - ) - - try: - client_method(request={}) - except BaseUrlCorrect: - pass - except BaseUrlIncorrect as e: - pytest.fail(f"Default url not used, got {e}") - +@dataclass +class URLTestCase: + description: str + sdk_endpoint_name: str + # url when you init the client (global for all endpoints) + client_url: str | None + # url when you init the SDK endpoint (vary per endpoint) + endpoint_url: str | None + # expected url when actually making the HTTP request in build_request + expected_url: str @pytest.mark.asyncio @pytest.mark.parametrize( - "sdk_endpoint_name", + "case", [ - ("general.partition_async"), - ], + URLTestCase( + description="non UNST domain client-level URL, no path", + sdk_endpoint_name="general.partition_async", + client_url="http://localhost:8000", + endpoint_url=None, + expected_url="http://localhost:8000" + ), + URLTestCase( + description="non UNST domain client-level URL, with path", + sdk_endpoint_name="general.partition_async", + client_url="http://localhost:8000/my/endpoint", + endpoint_url=None, + expected_url="http://localhost:8000/my/endpoint" + ), + URLTestCase( + description="non UNST domain endpoint-level URL, no path", + sdk_endpoint_name="general.partition_async", + client_url=None, + endpoint_url="http://localhost:8000", + expected_url="http://localhost:8000" + ), + URLTestCase( + description="non UNST domain endpoint-level URL, with path", + sdk_endpoint_name="general.partition_async", + client_url=None, + endpoint_url="http://localhost:8000/my/endpoint", + expected_url="http://localhost:8000/my/endpoint" + ), + URLTestCase( + description="UNST domain client-level URL, no path", + sdk_endpoint_name="general.partition_async", + client_url="https://unstructured-000mock.api.unstructuredapp.io", + endpoint_url=None, + expected_url="https://unstructured-000mock.api.unstructuredapp.io" + ), + URLTestCase( + description="UNST domain client-level URL, with path", + sdk_endpoint_name="general.partition_async", + client_url="https://unstructured-000mock.api.unstructuredapp.io/my/endpoint/", + endpoint_url=None, + expected_url="https://unstructured-000mock.api.unstructuredapp.io" + ), + URLTestCase( + description="UNST domain endpoint-level URL, no path", + sdk_endpoint_name="general.partition_async", + client_url=None, + endpoint_url="https://unstructured-000mock.api.unstructuredapp.io", + expected_url="https://unstructured-000mock.api.unstructuredapp.io" + ), + URLTestCase( + description="UNST domain endpoint-level URL, with path", + sdk_endpoint_name="general.partition_async", + client_url=None, + endpoint_url="https://unstructured-000mock.api.unstructuredapp.io/my/endpoint/", + expected_url="https://unstructured-000mock.api.unstructuredapp.io" + ), + URLTestCase( + description="default URL fallback", + sdk_endpoint_name="general.partition_async", + client_url=None, + endpoint_url=None, + expected_url="https://api.unstructuredapp.io" + ), + ] ) -async def test_async_endpoint_uses_correct_url(monkeypatch, sdk_endpoint_name): - # Test 1 - # Pass server_url to the client, no path - s = UnstructuredClient(server_url="http://localhost:8000") - client_method = get_client_method_with_mock( - sdk_endpoint_name, - s, - "http://localhost:8000", - monkeypatch - ) - - try: - await client_method(request={}) - except BaseUrlCorrect: - pass - except BaseUrlIncorrect as e: - pytest.fail(f"server_url was passed to client and ignored, got {e}") - - # Test 2 - # Pass server_url to the client, with path - s = UnstructuredClient(server_url="http://localhost:8000/my/endpoint") - client_method = get_client_method_with_mock( - sdk_endpoint_name, - s, - "http://localhost:8000", - monkeypatch - ) - - try: - await client_method(request={}) - except BaseUrlCorrect: - pass - except BaseUrlIncorrect as e: - pytest.fail(f"server_url was passed to client and was not stripped, got {e}") - - # Test 3 - # Pass server_url to the endpoint, no path - s = UnstructuredClient() - client_method = get_client_method_with_mock( - sdk_endpoint_name, - s, - "http://localhost:8000", - monkeypatch - ) - - try: - await client_method(request={}, server_url="http://localhost:8000") - except BaseUrlCorrect: - pass - except BaseUrlIncorrect as e: - pytest.fail(f"server_url was passed to endpoint and ignored, got {e}") - - # Test 4 - # Pass server_url to the endpoint, with path - s = UnstructuredClient() - client_method = get_client_method_with_mock( - sdk_endpoint_name, - s, - "http://localhost:8000", - monkeypatch - ) - - try: - await client_method(request={}, server_url="http://localhost:8000/my/endpoint") - except BaseUrlCorrect: - pass - except BaseUrlIncorrect as e: - pytest.fail(f"server_url was passed to endpoint and ignored, got {e}") - - - # Test 5 - # No server_url, should take the default - server_url = "https://api.unstructuredapp.io" if "partition" in sdk_endpoint_name else "https://platform.unstructuredapp.io" +async def test_async_endpoint_uses_correct_url(monkeypatch, case: URLTestCase): + if case.client_url: + s = UnstructuredClient(server_url=case.client_url) + else: + s = UnstructuredClient() - s = UnstructuredClient() client_method = get_client_method_with_mock( - sdk_endpoint_name, + case.sdk_endpoint_name, s, - server_url, + case.expected_url, monkeypatch ) try: - await client_method(request={}) + if case.endpoint_url: + await client_method(request={}, server_url=case.endpoint_url) + else: + await client_method(request={}) except BaseUrlCorrect: pass except BaseUrlIncorrect as e: - pytest.fail(f"Default url not used, got {e}") + pytest.fail( + f"{case.description}: Expected {case.expected_url}, got {e}" + ) diff --git a/src/unstructured_client/destinations.py b/src/unstructured_client/destinations.py index d29a42d7..edacd462 100644 --- a/src/unstructured_client/destinations.py +++ b/src/unstructured_client/destinations.py @@ -1,18 +1,15 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" - +from unstructured_client._hooks.custom.clean_server_url_hook import clean_server_url from .basesdk import BaseSDK from typing import Any, List, Mapping, Optional, Union, cast from unstructured_client import utils from unstructured_client._hooks import HookContext from unstructured_client.models import errors, operations, shared from unstructured_client.types import BaseModel, OptionalNullable, UNSET -from unstructured_client.sdkconfiguration import SERVER_PLATFORM_API, SERVERS class Destinations(BaseSDK): def get_default_server_url(self) -> str: client_url, *_ = self.sdk_configuration.get_server_details() - if client_url is None: - return utils.remove_suffix(SERVERS[SERVER_PLATFORM_API], "/") return client_url @@ -38,7 +35,7 @@ def create_destination( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: @@ -152,7 +149,7 @@ async def create_destination_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -266,7 +263,7 @@ def delete_destination( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -372,7 +369,7 @@ async def delete_destination_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -476,7 +473,7 @@ def get_destination( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -582,7 +579,7 @@ async def get_destination_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -689,7 +686,7 @@ def list_destinations( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -796,7 +793,7 @@ async def list_destinations_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -903,7 +900,7 @@ def update_destination( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -1017,7 +1014,7 @@ async def update_destination_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms diff --git a/src/unstructured_client/general.py b/src/unstructured_client/general.py index 74e6f6bf..5ae9c77a 100644 --- a/src/unstructured_client/general.py +++ b/src/unstructured_client/general.py @@ -1,5 +1,6 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" +from unstructured_client._hooks.custom.clean_server_url_hook import clean_server_url from .basesdk import BaseSDK from enum import Enum from typing import Any, Dict, List, Mapping, Optional, Union, cast @@ -7,7 +8,7 @@ from unstructured_client._hooks import HookContext from unstructured_client.models import errors, operations, shared from unstructured_client.types import BaseModel, OptionalNullable, UNSET - +from unstructured_client.sdkconfiguration import SERVER_PLATFORM_API, SERVERS class PartitionAcceptEnum(str, Enum): APPLICATION_JSON = "application/json" @@ -17,7 +18,8 @@ class PartitionAcceptEnum(str, Enum): class General(BaseSDK): def get_default_server_url(self) -> str: client_url, *_ = self.sdk_configuration.get_server_details() - if client_url is None: + if client_url == utils.remove_suffix(SERVERS[SERVER_PLATFORM_API], "/"): + #Note(yuming):get_server_details will set the default server to platform-api return operations.PARTITION_SERVERS[ operations.PARTITION_SERVER_SAAS_API ] @@ -46,7 +48,7 @@ def partition( :param accept_header_override: Override the default accept header for this method :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: @@ -168,8 +170,8 @@ async def partition_async( :param accept_header_override: Override the default accept header for this method :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() - + + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms diff --git a/src/unstructured_client/jobs.py b/src/unstructured_client/jobs.py index 36e246a9..086ed54f 100644 --- a/src/unstructured_client/jobs.py +++ b/src/unstructured_client/jobs.py @@ -1,18 +1,15 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" - +from unstructured_client._hooks.custom.clean_server_url_hook import clean_server_url from .basesdk import BaseSDK from typing import Any, List, Mapping, Optional, Union, cast from unstructured_client import utils from unstructured_client._hooks import HookContext from unstructured_client.models import errors, operations, shared from unstructured_client.types import BaseModel, OptionalNullable, UNSET -from unstructured_client.sdkconfiguration import SERVER_PLATFORM_API, SERVERS class Jobs(BaseSDK): def get_default_server_url(self) -> str: client_url, *_ = self.sdk_configuration.get_server_details() - if client_url is None: - return utils.remove_suffix(SERVERS[SERVER_PLATFORM_API], "/") return client_url def cancel_job( @@ -36,7 +33,7 @@ def cancel_job( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -140,7 +137,7 @@ async def cancel_job_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -245,7 +242,7 @@ def download_job_output( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -351,7 +348,7 @@ async def download_job_output_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -453,7 +450,7 @@ def get_job( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -557,7 +554,7 @@ async def get_job_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -661,7 +658,7 @@ def list_jobs( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -764,7 +761,7 @@ async def list_jobs_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms diff --git a/src/unstructured_client/sources.py b/src/unstructured_client/sources.py index e854e25e..960bbd59 100644 --- a/src/unstructured_client/sources.py +++ b/src/unstructured_client/sources.py @@ -1,18 +1,15 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" - +from unstructured_client._hooks.custom.clean_server_url_hook import clean_server_url from .basesdk import BaseSDK from typing import Any, List, Mapping, Optional, Union, cast from unstructured_client import utils from unstructured_client._hooks import HookContext from unstructured_client.models import errors, operations, shared from unstructured_client.types import BaseModel, OptionalNullable, UNSET -from unstructured_client.sdkconfiguration import SERVER_PLATFORM_API, SERVERS class Sources(BaseSDK): def get_default_server_url(self) -> str: client_url, *_ = self.sdk_configuration.get_server_details() - if client_url is None: - return utils.remove_suffix(SERVERS[SERVER_PLATFORM_API], "/") return client_url def create_source( @@ -36,7 +33,7 @@ def create_source( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -149,7 +146,7 @@ async def create_source_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -262,7 +259,7 @@ def delete_source( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -365,7 +362,7 @@ async def delete_source_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -469,7 +466,7 @@ def get_source( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -575,7 +572,7 @@ async def get_source_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -681,7 +678,7 @@ def list_sources( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -787,7 +784,7 @@ async def list_sources_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -892,7 +889,7 @@ def update_source( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -1005,7 +1002,7 @@ async def update_source_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms diff --git a/src/unstructured_client/workflows.py b/src/unstructured_client/workflows.py index 35d13690..4bcee20d 100644 --- a/src/unstructured_client/workflows.py +++ b/src/unstructured_client/workflows.py @@ -1,19 +1,16 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" - +from unstructured_client._hooks.custom.clean_server_url_hook import clean_server_url from .basesdk import BaseSDK from typing import Any, List, Mapping, Optional, Union, cast from unstructured_client import utils from unstructured_client._hooks import HookContext from unstructured_client.models import errors, operations, shared from unstructured_client.types import BaseModel, OptionalNullable, UNSET -from unstructured_client.sdkconfiguration import SERVER_PLATFORM_API, SERVERS class Workflows(BaseSDK): def get_default_server_url(self) -> str: client_url, *_ = self.sdk_configuration.get_server_details() - if client_url is None: - return utils.remove_suffix(SERVERS[SERVER_PLATFORM_API], "/") return client_url def create_workflow( @@ -37,7 +34,7 @@ def create_workflow( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -146,7 +143,7 @@ async def create_workflow_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -255,7 +252,7 @@ def delete_workflow( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -360,7 +357,7 @@ async def delete_workflow_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -464,7 +461,7 @@ def get_workflow( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -570,7 +567,7 @@ async def get_workflow_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -676,7 +673,7 @@ def list_workflows( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -782,7 +779,7 @@ async def list_workflows_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -888,7 +885,7 @@ def run_workflow( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -1001,7 +998,7 @@ async def run_workflow_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -1114,7 +1111,7 @@ def update_workflow( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms @@ -1223,7 +1220,7 @@ async def update_workflow_async( :param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param http_headers: Additional headers to set or replace on requests. """ - base_url = server_url if server_url is not None else self.get_default_server_url() + base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms From afe0654acb5015571f09f8adf51deb2f962f1cab Mon Sep 17 00:00:00 2001 From: Yuming Long Date: Mon, 21 Apr 2025 13:54:27 -0700 Subject: [PATCH 07/21] ruff --- _test_unstructured_client/unit/test_custom_hooks.py | 2 +- _test_unstructured_client/unit/test_request_utils.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/_test_unstructured_client/unit/test_custom_hooks.py b/_test_unstructured_client/unit/test_custom_hooks.py index 7659a57f..33403efb 100644 --- a/_test_unstructured_client/unit/test_custom_hooks.py +++ b/_test_unstructured_client/unit/test_custom_hooks.py @@ -169,7 +169,7 @@ def mock_post(request): with pytest.raises(Exception): session.general.partition(request=req, retries=retries) - pattern = re.compile(f"Failed to process a request due to connection error .*? " + pattern = re.compile("Failed to process a request due to connection error .*? " "Attempting retry number 1 after sleep.") assert bool(pattern.search(caplog.text)) diff --git a/_test_unstructured_client/unit/test_request_utils.py b/_test_unstructured_client/unit/test_request_utils.py index 9910911f..72b7c04b 100644 --- a/_test_unstructured_client/unit/test_request_utils.py +++ b/_test_unstructured_client/unit/test_request_utils.py @@ -7,7 +7,6 @@ get_base_url, get_multipart_stream_fields, ) -from unstructured_client.models import shared # make the above test using @pytest.mark.parametrize From 68413fe6035ab667dadda62ca64fb15e4aecf090 Mon Sep 17 00:00:00 2001 From: Yuming Long Date: Mon, 21 Apr 2025 13:58:15 -0700 Subject: [PATCH 08/21] cover tests --- .../unit/test_server_urls.py | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/_test_unstructured_client/unit/test_server_urls.py b/_test_unstructured_client/unit/test_server_urls.py index 435ac2ea..c046a3aa 100644 --- a/_test_unstructured_client/unit/test_server_urls.py +++ b/_test_unstructured_client/unit/test_server_urls.py @@ -155,3 +155,125 @@ async def test_async_endpoint_uses_correct_url(monkeypatch, case: URLTestCase): pytest.fail( f"{case.description}: Expected {case.expected_url}, got {e}" ) + + +@pytest.mark.parametrize( + "case", + [ + URLTestCase( + description="non UNST domain client-level URL, no path", + sdk_endpoint_name="general.partition", + client_url="http://localhost:8000", + endpoint_url=None, + expected_url="http://localhost:8000" + ), + URLTestCase( + description="non UNST domain client-level URL, with path", + sdk_endpoint_name="general.partition", + client_url="http://localhost:8000/my/endpoint", + endpoint_url=None, + expected_url="http://localhost:8000/my/endpoint" + ), + URLTestCase( + description="non UNST domain endpoint-level URL, no path", + sdk_endpoint_name="general.partition", + client_url=None, + endpoint_url="http://localhost:8000", + expected_url="http://localhost:8000" + ), + URLTestCase( + description="non UNST domain endpoint-level URL, with path", + sdk_endpoint_name="general.partition", + client_url=None, + endpoint_url="http://localhost:8000/my/endpoint", + expected_url="http://localhost:8000/my/endpoint" + ), + URLTestCase( + description="UNST domain client-level URL, no path", + sdk_endpoint_name="general.partition", + client_url="https://unstructured-000mock.api.unstructuredapp.io", + endpoint_url=None, + expected_url="https://unstructured-000mock.api.unstructuredapp.io" + ), + URLTestCase( + description="UNST domain client-level URL, with path", + sdk_endpoint_name="general.partition", + client_url="https://unstructured-000mock.api.unstructuredapp.io/my/endpoint/", + endpoint_url=None, + expected_url="https://unstructured-000mock.api.unstructuredapp.io" + ), + URLTestCase( + description="UNST domain endpoint-level URL, no path", + sdk_endpoint_name="general.partition", + client_url=None, + endpoint_url="https://unstructured-000mock.api.unstructuredapp.io", + expected_url="https://unstructured-000mock.api.unstructuredapp.io" + ), + URLTestCase( + description="UNST domain endpoint-level URL, with path", + sdk_endpoint_name="general.partition", + client_url=None, + endpoint_url="https://unstructured-000mock.api.unstructuredapp.io/my/endpoint/", + expected_url="https://unstructured-000mock.api.unstructuredapp.io" + ), + URLTestCase( + description="default URL fallback", + sdk_endpoint_name="general.partition", + client_url=None, + endpoint_url=None, + expected_url="https://api.unstructuredapp.io" + ), + URLTestCase( + description="default URL fallback", + sdk_endpoint_name="destinations.create_destination", + client_url=None, + endpoint_url=None, + expected_url="https://platform.unstructuredapp.io" + ), + URLTestCase( + description="default URL fallback", + sdk_endpoint_name="sources.create_source", + client_url=None, + endpoint_url=None, + expected_url="https://platform.unstructuredapp.io" + ), + URLTestCase( + description="default URL fallback", + sdk_endpoint_name="jobs.get_job", + client_url=None, + endpoint_url=None, + expected_url="https://platform.unstructuredapp.io" + ), + URLTestCase( + description="default URL fallback", + sdk_endpoint_name="workflows.create_workflow", + client_url=None, + endpoint_url=None, + expected_url="https://platform.unstructuredapp.io" + ), + ] +) +def test_endpoint_uses_correct_url(monkeypatch, case: URLTestCase): + if case.client_url: + s = UnstructuredClient(server_url=case.client_url) + else: + s = UnstructuredClient() + + client_method = get_client_method_with_mock( + case.sdk_endpoint_name, + s, + case.expected_url, + monkeypatch + ) + + try: + if case.endpoint_url: + client_method(request={}, server_url=case.endpoint_url) + else: + client_method(request={}) + except BaseUrlCorrect: + pass + except BaseUrlIncorrect as e: + pytest.fail( + f"{case.description}: Expected {case.expected_url}, got {e}" + ) \ No newline at end of file From e151b482108d54d05b631ec5d38daf5a0452572b Mon Sep 17 00:00:00 2001 From: Yuming Long Date: Mon, 21 Apr 2025 14:22:09 -0700 Subject: [PATCH 09/21] tests --- .../unit/test_custom_hooks.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/_test_unstructured_client/unit/test_custom_hooks.py b/_test_unstructured_client/unit/test_custom_hooks.py index 33403efb..d36a3862 100644 --- a/_test_unstructured_client/unit/test_custom_hooks.py +++ b/_test_unstructured_client/unit/test_custom_hooks.py @@ -198,23 +198,20 @@ def test_unit_clean_server_url_fixes_malformed_paid_api_url(server_url: str): @pytest.mark.parametrize( - "server_url", + "server_url,expected_url", [ - # -- well-formed url -- - "http://localhost:8000", - # -- common malformed urls -- - "localhost:8000", - "localhost:8000/general/v0/general", - "http://localhost:8000/general/v0/general", + ("http://localhost:8000", "http://localhost:8000"), + ("localhost:8000", "http://localhost:8000"), + ("localhost:8000/general/v0/general", "http://localhost:8000/general/v0/general"), + ("http://localhost:8000/general/v0/general", "http://localhost:8000/general/v0/general"), ], ) -def test_unit_clean_server_url_fixes_malformed_localhost_url(server_url: str): +def test_unit_clean_server_url_fixes_non_unst_domain_url(server_url: str, expected_url: str): client = UnstructuredClient( server_url=server_url, api_key_auth=FAKE_KEY, ) - assert client.general.sdk_configuration.server_url == "http://localhost:8000" - + assert client.general.sdk_configuration.server_url == expected_url @pytest.mark.parametrize( "server_url", From 47b6131813d5bfd981e8f9d07221a6b30180b8c5 Mon Sep 17 00:00:00 2001 From: Yuming Long Date: Mon, 21 Apr 2025 14:31:21 -0700 Subject: [PATCH 10/21] clean also on server level --- .../unit/test_server_urls.py | 20 +++++++++---------- .../_hooks/custom/clean_server_url_hook.py | 2 +- src/unstructured_client/destinations.py | 2 +- src/unstructured_client/general.py | 6 +++--- src/unstructured_client/jobs.py | 2 +- src/unstructured_client/sources.py | 2 +- src/unstructured_client/workflows.py | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/_test_unstructured_client/unit/test_server_urls.py b/_test_unstructured_client/unit/test_server_urls.py index c046a3aa..85da040f 100644 --- a/_test_unstructured_client/unit/test_server_urls.py +++ b/_test_unstructured_client/unit/test_server_urls.py @@ -69,14 +69,14 @@ class URLTestCase: URLTestCase( description="non UNST domain client-level URL, no path", sdk_endpoint_name="general.partition_async", - client_url="http://localhost:8000", + client_url="http://localhost:8000/", endpoint_url=None, expected_url="http://localhost:8000" ), URLTestCase( description="non UNST domain client-level URL, with path", sdk_endpoint_name="general.partition_async", - client_url="http://localhost:8000/my/endpoint", + client_url="http://localhost:8000/my/endpoint/", endpoint_url=None, expected_url="http://localhost:8000/my/endpoint" ), @@ -84,14 +84,14 @@ class URLTestCase: description="non UNST domain endpoint-level URL, no path", sdk_endpoint_name="general.partition_async", client_url=None, - endpoint_url="http://localhost:8000", + endpoint_url="http://localhost:8000/", expected_url="http://localhost:8000" ), URLTestCase( description="non UNST domain endpoint-level URL, with path", sdk_endpoint_name="general.partition_async", client_url=None, - endpoint_url="http://localhost:8000/my/endpoint", + endpoint_url="http://localhost:8000/my/endpoint/", expected_url="http://localhost:8000/my/endpoint" ), URLTestCase( @@ -162,28 +162,28 @@ async def test_async_endpoint_uses_correct_url(monkeypatch, case: URLTestCase): [ URLTestCase( description="non UNST domain client-level URL, no path", - sdk_endpoint_name="general.partition", - client_url="http://localhost:8000", + sdk_endpoint_name="destinations.create_destination", + client_url="http://localhost:8000/", endpoint_url=None, expected_url="http://localhost:8000" ), URLTestCase( description="non UNST domain client-level URL, with path", - sdk_endpoint_name="general.partition", - client_url="http://localhost:8000/my/endpoint", + sdk_endpoint_name="sources.create_source", + client_url="http://localhost:8000/my/endpoint/", endpoint_url=None, expected_url="http://localhost:8000/my/endpoint" ), URLTestCase( description="non UNST domain endpoint-level URL, no path", - sdk_endpoint_name="general.partition", + sdk_endpoint_name="jobs.get_job", client_url=None, endpoint_url="http://localhost:8000", expected_url="http://localhost:8000" ), URLTestCase( description="non UNST domain endpoint-level URL, with path", - sdk_endpoint_name="general.partition", + sdk_endpoint_name="workflows.create_workflow", client_url=None, endpoint_url="http://localhost:8000/my/endpoint", expected_url="http://localhost:8000/my/endpoint" diff --git a/src/unstructured_client/_hooks/custom/clean_server_url_hook.py b/src/unstructured_client/_hooks/custom/clean_server_url_hook.py index 87b94352..d8c04590 100644 --- a/src/unstructured_client/_hooks/custom/clean_server_url_hook.py +++ b/src/unstructured_client/_hooks/custom/clean_server_url_hook.py @@ -29,7 +29,7 @@ def clean_server_url(base_url: str) -> str: # For other domains, we want to keep the path clean_url = urlunparse(parsed_url._replace(params="", query="", fragment="")) - return clean_url + return clean_url.rstrip("/") diff --git a/src/unstructured_client/destinations.py b/src/unstructured_client/destinations.py index edacd462..bff960cf 100644 --- a/src/unstructured_client/destinations.py +++ b/src/unstructured_client/destinations.py @@ -10,7 +10,7 @@ class Destinations(BaseSDK): def get_default_server_url(self) -> str: client_url, *_ = self.sdk_configuration.get_server_details() - return client_url + return clean_server_url(client_url) def create_destination( diff --git a/src/unstructured_client/general.py b/src/unstructured_client/general.py index 5ae9c77a..73a8006e 100644 --- a/src/unstructured_client/general.py +++ b/src/unstructured_client/general.py @@ -18,12 +18,12 @@ class PartitionAcceptEnum(str, Enum): class General(BaseSDK): def get_default_server_url(self) -> str: client_url, *_ = self.sdk_configuration.get_server_details() - if client_url == utils.remove_suffix(SERVERS[SERVER_PLATFORM_API], "/"): + if client_url == SERVERS[SERVER_PLATFORM_API].rstrip("/"): #Note(yuming):get_server_details will set the default server to platform-api return operations.PARTITION_SERVERS[ operations.PARTITION_SERVER_SAAS_API - ] - return client_url + ].rstrip("/") + return clean_server_url(client_url) def partition( self, diff --git a/src/unstructured_client/jobs.py b/src/unstructured_client/jobs.py index 086ed54f..27b0b505 100644 --- a/src/unstructured_client/jobs.py +++ b/src/unstructured_client/jobs.py @@ -10,7 +10,7 @@ class Jobs(BaseSDK): def get_default_server_url(self) -> str: client_url, *_ = self.sdk_configuration.get_server_details() - return client_url + return clean_server_url(client_url) def cancel_job( self, diff --git a/src/unstructured_client/sources.py b/src/unstructured_client/sources.py index 960bbd59..48c81032 100644 --- a/src/unstructured_client/sources.py +++ b/src/unstructured_client/sources.py @@ -10,7 +10,7 @@ class Sources(BaseSDK): def get_default_server_url(self) -> str: client_url, *_ = self.sdk_configuration.get_server_details() - return client_url + return clean_server_url(client_url) def create_source( self, diff --git a/src/unstructured_client/workflows.py b/src/unstructured_client/workflows.py index 4bcee20d..248dc8ec 100644 --- a/src/unstructured_client/workflows.py +++ b/src/unstructured_client/workflows.py @@ -11,7 +11,7 @@ class Workflows(BaseSDK): def get_default_server_url(self) -> str: client_url, *_ = self.sdk_configuration.get_server_details() - return client_url + return clean_server_url(client_url) def create_workflow( self, From 86af8fcb0c97f709947792d02f8754e56b6a89ae Mon Sep 17 00:00:00 2001 From: Yuming Long Date: Mon, 21 Apr 2025 14:52:58 -0700 Subject: [PATCH 11/21] gen ignore --- .genignore | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.genignore b/.genignore index e5adb336..240c9d4a 100644 --- a/.genignore +++ b/.genignore @@ -1,7 +1,7 @@ # https://www.speakeasy.com/docs/customize/code/monkey-patching # ignore human-written files and directories -# src/unstructured_client/_unstructured +src/unstructured_client/_unstructured _jupyter _sample_docs _test_unstructured_client @@ -10,4 +10,8 @@ _test_unstructured_client Makefile # Ignore the general.partition code until we can fix the base_url issue -# src/unstructured_client/general.py +src/unstructured_client/general.py +src/unstructured_client/destinations.py +src/unstructured_client/sources.py +src/unstructured_client/jobs.py +src/unstructured_client/workflows.py From 96390624c118c820cca46d7c9ea94d9c1552268a Mon Sep 17 00:00:00 2001 From: Yuming Long Date: Mon, 21 Apr 2025 17:21:27 -0700 Subject: [PATCH 12/21] i am just testing --- .genignore | 8 -------- gen.yaml | 2 +- src/unstructured_client/general.py | 6 ++++-- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.genignore b/.genignore index 240c9d4a..feb6bc18 100644 --- a/.genignore +++ b/.genignore @@ -1,7 +1,5 @@ # https://www.speakeasy.com/docs/customize/code/monkey-patching -# ignore human-written files and directories -src/unstructured_client/_unstructured _jupyter _sample_docs _test_unstructured_client @@ -9,9 +7,3 @@ _test_unstructured_client # ignore Makefile Makefile -# Ignore the general.partition code until we can fix the base_url issue -src/unstructured_client/general.py -src/unstructured_client/destinations.py -src/unstructured_client/sources.py -src/unstructured_client/jobs.py -src/unstructured_client/workflows.py diff --git a/gen.yaml b/gen.yaml index 35688474..b6d54e2f 100644 --- a/gen.yaml +++ b/gen.yaml @@ -34,7 +34,7 @@ python: clientServerStatusCodesAsErrors: true defaultErrorName: SDKError description: Python Client SDK for Unstructured API - enableCustomCodeRegions: false + enableCustomCodeRegions: true enumFormat: enum fixFlags: responseRequiredSep2024: false diff --git a/src/unstructured_client/general.py b/src/unstructured_client/general.py index 73a8006e..bed3d486 100644 --- a/src/unstructured_client/general.py +++ b/src/unstructured_client/general.py @@ -16,6 +16,7 @@ class PartitionAcceptEnum(str, Enum): class General(BaseSDK): + # region sdk-class-body def get_default_server_url(self) -> str: client_url, *_ = self.sdk_configuration.get_server_details() if client_url == SERVERS[SERVER_PLATFORM_API].rstrip("/"): @@ -24,7 +25,7 @@ def get_default_server_url(self) -> str: operations.PARTITION_SERVER_SAAS_API ].rstrip("/") return clean_server_url(client_url) - + # endregion sdk-class-body def partition( self, *, @@ -48,12 +49,13 @@ def partition( :param accept_header_override: Override the default accept header for this method :param http_headers: Additional headers to set or replace on requests. """ + # endregion sdk-class-body base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - + # endregion sdk-class-body if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.PartitionRequest) request = cast(operations.PartitionRequest, request) From 6553ee00b70817daf493c47edea25f0e154df1a4 Mon Sep 17 00:00:00 2001 From: Yuming Long Date: Mon, 21 Apr 2025 17:36:38 -0700 Subject: [PATCH 13/21] Revert "i am just testing" This reverts commit 96390624c118c820cca46d7c9ea94d9c1552268a. --- .genignore | 8 ++++++++ gen.yaml | 2 +- src/unstructured_client/general.py | 6 ++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.genignore b/.genignore index feb6bc18..240c9d4a 100644 --- a/.genignore +++ b/.genignore @@ -1,5 +1,7 @@ # https://www.speakeasy.com/docs/customize/code/monkey-patching +# ignore human-written files and directories +src/unstructured_client/_unstructured _jupyter _sample_docs _test_unstructured_client @@ -7,3 +9,9 @@ _test_unstructured_client # ignore Makefile Makefile +# Ignore the general.partition code until we can fix the base_url issue +src/unstructured_client/general.py +src/unstructured_client/destinations.py +src/unstructured_client/sources.py +src/unstructured_client/jobs.py +src/unstructured_client/workflows.py diff --git a/gen.yaml b/gen.yaml index b6d54e2f..35688474 100644 --- a/gen.yaml +++ b/gen.yaml @@ -34,7 +34,7 @@ python: clientServerStatusCodesAsErrors: true defaultErrorName: SDKError description: Python Client SDK for Unstructured API - enableCustomCodeRegions: true + enableCustomCodeRegions: false enumFormat: enum fixFlags: responseRequiredSep2024: false diff --git a/src/unstructured_client/general.py b/src/unstructured_client/general.py index bed3d486..73a8006e 100644 --- a/src/unstructured_client/general.py +++ b/src/unstructured_client/general.py @@ -16,7 +16,6 @@ class PartitionAcceptEnum(str, Enum): class General(BaseSDK): - # region sdk-class-body def get_default_server_url(self) -> str: client_url, *_ = self.sdk_configuration.get_server_details() if client_url == SERVERS[SERVER_PLATFORM_API].rstrip("/"): @@ -25,7 +24,7 @@ def get_default_server_url(self) -> str: operations.PARTITION_SERVER_SAAS_API ].rstrip("/") return clean_server_url(client_url) - # endregion sdk-class-body + def partition( self, *, @@ -49,13 +48,12 @@ def partition( :param accept_header_override: Override the default accept header for this method :param http_headers: Additional headers to set or replace on requests. """ - # endregion sdk-class-body base_url = clean_server_url(server_url) if server_url is not None else self.get_default_server_url() url_variables = None if timeout_ms is None: timeout_ms = self.sdk_configuration.timeout_ms - # endregion sdk-class-body + if not isinstance(request, BaseModel): request = utils.unmarshal(request, operations.PartitionRequest) request = cast(operations.PartitionRequest, request) From 8b72882e3fd554d35ba0f2fff28a49e6e15331da Mon Sep 17 00:00:00 2001 From: Yuming Long Date: Mon, 21 Apr 2025 18:43:31 -0700 Subject: [PATCH 14/21] maybe don't ignore --- .genignore | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.genignore b/.genignore index 240c9d4a..b3472289 100644 --- a/.genignore +++ b/.genignore @@ -1,7 +1,6 @@ # https://www.speakeasy.com/docs/customize/code/monkey-patching # ignore human-written files and directories -src/unstructured_client/_unstructured _jupyter _sample_docs _test_unstructured_client @@ -9,9 +8,3 @@ _test_unstructured_client # ignore Makefile Makefile -# Ignore the general.partition code until we can fix the base_url issue -src/unstructured_client/general.py -src/unstructured_client/destinations.py -src/unstructured_client/sources.py -src/unstructured_client/jobs.py -src/unstructured_client/workflows.py From bd8d0a955b262cf877dce2b6fc23e4ac959f2cae Mon Sep 17 00:00:00 2001 From: Yuming Long Date: Mon, 21 Apr 2025 19:13:51 -0700 Subject: [PATCH 15/21] new version --- .gitignore | 3 +-- .speakeasy/gen.lock | 20 +++++++++++--------- gen.yaml | 2 +- poetry.lock | 18 +++--------------- pyproject.toml | 4 +--- src/unstructured_client/_version.py | 6 +++--- 6 files changed, 20 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index 214f57bf..32264e26 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.speakeasy/temp/ .speakeasy/reports .venv/ README-PYPI.md @@ -11,10 +12,8 @@ __pycache__/ # human-added igore files .ipynb_checkpoints/ .idea/ - .local *.ipynb - openapi.json openapi_client.json openapi_serverless.json diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 1c555d20..2f96e3bc 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: 8b5fa338-9106-4734-abf0-e30d67044a90 management: - docChecksum: 6433f28e5b70c3c0d7754fc7a88db327 + docChecksum: 008302e535886666d303b5a03b8236c2 docVersion: 1.1.7 - speakeasyVersion: 1.535.1 - generationVersion: 2.585.2 - releaseVersion: 0.33.1 - configChecksum: 8b5e7fbd95d040ba09964f3c97c3156a + speakeasyVersion: 1.537.0 + generationVersion: 2.588.0 + releaseVersion: 0.34.0 + configChecksum: 0ba814fcbe0d0489903de407d36313af repoURL: https://github.com/Unstructured-IO/unstructured-python-client.git repoSubDirectory: . installationURL: https://github.com/Unstructured-IO/unstructured-python-client.git @@ -16,7 +16,7 @@ features: acceptHeaders: 3.0.0 additionalDependencies: 1.0.0 constsAndDefaults: 1.0.5 - core: 5.14.0 + core: 5.15.0 defaultEnabledRetries: 0.2.0 enumUnions: 0.1.0 envVarSecurityUsage: 0.3.2 @@ -228,6 +228,7 @@ generatedFiles: - src/unstructured_client/_version.py - src/unstructured_client/basesdk.py - src/unstructured_client/destinations.py + - src/unstructured_client/general.py - src/unstructured_client/httpclient.py - src/unstructured_client/jobs.py - src/unstructured_client/models/__init__.py @@ -369,6 +370,7 @@ generatedFiles: - src/unstructured_client/types/basemodel.py - src/unstructured_client/utils/__init__.py - src/unstructured_client/utils/annotations.py + - src/unstructured_client/utils/datetimes.py - src/unstructured_client/utils/enums.py - src/unstructured_client/utils/eventstreaming.py - src/unstructured_client/utils/forms.py @@ -668,7 +670,7 @@ examples: "200": application/json: {"created_at": "2025-03-13T23:31:02.383Z", "id": "c3274f55-9861-4e4e-8526-4273aa4d2772", "status": "FAILURE"} "422": - application/json: {"detail": [{"loc": [""], "msg": "", "type": ""}, {"loc": [], "msg": "", "type": ""}, {"loc": [], "msg": "", "type": ""}]} + application/json: {"detail": ""} create_connection_check_sources: speakeasy-default-create-connection-check-sources: parameters: @@ -679,7 +681,7 @@ examples: "202": application/json: {"created_at": "2023-03-12T05:54:05.025Z", "id": "b5793adb-057f-470c-ae7e-309d786a99eb", "status": "SUCCESS"} "422": - application/json: {"detail": []} + application/json: {"detail": ""} get_connection_check_sources: speakeasy-default-get-connection-check-sources: parameters: @@ -690,6 +692,6 @@ examples: "200": application/json: {"created_at": "2023-09-12T00:38:55.692Z", "id": "f7d1d931-a753-4fe9-ae3f-671f188a9b55", "status": "SUCCESS"} "422": - application/json: {"detail": [{"loc": [""], "msg": "", "type": ""}, {"loc": [], "msg": "", "type": ""}]} + application/json: {"detail": ""} examplesVersion: 1.0.1 generatedTests: {} diff --git a/gen.yaml b/gen.yaml index 35688474..36f1fae2 100644 --- a/gen.yaml +++ b/gen.yaml @@ -12,7 +12,7 @@ generation: oAuth2ClientCredentialsEnabled: false oAuth2PasswordEnabled: false python: - version: 0.33.1 + version: 0.34.0 additionalDependencies: dev: deepdiff: '>=6.0' diff --git a/poetry.lock b/poetry.lock index 16b71d96..e0f55f92 100644 --- a/poetry.lock +++ b/poetry.lock @@ -930,7 +930,7 @@ version = "2.8.2" description = "Extensions to the standard Python datetime module" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" -groups = ["main", "dev"] +groups = ["dev"] files = [ {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, @@ -982,7 +982,7 @@ version = "1.16.0" description = "Python 2 and 3 compatibility utilities" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" -groups = ["main", "dev"] +groups = ["dev"] files = [ {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, @@ -1037,18 +1037,6 @@ files = [ {file = "types_aiofiles-24.1.0.20240626-py3-none-any.whl", hash = "sha256:7939eca4a8b4f9c6491b6e8ef160caee9a21d32e18534a57d5ed90aee47c66b4"}, ] -[[package]] -name = "types-python-dateutil" -version = "2.9.0.20241003" -description = "Typing stubs for python-dateutil" -optional = false -python-versions = ">=3.8" -groups = ["dev"] -files = [ - {file = "types-python-dateutil-2.9.0.20241003.tar.gz", hash = "sha256:58cb85449b2a56d6684e41aeefb4c4280631246a0da1a719bdbe6f3fb0317446"}, - {file = "types_python_dateutil-2.9.0.20241003-py3-none-any.whl", hash = "sha256:250e1d8e80e7bbc3a6c99b907762711d1a1cdd00e978ad39cb5940f6f0a87f3d"}, -] - [[package]] name = "typing-extensions" version = "4.12.2" @@ -1149,4 +1137,4 @@ test = ["aiohttp (>=3.10.5)", "flake8 (>=5.0,<6.0)", "mypy (>=0.800)", "psutil", [metadata] lock-version = "2.1" python-versions = ">=3.9" -content-hash = "73969f5008660fe0c90c961d9d7cfca0e108f73a2dd6fe6a647cab04ca1f66e3" +content-hash = "78203fbab14338991dfb8810278b0eb421816fcfb55a8771e0c6079bb56aabea" diff --git a/pyproject.toml b/pyproject.toml index 758c990c..158c0ab6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "unstructured-client" -version = "0.33.1" +version = "0.34.0" description = "Python Client SDK for Unstructured API" authors = [{ name = "Unstructured" },] readme = "README-PYPI.md" @@ -13,7 +13,6 @@ dependencies = [ "nest-asyncio >=1.6.0", "pydantic >=2.11.2", "pypdf >=4.0", - "python-dateutil >=2.8.2", "requests-toolbelt >=1.0.0", "typing-inspection >=0.4.0", ] @@ -41,7 +40,6 @@ pytest = ">=8.3.3" pytest-asyncio = ">=0.24.0" pytest-mock = ">=3.14.0" types-aiofiles = ">=24.1.0" -types-python-dateutil = "^2.9.0.20240316" uvloop = ">=0.20.0" [build-system] diff --git a/src/unstructured_client/_version.py b/src/unstructured_client/_version.py index 5ceb97af..e24f349a 100644 --- a/src/unstructured_client/_version.py +++ b/src/unstructured_client/_version.py @@ -3,10 +3,10 @@ import importlib.metadata __title__: str = "unstructured-client" -__version__: str = "0.33.1" +__version__: str = "0.34.0" __openapi_doc_version__: str = "1.1.7" -__gen_version__: str = "2.585.2" -__user_agent__: str = "speakeasy-sdk/python 0.33.1 2.585.2 1.1.7 unstructured-client" +__gen_version__: str = "2.588.0" +__user_agent__: str = "speakeasy-sdk/python 0.34.0 2.588.0 1.1.7 unstructured-client" try: if __package__ is not None: From 0c93267f3e50785d8c1c7518c3cc660ef5214b2b Mon Sep 17 00:00:00 2001 From: Yuming Long Date: Tue, 22 Apr 2025 08:01:23 -0700 Subject: [PATCH 16/21] type error? --- _test_unstructured_client/unit/test_server_urls.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_test_unstructured_client/unit/test_server_urls.py b/_test_unstructured_client/unit/test_server_urls.py index 85da040f..b402c0b4 100644 --- a/_test_unstructured_client/unit/test_server_urls.py +++ b/_test_unstructured_client/unit/test_server_urls.py @@ -56,9 +56,9 @@ class URLTestCase: description: str sdk_endpoint_name: str # url when you init the client (global for all endpoints) - client_url: str | None + client_url: str | None = None # url when you init the SDK endpoint (vary per endpoint) - endpoint_url: str | None + endpoint_url: str | None = None # expected url when actually making the HTTP request in build_request expected_url: str From 847042179e6e81d0c7cfe5c5d4a789234a4683c4 Mon Sep 17 00:00:00 2001 From: Yuming Long Date: Tue, 22 Apr 2025 08:02:55 -0700 Subject: [PATCH 17/21] Revert "new version" This reverts commit bd8d0a955b262cf877dce2b6fc23e4ac959f2cae. --- .gitignore | 3 ++- .speakeasy/gen.lock | 20 +++++++++----------- gen.yaml | 2 +- poetry.lock | 18 +++++++++++++++--- pyproject.toml | 4 +++- src/unstructured_client/_version.py | 6 +++--- 6 files changed, 33 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 32264e26..214f57bf 100755 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -.speakeasy/temp/ .speakeasy/reports .venv/ README-PYPI.md @@ -12,8 +11,10 @@ __pycache__/ # human-added igore files .ipynb_checkpoints/ .idea/ + .local *.ipynb + openapi.json openapi_client.json openapi_serverless.json diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 2f96e3bc..1c555d20 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: 8b5fa338-9106-4734-abf0-e30d67044a90 management: - docChecksum: 008302e535886666d303b5a03b8236c2 + docChecksum: 6433f28e5b70c3c0d7754fc7a88db327 docVersion: 1.1.7 - speakeasyVersion: 1.537.0 - generationVersion: 2.588.0 - releaseVersion: 0.34.0 - configChecksum: 0ba814fcbe0d0489903de407d36313af + speakeasyVersion: 1.535.1 + generationVersion: 2.585.2 + releaseVersion: 0.33.1 + configChecksum: 8b5e7fbd95d040ba09964f3c97c3156a repoURL: https://github.com/Unstructured-IO/unstructured-python-client.git repoSubDirectory: . installationURL: https://github.com/Unstructured-IO/unstructured-python-client.git @@ -16,7 +16,7 @@ features: acceptHeaders: 3.0.0 additionalDependencies: 1.0.0 constsAndDefaults: 1.0.5 - core: 5.15.0 + core: 5.14.0 defaultEnabledRetries: 0.2.0 enumUnions: 0.1.0 envVarSecurityUsage: 0.3.2 @@ -228,7 +228,6 @@ generatedFiles: - src/unstructured_client/_version.py - src/unstructured_client/basesdk.py - src/unstructured_client/destinations.py - - src/unstructured_client/general.py - src/unstructured_client/httpclient.py - src/unstructured_client/jobs.py - src/unstructured_client/models/__init__.py @@ -370,7 +369,6 @@ generatedFiles: - src/unstructured_client/types/basemodel.py - src/unstructured_client/utils/__init__.py - src/unstructured_client/utils/annotations.py - - src/unstructured_client/utils/datetimes.py - src/unstructured_client/utils/enums.py - src/unstructured_client/utils/eventstreaming.py - src/unstructured_client/utils/forms.py @@ -670,7 +668,7 @@ examples: "200": application/json: {"created_at": "2025-03-13T23:31:02.383Z", "id": "c3274f55-9861-4e4e-8526-4273aa4d2772", "status": "FAILURE"} "422": - application/json: {"detail": ""} + application/json: {"detail": [{"loc": [""], "msg": "", "type": ""}, {"loc": [], "msg": "", "type": ""}, {"loc": [], "msg": "", "type": ""}]} create_connection_check_sources: speakeasy-default-create-connection-check-sources: parameters: @@ -681,7 +679,7 @@ examples: "202": application/json: {"created_at": "2023-03-12T05:54:05.025Z", "id": "b5793adb-057f-470c-ae7e-309d786a99eb", "status": "SUCCESS"} "422": - application/json: {"detail": ""} + application/json: {"detail": []} get_connection_check_sources: speakeasy-default-get-connection-check-sources: parameters: @@ -692,6 +690,6 @@ examples: "200": application/json: {"created_at": "2023-09-12T00:38:55.692Z", "id": "f7d1d931-a753-4fe9-ae3f-671f188a9b55", "status": "SUCCESS"} "422": - application/json: {"detail": ""} + application/json: {"detail": [{"loc": [""], "msg": "", "type": ""}, {"loc": [], "msg": "", "type": ""}]} examplesVersion: 1.0.1 generatedTests: {} diff --git a/gen.yaml b/gen.yaml index 36f1fae2..35688474 100644 --- a/gen.yaml +++ b/gen.yaml @@ -12,7 +12,7 @@ generation: oAuth2ClientCredentialsEnabled: false oAuth2PasswordEnabled: false python: - version: 0.34.0 + version: 0.33.1 additionalDependencies: dev: deepdiff: '>=6.0' diff --git a/poetry.lock b/poetry.lock index e0f55f92..16b71d96 100644 --- a/poetry.lock +++ b/poetry.lock @@ -930,7 +930,7 @@ version = "2.8.2" description = "Extensions to the standard Python datetime module" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" -groups = ["dev"] +groups = ["main", "dev"] files = [ {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, @@ -982,7 +982,7 @@ version = "1.16.0" description = "Python 2 and 3 compatibility utilities" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" -groups = ["dev"] +groups = ["main", "dev"] files = [ {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, @@ -1037,6 +1037,18 @@ files = [ {file = "types_aiofiles-24.1.0.20240626-py3-none-any.whl", hash = "sha256:7939eca4a8b4f9c6491b6e8ef160caee9a21d32e18534a57d5ed90aee47c66b4"}, ] +[[package]] +name = "types-python-dateutil" +version = "2.9.0.20241003" +description = "Typing stubs for python-dateutil" +optional = false +python-versions = ">=3.8" +groups = ["dev"] +files = [ + {file = "types-python-dateutil-2.9.0.20241003.tar.gz", hash = "sha256:58cb85449b2a56d6684e41aeefb4c4280631246a0da1a719bdbe6f3fb0317446"}, + {file = "types_python_dateutil-2.9.0.20241003-py3-none-any.whl", hash = "sha256:250e1d8e80e7bbc3a6c99b907762711d1a1cdd00e978ad39cb5940f6f0a87f3d"}, +] + [[package]] name = "typing-extensions" version = "4.12.2" @@ -1137,4 +1149,4 @@ test = ["aiohttp (>=3.10.5)", "flake8 (>=5.0,<6.0)", "mypy (>=0.800)", "psutil", [metadata] lock-version = "2.1" python-versions = ">=3.9" -content-hash = "78203fbab14338991dfb8810278b0eb421816fcfb55a8771e0c6079bb56aabea" +content-hash = "73969f5008660fe0c90c961d9d7cfca0e108f73a2dd6fe6a647cab04ca1f66e3" diff --git a/pyproject.toml b/pyproject.toml index 158c0ab6..758c990c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "unstructured-client" -version = "0.34.0" +version = "0.33.1" description = "Python Client SDK for Unstructured API" authors = [{ name = "Unstructured" },] readme = "README-PYPI.md" @@ -13,6 +13,7 @@ dependencies = [ "nest-asyncio >=1.6.0", "pydantic >=2.11.2", "pypdf >=4.0", + "python-dateutil >=2.8.2", "requests-toolbelt >=1.0.0", "typing-inspection >=0.4.0", ] @@ -40,6 +41,7 @@ pytest = ">=8.3.3" pytest-asyncio = ">=0.24.0" pytest-mock = ">=3.14.0" types-aiofiles = ">=24.1.0" +types-python-dateutil = "^2.9.0.20240316" uvloop = ">=0.20.0" [build-system] diff --git a/src/unstructured_client/_version.py b/src/unstructured_client/_version.py index e24f349a..5ceb97af 100644 --- a/src/unstructured_client/_version.py +++ b/src/unstructured_client/_version.py @@ -3,10 +3,10 @@ import importlib.metadata __title__: str = "unstructured-client" -__version__: str = "0.34.0" +__version__: str = "0.33.1" __openapi_doc_version__: str = "1.1.7" -__gen_version__: str = "2.588.0" -__user_agent__: str = "speakeasy-sdk/python 0.34.0 2.588.0 1.1.7 unstructured-client" +__gen_version__: str = "2.585.2" +__user_agent__: str = "speakeasy-sdk/python 0.33.1 2.585.2 1.1.7 unstructured-client" try: if __package__ is not None: From d41d0d56c1e7ca456fd86731040f14d7d7b4f3d8 Mon Sep 17 00:00:00 2001 From: Yuming Long Date: Tue, 22 Apr 2025 08:06:59 -0700 Subject: [PATCH 18/21] version lint? --- _test_unstructured_client/unit/test_server_urls.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/_test_unstructured_client/unit/test_server_urls.py b/_test_unstructured_client/unit/test_server_urls.py index b402c0b4..661dbc40 100644 --- a/_test_unstructured_client/unit/test_server_urls.py +++ b/_test_unstructured_client/unit/test_server_urls.py @@ -1,7 +1,7 @@ import pytest from dataclasses import dataclass from unstructured_client import UnstructuredClient, utils - +from typing import Optional # Raise one of these from our mock to return to the test code class BaseUrlCorrect(Exception): @@ -55,12 +55,12 @@ def mock_build_request(*args, base_url, **kwargs): class URLTestCase: description: str sdk_endpoint_name: str - # url when you init the client (global for all endpoints) - client_url: str | None = None - # url when you init the SDK endpoint (vary per endpoint) - endpoint_url: str | None = None # expected url when actually making the HTTP request in build_request expected_url: str + # url when you init the client (global for all endpoints) + client_url: Optional[str] = None + # url when you init the SDK endpoint (vary per endpoint) + endpoint_url: Optional[str] = None @pytest.mark.asyncio @pytest.mark.parametrize( From b127e443472bab8d835f2d4106961aab272d3e17 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 22 Apr 2025 08:19:46 -0700 Subject: [PATCH 19/21] =?UTF-8?q?chore:=20=F0=9F=90=9D=20Update=20SDK=20-?= =?UTF-8?q?=20Generate=200.34.0=20(#266)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > [!IMPORTANT] > revert base_url changes ``` git checkout yuming/custom_url src/unstructured_client/destinations.py git checkout yuming/custom_url src/unstructured_client/sources.py git checkout yuming/custom_url src/unstructured_client/jobs.py git checkout yuming/custom_url src/unstructured_client/workflows.py git checkout yuming/custom_url src/unstructured_client/general.py ``` > Linting report available at: > OpenAPI Change report available at: # SDK update Based on: - OpenAPI Doc - Speakeasy CLI 1.537.0 (2.588.0) https://github.com/speakeasy-api/speakeasy ## Versioning Version Bump Type: [minor] - 🤖 (automated) ## OpenAPI Change Summary No specification changes ## PYTHON CHANGELOG ## core: 5.15.0 - 2025-04-17 ### :bee: New Features - Remove python-dateutil dependency *(commit by [@bflad](https://github.com/bflad))* --------- Co-authored-by: speakeasybot Co-authored-by: Yuming Long --- .gitignore | 3 +-- .speakeasy/gen.lock | 18 +++++++++-------- .speakeasy/workflow.lock | 10 +++++----- RELEASES.md | 12 ++++++++++- gen.yaml | 2 +- poetry.lock | 18 +++-------------- pyproject.toml | 4 +--- src/unstructured_client/_version.py | 6 +++--- src/unstructured_client/utils/__init__.py | 1 + src/unstructured_client/utils/datetimes.py | 23 ++++++++++++++++++++++ 10 files changed, 59 insertions(+), 38 deletions(-) create mode 100644 src/unstructured_client/utils/datetimes.py diff --git a/.gitignore b/.gitignore index 214f57bf..32264e26 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.speakeasy/temp/ .speakeasy/reports .venv/ README-PYPI.md @@ -11,10 +12,8 @@ __pycache__/ # human-added igore files .ipynb_checkpoints/ .idea/ - .local *.ipynb - openapi.json openapi_client.json openapi_serverless.json diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 1c555d20..5a22a1cb 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -3,10 +3,10 @@ id: 8b5fa338-9106-4734-abf0-e30d67044a90 management: docChecksum: 6433f28e5b70c3c0d7754fc7a88db327 docVersion: 1.1.7 - speakeasyVersion: 1.535.1 - generationVersion: 2.585.2 - releaseVersion: 0.33.1 - configChecksum: 8b5e7fbd95d040ba09964f3c97c3156a + speakeasyVersion: 1.537.0 + generationVersion: 2.588.0 + releaseVersion: 0.34.0 + configChecksum: 0ba814fcbe0d0489903de407d36313af repoURL: https://github.com/Unstructured-IO/unstructured-python-client.git repoSubDirectory: . installationURL: https://github.com/Unstructured-IO/unstructured-python-client.git @@ -16,7 +16,7 @@ features: acceptHeaders: 3.0.0 additionalDependencies: 1.0.0 constsAndDefaults: 1.0.5 - core: 5.14.0 + core: 5.15.0 defaultEnabledRetries: 0.2.0 enumUnions: 0.1.0 envVarSecurityUsage: 0.3.2 @@ -228,6 +228,7 @@ generatedFiles: - src/unstructured_client/_version.py - src/unstructured_client/basesdk.py - src/unstructured_client/destinations.py + - src/unstructured_client/general.py - src/unstructured_client/httpclient.py - src/unstructured_client/jobs.py - src/unstructured_client/models/__init__.py @@ -369,6 +370,7 @@ generatedFiles: - src/unstructured_client/types/basemodel.py - src/unstructured_client/utils/__init__.py - src/unstructured_client/utils/annotations.py + - src/unstructured_client/utils/datetimes.py - src/unstructured_client/utils/enums.py - src/unstructured_client/utils/eventstreaming.py - src/unstructured_client/utils/forms.py @@ -668,7 +670,7 @@ examples: "200": application/json: {"created_at": "2025-03-13T23:31:02.383Z", "id": "c3274f55-9861-4e4e-8526-4273aa4d2772", "status": "FAILURE"} "422": - application/json: {"detail": [{"loc": [""], "msg": "", "type": ""}, {"loc": [], "msg": "", "type": ""}, {"loc": [], "msg": "", "type": ""}]} + application/json: {"detail": ""} create_connection_check_sources: speakeasy-default-create-connection-check-sources: parameters: @@ -679,7 +681,7 @@ examples: "202": application/json: {"created_at": "2023-03-12T05:54:05.025Z", "id": "b5793adb-057f-470c-ae7e-309d786a99eb", "status": "SUCCESS"} "422": - application/json: {"detail": []} + application/json: {"detail": ""} get_connection_check_sources: speakeasy-default-get-connection-check-sources: parameters: @@ -690,6 +692,6 @@ examples: "200": application/json: {"created_at": "2023-09-12T00:38:55.692Z", "id": "f7d1d931-a753-4fe9-ae3f-671f188a9b55", "status": "SUCCESS"} "422": - application/json: {"detail": [{"loc": [""], "msg": "", "type": ""}, {"loc": [], "msg": "", "type": ""}]} + application/json: {"detail": ""} examplesVersion: 1.0.1 generatedTests: {} diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 76866fdf..7d58570d 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,21 +1,21 @@ -speakeasyVersion: 1.535.1 +speakeasyVersion: 1.537.0 sources: my-source: sourceNamespace: my-source - sourceRevisionDigest: sha256:6771a944eaf5581cde4835c43e7997635f7d80ce441763c47cad9c305ba4a91e + sourceRevisionDigest: sha256:f5fa536ffbf6240b18b267193074d11564a899dd6fdee36261205b93c8f84880 sourceBlobDigest: sha256:521a1c7be485e2be9f33ff7b82566823e96827cb69f7ca7775e0dd3dcc52d825 tags: - latest - - speakeasy-sdk-regen-1745261613 + - speakeasy-sdk-regen-1745334275 - 1.1.7 targets: unstructured-python: source: my-source sourceNamespace: my-source - sourceRevisionDigest: sha256:6771a944eaf5581cde4835c43e7997635f7d80ce441763c47cad9c305ba4a91e + sourceRevisionDigest: sha256:f5fa536ffbf6240b18b267193074d11564a899dd6fdee36261205b93c8f84880 sourceBlobDigest: sha256:521a1c7be485e2be9f33ff7b82566823e96827cb69f7ca7775e0dd3dcc52d825 codeSamplesNamespace: my-source-code-samples - codeSamplesRevisionDigest: sha256:06bd35ef844f603c2c2357092fc875febff06f5c9eb855e262ff013b8935d8d6 + codeSamplesRevisionDigest: sha256:5940dadc286e702b4e23f58d1b7b536ffea4648a9f4f4a7ab650c6c107730a28 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/RELEASES.md b/RELEASES.md index 34900c93..6ddac0c4 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -977,4 +977,14 @@ Based on: ### Generated - [python v0.33.1] . ### Releases -- [PyPI v0.33.1] https://pypi.org/project/unstructured-client/0.33.1 - . \ No newline at end of file +- [PyPI v0.33.1] https://pypi.org/project/unstructured-client/0.33.1 - . + +## 2025-04-22 15:11:11 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.537.0 (2.588.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v0.34.0] . +### Releases +- [PyPI v0.34.0] https://pypi.org/project/unstructured-client/0.34.0 - . \ No newline at end of file diff --git a/gen.yaml b/gen.yaml index 35688474..36f1fae2 100644 --- a/gen.yaml +++ b/gen.yaml @@ -12,7 +12,7 @@ generation: oAuth2ClientCredentialsEnabled: false oAuth2PasswordEnabled: false python: - version: 0.33.1 + version: 0.34.0 additionalDependencies: dev: deepdiff: '>=6.0' diff --git a/poetry.lock b/poetry.lock index 16b71d96..e0f55f92 100644 --- a/poetry.lock +++ b/poetry.lock @@ -930,7 +930,7 @@ version = "2.8.2" description = "Extensions to the standard Python datetime module" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" -groups = ["main", "dev"] +groups = ["dev"] files = [ {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, @@ -982,7 +982,7 @@ version = "1.16.0" description = "Python 2 and 3 compatibility utilities" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" -groups = ["main", "dev"] +groups = ["dev"] files = [ {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, @@ -1037,18 +1037,6 @@ files = [ {file = "types_aiofiles-24.1.0.20240626-py3-none-any.whl", hash = "sha256:7939eca4a8b4f9c6491b6e8ef160caee9a21d32e18534a57d5ed90aee47c66b4"}, ] -[[package]] -name = "types-python-dateutil" -version = "2.9.0.20241003" -description = "Typing stubs for python-dateutil" -optional = false -python-versions = ">=3.8" -groups = ["dev"] -files = [ - {file = "types-python-dateutil-2.9.0.20241003.tar.gz", hash = "sha256:58cb85449b2a56d6684e41aeefb4c4280631246a0da1a719bdbe6f3fb0317446"}, - {file = "types_python_dateutil-2.9.0.20241003-py3-none-any.whl", hash = "sha256:250e1d8e80e7bbc3a6c99b907762711d1a1cdd00e978ad39cb5940f6f0a87f3d"}, -] - [[package]] name = "typing-extensions" version = "4.12.2" @@ -1149,4 +1137,4 @@ test = ["aiohttp (>=3.10.5)", "flake8 (>=5.0,<6.0)", "mypy (>=0.800)", "psutil", [metadata] lock-version = "2.1" python-versions = ">=3.9" -content-hash = "73969f5008660fe0c90c961d9d7cfca0e108f73a2dd6fe6a647cab04ca1f66e3" +content-hash = "78203fbab14338991dfb8810278b0eb421816fcfb55a8771e0c6079bb56aabea" diff --git a/pyproject.toml b/pyproject.toml index 758c990c..158c0ab6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "unstructured-client" -version = "0.33.1" +version = "0.34.0" description = "Python Client SDK for Unstructured API" authors = [{ name = "Unstructured" },] readme = "README-PYPI.md" @@ -13,7 +13,6 @@ dependencies = [ "nest-asyncio >=1.6.0", "pydantic >=2.11.2", "pypdf >=4.0", - "python-dateutil >=2.8.2", "requests-toolbelt >=1.0.0", "typing-inspection >=0.4.0", ] @@ -41,7 +40,6 @@ pytest = ">=8.3.3" pytest-asyncio = ">=0.24.0" pytest-mock = ">=3.14.0" types-aiofiles = ">=24.1.0" -types-python-dateutil = "^2.9.0.20240316" uvloop = ">=0.20.0" [build-system] diff --git a/src/unstructured_client/_version.py b/src/unstructured_client/_version.py index 5ceb97af..e24f349a 100644 --- a/src/unstructured_client/_version.py +++ b/src/unstructured_client/_version.py @@ -3,10 +3,10 @@ import importlib.metadata __title__: str = "unstructured-client" -__version__: str = "0.33.1" +__version__: str = "0.34.0" __openapi_doc_version__: str = "1.1.7" -__gen_version__: str = "2.585.2" -__user_agent__: str = "speakeasy-sdk/python 0.33.1 2.585.2 1.1.7 unstructured-client" +__gen_version__: str = "2.588.0" +__user_agent__: str = "speakeasy-sdk/python 0.34.0 2.588.0 1.1.7 unstructured-client" try: if __package__ is not None: diff --git a/src/unstructured_client/utils/__init__.py b/src/unstructured_client/utils/__init__.py index 3cded8fe..f2950eed 100644 --- a/src/unstructured_client/utils/__init__.py +++ b/src/unstructured_client/utils/__init__.py @@ -1,6 +1,7 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from .annotations import get_discriminator +from .datetimes import parse_datetime from .enums import OpenEnumMeta from .headers import get_headers, get_response_headers from .metadata import ( diff --git a/src/unstructured_client/utils/datetimes.py b/src/unstructured_client/utils/datetimes.py new file mode 100644 index 00000000..a6c52cd6 --- /dev/null +++ b/src/unstructured_client/utils/datetimes.py @@ -0,0 +1,23 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from datetime import datetime +import sys + + +def parse_datetime(datetime_string: str) -> datetime: + """ + Convert a RFC 3339 / ISO 8601 formatted string into a datetime object. + Python versions 3.11 and later support parsing RFC 3339 directly with + datetime.fromisoformat(), but for earlier versions, this function + encapsulates the necessary extra logic. + """ + # Python 3.11 and later can parse RFC 3339 directly + if sys.version_info >= (3, 11): + return datetime.fromisoformat(datetime_string) + + # For Python 3.10 and earlier, a common ValueError is trailing 'Z' suffix, + # so fix that upfront. + if datetime_string.endswith("Z"): + datetime_string = datetime_string[:-1] + "+00:00" + + return datetime.fromisoformat(datetime_string) From 8d466348ce2a15c21048857ef25997f8beb4f851 Mon Sep 17 00:00:00 2001 From: Yuming Long Date: Tue, 22 Apr 2025 08:23:56 -0700 Subject: [PATCH 20/21] nah --- .genignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.genignore b/.genignore index b3472289..ba334a1c 100644 --- a/.genignore +++ b/.genignore @@ -8,3 +8,9 @@ _test_unstructured_client # ignore Makefile Makefile +# Ignore the endpoints code until we can fix the base_url issue +src/unstructured_client/general.py +src/unstructured_client/destinations.py +src/unstructured_client/sources.py +src/unstructured_client/jobs.py +src/unstructured_client/workflows.py \ No newline at end of file From 39a31b0d0c1691ff734e79ad3d7f38f84a7fa86b Mon Sep 17 00:00:00 2001 From: Yuming Long Date: Tue, 22 Apr 2025 08:47:03 -0700 Subject: [PATCH 21/21] Revert "nah" This reverts commit 8d466348ce2a15c21048857ef25997f8beb4f851. --- .genignore | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.genignore b/.genignore index ba334a1c..b3472289 100644 --- a/.genignore +++ b/.genignore @@ -8,9 +8,3 @@ _test_unstructured_client # ignore Makefile Makefile -# Ignore the endpoints code until we can fix the base_url issue -src/unstructured_client/general.py -src/unstructured_client/destinations.py -src/unstructured_client/sources.py -src/unstructured_client/jobs.py -src/unstructured_client/workflows.py \ No newline at end of file