Commit b0a005f
authored
chore: Revert custom handling for multiple Unstructured base urls (#270)
# The Issue
We discovered a behavior change in the Python SDK after we merged the
platform/serverless api specs. All of a sudden, the SDK level server_url
param silently stopped working, and we were forced to set custom urls
per function.
```
# The passed url is ignored and we go to our default Serverless URL.
# You suddenly get an invalid api key error if you expected to talk to, e.g, freemium
s = UnstructuredClient(server_url="my_own_url")
s.general.partition()
# This does the right thing
s = UnstructuredClient()
s.general.partition(server_url="my_own_url")
```
We had to patch some generated code in order to keep backwards
compatibility, and set the SDK level `server_url` the way we used to.
This works! However, any file in `.genignore` will not get updated and
eventually the SDK fails to generate because of drift. The better
solution is to figure out why the generated code changed on us, and fix
it "upstream".
# The Fix
Our SDK points to two services - the workflow API at
`platform.unstructuredapp.io` and the older partition endpoint at
`api.unstructuredapp.io`. We merged these two openapi specs in order to
generate a combined SDK, but this meant that urls could only be resolved
per operation. There is no longer a global default, so a statement like
`UnstructuredClient(server_url="my_own_url")` is ambiguous.
The solution to all this is to go back to one default server - the
platform url. The partition url is just one endpoint so it's much easier
to handle as a one off. This restores the `server_url` behavior we had,
without us having to fight with the autogenerated code.
# The Diff
This pr is huge because I regenerated the relevant files. There are only
a few changes that drive all of it:
## `overlay_client.yaml`
After merging the two `openapi.yaml` specs, remove all child `servers`
blocks and just keep one global config. Now every endpoint is a part of
`platform.unstructuredapp.io`
## `general.py`
This is now the only custom patch. In the `partition` (and
`partition_async`) call, we need to swap to the right url. We do this
only if the user has not already changed the default.
## `destinations.py`, `jobs.py`, etc
These are the other endpoint files that are no longer patched. After
regenerating, you can see the `base_url` logic cleans itself up. Either
the user passed a `server_url` in the call, or we fetch the globally
configured url.
## `test_server_urls.py`
Made some tweaks to these test cases. This locks in our compatibility
and asserts that we always use the right url. Users can set a custom url
at the SDK init, or at the operation. We need to cover this behavior
within `general.partition` since this has the special logic. Otherwise,
make sure both url approaches work for any of the other platform
operations.1 parent 1363a12 commit b0a005f
File tree
46 files changed
+335
-583
lines changed- _test_unstructured_client/unit
- docs/sdks
- destinations
- general
- jobs
- sources
- users
- workflows
- src/unstructured_client
- _hooks/custom
- models/operations
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
46 files changed
+335
-583
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | | - | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | 97 | | |
126 | 98 | | |
127 | 99 | | |
| |||
161 | 133 | | |
162 | 134 | | |
163 | 135 | | |
164 | | - | |
| 136 | + | |
165 | 137 | | |
166 | 138 | | |
167 | 139 | | |
168 | 140 | | |
169 | 141 | | |
170 | 142 | | |
171 | | - | |
| 143 | + | |
172 | 144 | | |
173 | 145 | | |
174 | 146 | | |
175 | 147 | | |
176 | 148 | | |
177 | 149 | | |
178 | | - | |
| 150 | + | |
179 | 151 | | |
180 | 152 | | |
181 | 153 | | |
182 | 154 | | |
183 | 155 | | |
184 | 156 | | |
185 | | - | |
| 157 | + | |
186 | 158 | | |
187 | 159 | | |
188 | 160 | | |
189 | 161 | | |
190 | 162 | | |
191 | 163 | | |
192 | | - | |
| 164 | + | |
193 | 165 | | |
194 | | - | |
| 166 | + | |
195 | 167 | | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
| 168 | + | |
211 | 169 | | |
212 | 170 | | |
213 | | - | |
| 171 | + | |
214 | 172 | | |
215 | 173 | | |
216 | | - | |
217 | | - | |
| 174 | + | |
| 175 | + | |
218 | 176 | | |
219 | 177 | | |
220 | | - | |
| 178 | + | |
221 | 179 | | |
222 | 180 | | |
223 | 181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
| |||
93 | 92 | | |
94 | 93 | | |
95 | 94 | | |
96 | | - | |
97 | 95 | | |
98 | 96 | | |
99 | 97 | | |
| |||
135 | 133 | | |
136 | 134 | | |
137 | 135 | | |
138 | | - | |
139 | 136 | | |
140 | 137 | | |
141 | 138 | | |
| |||
177 | 174 | | |
178 | 175 | | |
179 | 176 | | |
180 | | - | |
181 | 177 | | |
182 | 178 | | |
183 | 179 | | |
| |||
219 | 215 | | |
220 | 216 | | |
221 | 217 | | |
222 | | - | |
223 | 218 | | |
224 | 219 | | |
225 | 220 | | |
| |||
259 | 254 | | |
260 | 255 | | |
261 | 256 | | |
262 | | - | |
263 | 257 | | |
264 | 258 | | |
265 | 259 | | |
| |||
311 | 305 | | |
312 | 306 | | |
313 | 307 | | |
314 | | - | |
315 | 308 | | |
316 | 309 | | |
317 | 310 | | |
| |||
0 commit comments