diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 9073141c..52290687 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: 8befe9665bd102e8cc2241c80080859a + docChecksum: 761bdf240b7e572d6a866cee2c950c70 docVersion: 1.0.78 - speakeasyVersion: 1.509.0 - generationVersion: 2.539.0 - releaseVersion: 0.31.0 - configChecksum: faf5191e78f1597b78cd7600af4f1d96 + speakeasyVersion: 1.513.0 + generationVersion: 2.545.1 + releaseVersion: 0.31.1 + configChecksum: 569b9e45b4960f94a43454c345d9b38c repoURL: https://github.com/Unstructured-IO/unstructured-python-client.git repoSubDirectory: . installationURL: https://github.com/Unstructured-IO/unstructured-python-client.git @@ -197,7 +197,7 @@ generatedFiles: - py.typed - pylintrc - pyproject.toml - - scripts/prepare-readme.py + - scripts/prepare_readme.py - scripts/publish.sh - src/unstructured_client/__init__.py - src/unstructured_client/_hooks/__init__.py @@ -208,6 +208,7 @@ generatedFiles: - src/unstructured_client/destinations.py - src/unstructured_client/httpclient.py - src/unstructured_client/jobs.py + - src/unstructured_client/models/__init__.py - src/unstructured_client/models/errors/__init__.py - src/unstructured_client/models/errors/httpvalidationerror.py - src/unstructured_client/models/errors/sdkerror.py @@ -417,14 +418,14 @@ examples: "200": application/json: {"created_at": "2025-01-14T00:09:32.358Z", "id": "d18f330b-506f-455c-9cb8-0cee2386ac29", "runtime": "", "status": "IN_PROGRESS", "workflow_id": "136fd799-4c45-4417-a632-f460d8ebb2a2", "workflow_name": ""} "422": - application/json: {"detail": ""} + application/json: {"detail": [{"loc": ["", 701982], "msg": "", "type": ""}, {"loc": [""], "msg": "", "type": ""}]} list_jobs: speakeasy-default-list-jobs: responses: "200": application/json: [{"created_at": "2023-09-01T17:59:19.211Z", "id": "7098ff76-419f-4a5a-a313-d159507b629d", "runtime": "", "status": "SCHEDULED", "workflow_id": "75cf761e-8c10-48e4-b3d7-6ae90ad4fd3e", "workflow_name": ""}] "422": - application/json: {"detail": [{"loc": [], "msg": "", "type": ""}]} + application/json: {"detail": []} create_source: speakeasy-default-create-source: requestBody: @@ -522,9 +523,9 @@ examples: header: {} responses: "202": - application/json: {"created_at": "2024-08-04T10:06:22.481Z", "destinations": [], "id": "6c4f327c-7ca2-4933-a68d-2ebe9d9f1445", "name": "", "schedule": {"crontab_entries": [{"cron_expression": "0 0 * * *"}]}, "sources": ["a9593964-92eb-496f-84ac-c8f067ba24c3"], "status": "inactive", "workflow_nodes": [{"name": "", "subtype": "", "type": "chunk"}], "workflow_type": "custom"} + application/json: {"created_at": "2024-08-04T10:06:22.481Z", "id": "6c4f327c-7ca2-4933-a68d-2ebe9d9f1445", "runtime": "", "status": "COMPLETED", "workflow_id": "b67be6d9-8e94-40c8-afd7-21e5d2d00363", "workflow_name": ""} "422": - application/json: {"detail": [{"loc": [""], "msg": "", "type": ""}, {"loc": [397022, 604524], "msg": "", "type": ""}]} + application/json: {"detail": [{"loc": ["", 233068, ""], "msg": "", "type": ""}]} update_workflow: speakeasy-default-update-workflow: parameters: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 594f2f2a..33cc4d41 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,21 +1,21 @@ -speakeasyVersion: 1.509.0 +speakeasyVersion: 1.513.0 sources: my-source: sourceNamespace: my-source - sourceRevisionDigest: sha256:b62d80c1b902f285b4eaeaf67a4b1d2edb21053eded12c247daecbfeea1d8a30 - sourceBlobDigest: sha256:8d5c6a31539e2e1047e529fb6561fd4172fa80506241bc25dcf51d7c76f8b6e6 + sourceRevisionDigest: sha256:284396f88ac6b8f00fc6b64e117310094af9403c775d96d0273f2dc91e20a99d + sourceBlobDigest: sha256:eeff76b4ac663079622a4957d5023f06ca2a8ad423075a125478ad3b57aeb4ef tags: - latest - - speakeasy-sdk-regen-1741046993 + - speakeasy-sdk-regen-1741292249 - 1.0.78 targets: unstructured-python: source: my-source sourceNamespace: my-source - sourceRevisionDigest: sha256:b62d80c1b902f285b4eaeaf67a4b1d2edb21053eded12c247daecbfeea1d8a30 - sourceBlobDigest: sha256:8d5c6a31539e2e1047e529fb6561fd4172fa80506241bc25dcf51d7c76f8b6e6 + sourceRevisionDigest: sha256:284396f88ac6b8f00fc6b64e117310094af9403c775d96d0273f2dc91e20a99d + sourceBlobDigest: sha256:eeff76b4ac663079622a4957d5023f06ca2a8ad423075a125478ad3b57aeb4ef codeSamplesNamespace: my-source-code-samples - codeSamplesRevisionDigest: sha256:77255b7d9241b11e147927beb6e60a27654bd6089e121356a3d5ca06e5f0f2f1 + codeSamplesRevisionDigest: sha256:19241c5759df66896762918163ed4cbb6be089a165082e64717f088fb50320c1 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/Makefile b/Makefile index 96098b1a..86032aef 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ DOCKER_IMAGE ?= downloads.unstructured.io/unstructured-io/unstructured-api:lates .PHONY: install install: pip install -U poetry - python scripts/prepare-readme.py + python scripts/prepare_readme.py poetry install ## install-speakeasy-cli: download the speakeasy cli tool diff --git a/RELEASES.md b/RELEASES.md index 460da5c6..7c4de2aa 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -845,4 +845,14 @@ Based on: ### Generated - [python v0.31.0] . ### Releases -- [PyPI v0.31.0] https://pypi.org/project/unstructured-client/0.31.0 - . \ No newline at end of file +- [PyPI v0.31.0] https://pypi.org/project/unstructured-client/0.31.0 - . + +## 2025-03-06 20:17:13 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.513.0 (2.545.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v0.31.1] . +### Releases +- [PyPI v0.31.1] https://pypi.org/project/unstructured-client/0.31.1 - . \ No newline at end of file diff --git a/_test_contract/platform_api/test_workflows.py b/_test_contract/platform_api/test_workflows.py index 214c2395..50a858b1 100644 --- a/_test_contract/platform_api/test_workflows.py +++ b/_test_contract/platform_api/test_workflows.py @@ -226,21 +226,17 @@ def test_run_workflow(httpx_mock, client: UnstructuredClient, platform_api_url: httpx_mock.add_response( method="POST", - url=url, status_code=202, + headers={"Content-Type": "application/json"}, json={ - "created_at": "2024-08-04T10:06:22.481Z", - "id": "6c4f327c-7ca2-4933-a68d-2ebe9d9f1445", - "name": "test_workflow", - "schedule": {"crontab_entries": [{"cron_expression": "0 0 * * 0"}]}, - "sources": ["a9593964-92eb-496f-84ac-c8f067ba24c3"], - "destinations": [ - "aeebecc7-9d8e-4625-bf1d-815c2f084869", - ], - "workflow_nodes": [], - "status": "active", - "workflow_type": "platinum", + "created_at": "2025-06-22T11:37:21.648Z", + "id": "fcdc4994-eea5-425c-91fa-e03f2bd8030d", + "status": "IN_PROGRESS", + "runtime": None, + "workflow_id": "16b80fee-64dc-472d-8f26-1d7729b6423d", + "workflow_name": "test_workflow", }, + url=url, ) run_workflow_response = client.workflows.run_workflow( @@ -257,16 +253,7 @@ def test_run_workflow(httpx_mock, client: UnstructuredClient, platform_api_url: assert request.method == "POST" assert request.url == url - workflow_run = run_workflow_response.workflow_information - assert workflow_run.id == "6c4f327c-7ca2-4933-a68d-2ebe9d9f1445" - assert workflow_run.name == "test_workflow" - assert workflow_run.workflow_type == "platinum" - assert workflow_run.status == "active" - assert workflow_run.created_at == datetime.fromisoformat( - "2024-08-04T10:06:22.481+00:00" - ) - assert workflow_run.schedule == shared.WorkflowSchedule( - crontab_entries=[shared.crontabentry.CronTabEntry(cron_expression="0 0 * * 0")] - ) - assert workflow_run.sources == ["a9593964-92eb-496f-84ac-c8f067ba24c3"] - assert workflow_run.destinations == ["aeebecc7-9d8e-4625-bf1d-815c2f084869"] + new_job = run_workflow_response.job_information + assert new_job.id == "fcdc4994-eea5-425c-91fa-e03f2bd8030d" + assert new_job.workflow_name == "test_workflow" + assert new_job.status == "IN_PROGRESS" \ No newline at end of file diff --git a/codeSamples.yaml b/codeSamples.yaml index 59492c20..613403d4 100644 --- a/codeSamples.yaml +++ b/codeSamples.yaml @@ -116,7 +116,7 @@ actions: "x-codeSamples": - "lang": "python" "label": "run_workflow" - "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient() as uc_client:\n\n res = uc_client.workflows.run_workflow(request={\n \"workflow_id\": \"6b67be6d-98e9-440c-88fd-721e5d2d0036\",\n })\n\n assert res.workflow_information is not None\n\n # Handle response\n print(res.workflow_information)" + "source": "from unstructured_client import UnstructuredClient\n\n\nwith UnstructuredClient() as uc_client:\n\n res = uc_client.workflows.run_workflow(request={\n \"workflow_id\": \"6b67be6d-98e9-440c-88fd-721e5d2d0036\",\n })\n\n assert res.job_information is not None\n\n # Handle response\n print(res.job_information)" - target: $["paths"]["/general/v0/general"]["post"] update: "x-codeSamples": diff --git a/docs/models/operations/runworkflowresponse.md b/docs/models/operations/runworkflowresponse.md index a3d1401b..f2220b79 100644 --- a/docs/models/operations/runworkflowresponse.md +++ b/docs/models/operations/runworkflowresponse.md @@ -3,9 +3,9 @@ ## Fields -| Field | Type | Required | Description | -| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | -| `content_type` | *str* | :heavy_check_mark: | HTTP response content type for this operation | -| `status_code` | *int* | :heavy_check_mark: | HTTP response status code for this operation | -| `raw_response` | [httpx.Response](https://www.python-httpx.org/api/#response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | -| `workflow_information` | [Optional[shared.WorkflowInformation]](../../models/shared/workflowinformation.md) | :heavy_minus_sign: | Successful Response | \ No newline at end of file +| Field | Type | Required | Description | +| ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | +| `content_type` | *str* | :heavy_check_mark: | HTTP response content type for this operation | +| `status_code` | *int* | :heavy_check_mark: | HTTP response status code for this operation | +| `raw_response` | [httpx.Response](https://www.python-httpx.org/api/#response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | +| `job_information` | [Optional[shared.JobInformation]](../../models/shared/jobinformation.md) | :heavy_minus_sign: | Successful Response | \ No newline at end of file diff --git a/docs/sdks/workflows/README.md b/docs/sdks/workflows/README.md index b5ff11a5..5ed628aa 100644 --- a/docs/sdks/workflows/README.md +++ b/docs/sdks/workflows/README.md @@ -201,10 +201,10 @@ with UnstructuredClient() as uc_client: "workflow_id": "6b67be6d-98e9-440c-88fd-721e5d2d0036", }) - assert res.workflow_information is not None + assert res.job_information is not None # Handle response - print(res.workflow_information) + print(res.job_information) ``` diff --git a/gen.yaml b/gen.yaml index 0063214f..17a4452f 100644 --- a/gen.yaml +++ b/gen.yaml @@ -12,7 +12,7 @@ generation: oAuth2ClientCredentialsEnabled: false oAuth2PasswordEnabled: false python: - version: 0.31.0 + version: 0.31.1 additionalDependencies: dev: deepdiff: '>=6.0' diff --git a/poetry.lock b/poetry.lock index 542e9380..8445ceae 100644 --- a/poetry.lock +++ b/poetry.lock @@ -579,7 +579,7 @@ version = "1.0.0" description = "Type system extensions for programs checked with the mypy type checker." optional = false python-versions = ">=3.5" -groups = ["main", "dev"] +groups = ["dev"] files = [ {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, @@ -1053,20 +1053,19 @@ files = [ ] [[package]] -name = "typing-inspect" -version = "0.9.0" -description = "Runtime inspection utilities for typing module." +name = "typing-inspection" +version = "0.4.0" +description = "Runtime typing introspection tools" optional = false -python-versions = "*" +python-versions = ">=3.9" groups = ["main"] files = [ - {file = "typing_inspect-0.9.0-py3-none-any.whl", hash = "sha256:9ee6fc59062311ef8547596ab6b955e1b8aa46242d854bfc78f4f6b0eff35f9f"}, - {file = "typing_inspect-0.9.0.tar.gz", hash = "sha256:b23fc42ff6f6ef6954e4852c1fb512cdd18dbea03134f91f856a95ccc9461f78"}, + {file = "typing_inspection-0.4.0-py3-none-any.whl", hash = "sha256:50e72559fcd2a6367a19f7a7e610e6afcb9fac940c650290eed893d61386832f"}, + {file = "typing_inspection-0.4.0.tar.gz", hash = "sha256:9765c87de36671694a67904bf2c96e395be9c6439bb6c87b5142569dcdd65122"}, ] [package.dependencies] -mypy-extensions = ">=0.3.0" -typing-extensions = ">=3.7.4" +typing-extensions = ">=4.12.0" [[package]] name = "urllib3" @@ -1141,4 +1140,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 = "a248aa08992212d7b1fb89ead64451a990c649618e4c6fa8261eb3374f60f8ae" +content-hash = "4898d7795a3536100b31253940f9356d99ba3c82debbb25cf03426e6fb0627dc" diff --git a/pylintrc b/pylintrc index f2385e87..097b0a80 100644 --- a/pylintrc +++ b/pylintrc @@ -454,7 +454,10 @@ disable=raw-checker-failed, bare-except, broad-exception-caught, fixme, - relative-beyond-top-level + relative-beyond-top-level, + consider-using-with, + wildcard-import, + unused-wildcard-import # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option diff --git a/pyproject.toml b/pyproject.toml index f098ea67..d9e443bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "unstructured-client" -version = "0.31.0" +version = "0.31.1" description = "Python Client SDK for Unstructured API" authors = [{ name = "Unstructured" },] readme = "README-PYPI.md" @@ -15,7 +15,7 @@ dependencies = [ "pypdf >=4.0", "python-dateutil >=2.8.2", "requests-toolbelt >=1.0.0", - "typing-inspect >=0.9.0", + "typing-inspection >=0.4.0", ] [tool.poetry] diff --git a/scripts/prepare-readme.py b/scripts/prepare_readme.py similarity index 84% rename from scripts/prepare-readme.py rename to scripts/prepare_readme.py index b5bf03ff..52e872a1 100644 --- a/scripts/prepare-readme.py +++ b/scripts/prepare_readme.py @@ -4,7 +4,7 @@ import shutil try: - with open("README.md", "r") as rh: + with open("README.md", "r", encoding="utf-8") as rh: readme_contents = rh.read() GITHUB_URL = "https://github.com/Unstructured-IO/unstructured-python-client.git" GITHUB_URL = ( @@ -21,13 +21,13 @@ readme_contents, ) - with open("README-PYPI.md", "w") as wh: + with open("README-PYPI.md", "w", encoding="utf-8") as wh: wh.write(readme_contents) except Exception as e: try: print("Failed to rewrite README.md to README-PYPI.md, copying original instead") print(e) shutil.copyfile("README.md", "README-PYPI.md") - except Exception as e: + except Exception as ie: print("Failed to copy README.md to README-PYPI.md") - print(e) + print(ie) diff --git a/scripts/publish.sh b/scripts/publish.sh index ab45b1f9..f2f2cf2c 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -2,6 +2,6 @@ export POETRY_PYPI_TOKEN_PYPI=${PYPI_TOKEN} -poetry run python scripts/prepare-readme.py +poetry run python scripts/prepare_readme.py poetry publish --build --skip-existing diff --git a/src/unstructured_client/_version.py b/src/unstructured_client/_version.py index 432c205b..2483b0b4 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.31.0" +__version__: str = "0.31.1" __openapi_doc_version__: str = "1.0.78" -__gen_version__: str = "2.539.0" -__user_agent__: str = "speakeasy-sdk/python 0.31.0 2.539.0 1.0.78 unstructured-client" +__gen_version__: str = "2.545.1" +__user_agent__: str = "speakeasy-sdk/python 0.31.1 2.545.1 1.0.78 unstructured-client" try: if __package__ is not None: diff --git a/src/unstructured_client/models/__init__.py b/src/unstructured_client/models/__init__.py new file mode 100644 index 00000000..cc53976c --- /dev/null +++ b/src/unstructured_client/models/__init__.py @@ -0,0 +1,4 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +# package + diff --git a/src/unstructured_client/models/operations/run_workflow.py b/src/unstructured_client/models/operations/run_workflow.py index 230e87a1..c5715f5d 100644 --- a/src/unstructured_client/models/operations/run_workflow.py +++ b/src/unstructured_client/models/operations/run_workflow.py @@ -6,9 +6,7 @@ from pydantic import model_serializer from typing import Optional from typing_extensions import Annotated, NotRequired, TypedDict -from unstructured_client.models.shared import ( - workflowinformation as shared_workflowinformation, -) +from unstructured_client.models.shared import jobinformation as shared_jobinformation from unstructured_client.types import ( BaseModel, Nullable, @@ -80,9 +78,7 @@ class RunWorkflowResponseTypedDict(TypedDict): r"""HTTP response status code for this operation""" raw_response: httpx.Response r"""Raw HTTP response; suitable for custom response parsing""" - workflow_information: NotRequired[ - shared_workflowinformation.WorkflowInformationTypedDict - ] + job_information: NotRequired[shared_jobinformation.JobInformationTypedDict] r"""Successful Response""" @@ -96,7 +92,5 @@ class RunWorkflowResponse(BaseModel): raw_response: httpx.Response r"""Raw HTTP response; suitable for custom response parsing""" - workflow_information: Optional[shared_workflowinformation.WorkflowInformation] = ( - None - ) + job_information: Optional[shared_jobinformation.JobInformation] = None r"""Successful Response""" diff --git a/src/unstructured_client/utils/serializers.py b/src/unstructured_client/utils/serializers.py index c5eb3659..312e50f7 100644 --- a/src/unstructured_client/utils/serializers.py +++ b/src/unstructured_client/utils/serializers.py @@ -7,14 +7,15 @@ from typing_extensions import get_origin from pydantic import ConfigDict, create_model from pydantic_core import from_json -from typing_inspect import is_optional_type +from typing_inspection.typing_objects import is_union from ..types.basemodel import BaseModel, Nullable, OptionalNullable, Unset def serialize_decimal(as_str: bool): def serialize(d): - if is_optional_type(type(d)) and d is None: + # Optional[T] is a Union[T, None] + if is_union(type(d)) and type(None) in get_args(type(d)) and d is None: return None if isinstance(d, Unset): return d @@ -42,7 +43,8 @@ def validate_decimal(d): def serialize_float(as_str: bool): def serialize(f): - if is_optional_type(type(f)) and f is None: + # Optional[T] is a Union[T, None] + if is_union(type(f)) and type(None) in get_args(type(f)) and f is None: return None if isinstance(f, Unset): return f @@ -70,7 +72,8 @@ def validate_float(f): def serialize_int(as_str: bool): def serialize(i): - if is_optional_type(type(i)) and i is None: + # Optional[T] is a Union[T, None] + if is_union(type(i)) and type(None) in get_args(type(i)) and i is None: return None if isinstance(i, Unset): return i @@ -118,7 +121,8 @@ def validate(e): def validate_const(v): def validate(c): - if is_optional_type(type(c)) and c is None: + # Optional[T] is a Union[T, None] + if is_union(type(c)) and type(None) in get_args(type(c)) and c is None: return None if v != c: diff --git a/src/unstructured_client/workflows.py b/src/unstructured_client/workflows.py index 0b59f9c9..439dedaf 100644 --- a/src/unstructured_client/workflows.py +++ b/src/unstructured_client/workflows.py @@ -987,8 +987,8 @@ def run_workflow( response_data: Any = None if utils.match_response(http_res, "202", "application/json"): return operations.RunWorkflowResponse( - workflow_information=utils.unmarshal_json( - http_res.text, Optional[shared.WorkflowInformation] + job_information=utils.unmarshal_json( + http_res.text, Optional[shared.JobInformation] ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "", @@ -1099,8 +1099,8 @@ async def run_workflow_async( response_data: Any = None if utils.match_response(http_res, "202", "application/json"): return operations.RunWorkflowResponse( - workflow_information=utils.unmarshal_json( - http_res.text, Optional[shared.WorkflowInformation] + job_information=utils.unmarshal_json( + http_res.text, Optional[shared.JobInformation] ), status_code=http_res.status_code, content_type=http_res.headers.get("Content-Type") or "",