Skip to content

NEXUS-909 feat Enable custom server URLs in the workflow endpoints #265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Apr 22, 2025

Conversation

yuming-long
Copy link
Contributor

@yuming-long yuming-long commented Apr 22, 2025

Summary

  • server_url logic in workflow endpoints is now the same as partition endpoint: user should be able to pass it from Client init to each endpoint and if no input we will just fallback to default based on endpoint operation
  • NOTE changes to developers: generate GHA will need manual changes
    • you need to change the automate speakeasy bot PR made generate GHA -> so that it won't revert the changes on base_url in each endpoint (see chore: 🐝 Update SDK - Generate 0.34.0 #266)
    • we could add those file under .genignore so that speakeasy bot ignore the ^^ changes -> but i don't like this way since we might still need to modify workflow API endpoint and speakeasy bot will ignore them if we do
    • another trick i found that could solve the issue -> we could pay speakeasy more... but still not very flexible
    • or we could also patch _get_url in basesdk.py but thats in deeper stack of code might be difficult to read the flow (and write tests)
    • all reasons ^^^^ include i decide to go with manual changes in generate GHA -> we need a developer to approve that auto PR anyway

Test

you got three ways of using the url

## make sure the version of unstructured_client is the local one should be 0.34.0
import unstructured_client
from unstructured_client.models import operations, shared
from unstructured_client import UnstructuredClient
# 1. init custom url when you create the Client (suggested way for in-VPC)
uc_client = UnstructuredClient(server_url="http://localhost:8081/", api_key_auth="XXXX")

create_workflow_data = {
    "name": "custom sdk workflow",
    "workflow_type": shared.WorkflowType.BASIC,
}

client_res = uc_client.workflows.create_workflow(request={
    "create_workflow": create_workflow_data,
})
# 2. pass url when you call the specific endpoint (probably nobody will use this one...)
uc_client = UnstructuredClient(api_key_auth="XXX")

create_workflow_data = {
    "name": "custom sdk workflow",
    "workflow_type": shared.WorkflowType.BASIC,
}

client_res = uc_client.workflows.create_workflow(
    request={"create_workflow": create_workflow_data,},
    server_url="http://localhost:8081/",
)
# 3. no passing any url, fallback to default
uc_client = UnstructuredClient(api_key_auth="XXX)

create_workflow_data = {
    "name": "custom sdk workflow",
    "workflow_type": shared.WorkflowType.BASIC,
}

client_res = uc_client.workflows.create_workflow(
    request={"create_workflow": create_workflow_data,},
)

and responses would be (last one is default fallback)

INFO: HTTP Request: POST http://localhost:8081/api/v1/workflows/ "HTTP/1.1 200 OK"
INFO: HTTP Request: POST http://localhost:8081/api/v1/workflows/ "HTTP/1.1 200 OK"
INFO: HTTP Request: POST https://platform.unstructuredapp.io/api/v1/workflows/ "HTTP/1.1 200 OK"

yuming-long and others added 22 commits April 21, 2025 09:08
This reverts commit 9639062.
This reverts commit bd8d0a9.
> [!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:
<https://app.speakeasy.com/org/unstructured/unstructured5xr/linting-report/58686777b39d3936df6f61710ab738d8>
> OpenAPI Change report available at:
<https://app.speakeasy.com/org/unstructured/unstructured5xr/changes-report/d1b6cec20149892cd22bac1b6ad7c703>
# 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
### 🐝 New Features
- Remove python-dateutil dependency *(commit by
[@bflad](https://github.com/bflad))*

---------

Co-authored-by: speakeasybot <[email protected]>
Co-authored-by: Yuming Long <[email protected]>
This reverts commit 8d46634.
@yuming-long yuming-long merged commit 51e5e61 into main Apr 22, 2025
9 of 11 checks passed
@yuming-long yuming-long deleted the yuming/custom_url branch April 22, 2025 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants