Skip to content

Commit 46a1cac

Browse files
committed
ci: regenerated with OpenAPI Doc 0.0.1, Speakeasy CLI 1.126.0
1 parent d4e5e5e commit 46a1cac

File tree

10 files changed

+44
-34
lines changed

10 files changed

+44
-34
lines changed

RELEASES.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,4 +294,14 @@ Based on:
294294
### Generated
295295
- [python v0.14.4] .
296296
### Releases
297-
- [PyPI v0.14.4] https://pypi.org/project/unstructured-client/0.14.4 - .
297+
- [PyPI v0.14.4] https://pypi.org/project/unstructured-client/0.14.4 - .
298+
299+
## 2023-12-12 00:19:45
300+
### Changes
301+
Based on:
302+
- OpenAPI Doc 0.0.1
303+
- Speakeasy CLI 1.126.0 (2.213.3) https://github.com/speakeasy-api/speakeasy
304+
### Generated
305+
- [python v0.15.0] .
306+
### Releases
307+
- [PyPI v0.15.0] https://pypi.org/project/unstructured-client/0.15.0 - .

USAGE.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ req = shared.PartitionParameters(
2828
new_after_n_chars=1500,
2929
output_format='application/json',
3030
skip_infer_table_types=[
31-
'p',
32-
'd',
33-
'f',
31+
'pdf',
3432
],
3533
strategy='hi_res',
3634
)

docs/models/shared/partitionparameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
| `new_after_n_chars` | *Optional[int]* | :heavy_minus_sign: | If chunking strategy is set, cut off new sections after reaching a length of n chars (soft max). Default: 1500 | 1500 |
2020
| `output_format` | *Optional[str]* | :heavy_minus_sign: | The format of the response. Supported formats are application/json and text/csv. Default: application/json. | application/json |
2121
| `pdf_infer_table_structure` | *Optional[bool]* | :heavy_minus_sign: | If True and strategy=hi_res, any Table Elements extracted from a PDF will include an additional metadata field, 'text_as_html', where the value (string) is a just a transformation of the data into an HTML <table>. | |
22-
| `skip_infer_table_types` | List[*str*] | :heavy_minus_sign: | The document types that you want to skip table extraction with. Default: ['pdf', 'jpg', 'png'] | pdf |
22+
| `skip_infer_table_types` | List[*str*] | :heavy_minus_sign: | The document types that you want to skip table extraction with. Default: ['pdf', 'jpg', 'png'] | |
2323
| `strategy` | *Optional[str]* | :heavy_minus_sign: | The strategy to use for partitioning PDF/image. Options are fast, hi_res, auto. Default: auto | hi_res |
2424
| `xml_keep_tags` | *Optional[bool]* | :heavy_minus_sign: | If True, will retain the XML tags in the output. Otherwise it will simply extract the text from within the tags. Only applies to partition_xml. | |

gen.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ configVersion: 1.0.0
22
management:
33
docChecksum: bf57420eebd40f2b1d166092f01e3927
44
docVersion: 0.0.1
5-
speakeasyVersion: 1.125.2
6-
generationVersion: 2.210.6
5+
speakeasyVersion: 1.126.0
6+
generationVersion: 2.213.3
77
generation:
88
comments: {}
99
sdkClassName: unstructured_client
@@ -12,15 +12,15 @@ generation:
1212
optionalPropertyRendering: withExample
1313
features:
1414
python:
15-
core: 4.1.6
15+
core: 4.3.0
1616
examples: 2.81.3
17-
globalSecurity: 2.83.0
17+
globalSecurity: 2.83.1
1818
globalServerURLs: 2.82.1
1919
nameOverrides: 2.81.1
2020
retries: 2.82.0
2121
serverIDs: 2.81.1
2222
python:
23-
version: 0.14.4
23+
version: 0.15.0
2424
author: Unstructured
2525
clientServerStatusCodesAsErrors: true
2626
description: Python Client SDK for Unstructured API

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setuptools.setup(
1212
name="unstructured-client",
13-
version="0.14.4",
13+
version="0.15.0",
1414
author="Unstructured",
1515
description="Python Client SDK for Unstructured API",
1616
long_description=long_description,

src/unstructured_client/general.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ def __init__(self, sdk_config: SDKConfiguration) -> None:
1313

1414

1515

16-
def partition(self, request: shared.PartitionParameters, retries: Optional[utils.RetryConfig] = None) -> operations.PartitionResponse:
16+
def partition(self, request: Optional[shared.PartitionParameters], retries: Optional[utils.RetryConfig] = None) -> operations.PartitionResponse:
1717
r"""Pipeline 1"""
1818
base_url = utils.template_url(*self.sdk_configuration.get_server_details())
1919

2020
url = base_url + '/general/v0/general'
2121
headers = {}
22-
req_content_type, data, form = utils.serialize_request_body(request, "request", False, True, 'multipart')
22+
req_content_type, data, form = utils.serialize_request_body(request, Optional[shared.PartitionParameters], "request", False, True, 'multipart')
2323
if req_content_type not in ('multipart/form-data', 'multipart/mixed'):
2424
headers['content-type'] = req_content_type
2525
headers['Accept'] = 'application/json'

src/unstructured_client/models/errors/httpvalidationerror.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ class HTTPValidationError(Exception):
1616

1717

1818
def __str__(self) -> str:
19-
return utils.marshal_json(self)
19+
return utils.marshal_json(self, type(self))

src/unstructured_client/sdk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import requests as requests_http
44
from .general import General
55
from .sdkconfiguration import SDKConfiguration
6-
from typing import Callable, Dict, Union
6+
from typing import Dict
77
from unstructured_client import utils
88
from unstructured_client.models import shared
99

@@ -14,7 +14,7 @@ class UnstructuredClient:
1414
sdk_configuration: SDKConfiguration
1515

1616
def __init__(self,
17-
api_key_auth: Union[str,Callable[[], str]],
17+
api_key_auth: str ,
1818
server: str = None,
1919
server_url: str = None,
2020
url_params: Dict[str, str] = None,

src/unstructured_client/sdkconfiguration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ class SDKConfiguration:
2727
server: str = ''
2828
language: str = 'python'
2929
openapi_doc_version: str = '0.0.1'
30-
sdk_version: str = '0.14.4'
31-
gen_version: str = '2.210.6'
32-
user_agent: str = 'speakeasy-sdk/python 0.14.4 2.210.6 0.0.1 unstructured-client'
30+
sdk_version: str = '0.15.0'
31+
gen_version: str = '2.213.3'
32+
user_agent: str = 'speakeasy-sdk/python 0.15.0 2.213.3 0.0.1 unstructured-client'
3333
retry_config: RetryConfig = None
3434

3535
def get_server_details(self) -> Tuple[str, Dict[str, str]]:

src/unstructured_client/utils/utils.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from typing import (Any, Callable, Dict, List, Optional, Tuple, Union,
1313
get_args, get_origin)
1414
from xmlrpc.client import boolean
15-
15+
from typing_inspect import is_optional_type
1616
import dateutil.parser
1717
import requests
1818
from dataclasses_json import DataClassJsonMixin
@@ -169,7 +169,7 @@ def generate_url(clazz: type, server_url: str, path: str, path_params: dataclass
169169
serialization = param_metadata.get('serialization', '')
170170
if serialization != '':
171171
serialized_params = _get_serialized_params(
172-
param_metadata, f_name, param)
172+
param_metadata, field.type, f_name, param)
173173
for key, value in serialized_params.items():
174174
path = path.replace(
175175
'{' + key + '}', value, 1)
@@ -261,7 +261,7 @@ def get_query_params(clazz: type, query_params: dataclass, gbls: Dict[str, Dict[
261261
f_name = metadata.get("field_name")
262262
serialization = metadata.get('serialization', '')
263263
if serialization != '':
264-
serialized_parms = _get_serialized_params(metadata, f_name, value)
264+
serialized_parms = _get_serialized_params(metadata, field.type, f_name, value)
265265
for key, value in serialized_parms.items():
266266
if key in params:
267267
params[key].extend(value)
@@ -304,12 +304,12 @@ def get_headers(headers_params: dataclass) -> Dict[str, str]:
304304
return headers
305305

306306

307-
def _get_serialized_params(metadata: Dict, field_name: str, obj: any) -> Dict[str, str]:
307+
def _get_serialized_params(metadata: Dict, field_type: type, field_name: str, obj: any) -> Dict[str, str]:
308308
params: Dict[str, str] = {}
309309

310310
serialization = metadata.get('serialization', '')
311311
if serialization == 'json':
312-
params[metadata.get("field_name", field_name)] = marshal_json(obj)
312+
params[metadata.get("field_name", field_name)] = marshal_json(obj, field_type)
313313

314314
return params
315315

@@ -394,14 +394,14 @@ def _get_delimited_query_params(metadata: Dict, field_name: str, obj: any, delim
394394
}
395395

396396

397-
def serialize_request_body(request: dataclass, request_field_name: str, nullable: bool, optional: bool, serialization_method: str, encoder=None) -> Tuple[
397+
def serialize_request_body(request: dataclass, request_type: type, request_field_name: str, nullable: bool, optional: bool, serialization_method: str, encoder=None) -> Tuple[
398398
str, any, any]:
399399
if request is None:
400400
if not nullable and optional:
401401
return None, None, None
402402

403403
if not is_dataclass(request) or not hasattr(request, request_field_name):
404-
return serialize_content_type(request_field_name, SERIALIZATION_METHOD_TO_CONTENT_TYPE[serialization_method],
404+
return serialize_content_type(request_field_name, request_type, SERIALIZATION_METHOD_TO_CONTENT_TYPE[serialization_method],
405405
request, encoder)
406406

407407
request_val = getattr(request, request_field_name)
@@ -421,13 +421,13 @@ def serialize_request_body(request: dataclass, request_field_name: str, nullable
421421
if request_metadata is None:
422422
raise Exception('invalid request type')
423423

424-
return serialize_content_type(request_field_name, request_metadata.get('media_type', 'application/octet-stream'),
424+
return serialize_content_type(request_field_name, request_type, request_metadata.get('media_type', 'application/octet-stream'),
425425
request_val)
426426

427427

428-
def serialize_content_type(field_name: str, media_type: str, request: dataclass, encoder=None) -> Tuple[str, any, List[List[any]]]:
428+
def serialize_content_type(field_name: str, request_type: any, media_type: str, request: dataclass, encoder=None) -> Tuple[str, any, List[List[any]]]:
429429
if re.match(r'(application|text)\/.*?\+*json.*', media_type) is not None:
430-
return media_type, marshal_json(request, encoder), None
430+
return media_type, marshal_json(request, request_type, encoder), None
431431
if re.match(r'multipart\/.*', media_type) is not None:
432432
return serialize_multipart_form(media_type, request)
433433
if re.match(r'application\/x-www-form-urlencoded.*', media_type) is not None:
@@ -478,7 +478,7 @@ def serialize_multipart_form(media_type: str, request: dataclass) -> Tuple[str,
478478
form.append([field_name, [file_name, content]])
479479
elif field_metadata.get("json") is True:
480480
to_append = [field_metadata.get("field_name", field.name), [
481-
None, marshal_json(val), "application/json"]]
481+
None, marshal_json(val, field.type), "application/json"]]
482482
form.append(to_append)
483483
else:
484484
field_name = field_metadata.get(
@@ -531,7 +531,7 @@ def serialize_form_data(field_name: str, data: dataclass) -> Dict[str, any]:
531531
field_name = metadata.get('field_name', field.name)
532532

533533
if metadata.get('json'):
534-
form[field_name] = [marshal_json(val)]
534+
form[field_name] = [marshal_json(val, field.type)]
535535
else:
536536
if metadata.get('style', 'form') == 'form':
537537
form = {**form, **_populate_form(
@@ -697,12 +697,14 @@ def unmarshal_json(data, typ, decoder=None):
697697
return out.res if decoder is None else decoder(out.res)
698698

699699

700-
def marshal_json(val, encoder=None):
701-
marshal = make_dataclass('Marshal', [('res', type(val))],
700+
def marshal_json(val, typ, encoder=None):
701+
if not is_optional_type(typ) and val is None:
702+
raise ValueError(f"Could not marshal None into non-optional type: {typ}")
703+
704+
marshal = make_dataclass('Marshal', [('res', typ)],
702705
bases=(DataClassJsonMixin,))
703706
marshaller = marshal(res=val)
704707
json_dict = marshaller.to_dict()
705-
706708
val = json_dict["res"] if encoder is None else encoder(json_dict["res"])
707709

708710
return json.dumps(val, separators=(',', ':'), sort_keys=True)

0 commit comments

Comments
 (0)