patchwell 0.1.0__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {patchwell-0.1.0 → patchwell-0.2.0}/PKG-INFO +8 -2
- {patchwell-0.1.0 → patchwell-0.2.0}/README.md +6 -0
- {patchwell-0.1.0 → patchwell-0.2.0}/patchwell/__init__.py +34 -3
- {patchwell-0.1.0 → patchwell-0.2.0}/patchwell.egg-info/PKG-INFO +8 -2
- {patchwell-0.1.0 → patchwell-0.2.0}/pyproject.toml +21 -21
- {patchwell-0.1.0 → patchwell-0.2.0}/tests/test_sdk.py +90 -58
- {patchwell-0.1.0 → patchwell-0.2.0}/LICENSE +0 -0
- {patchwell-0.1.0 → patchwell-0.2.0}/patchwell.egg-info/SOURCES.txt +0 -0
- {patchwell-0.1.0 → patchwell-0.2.0}/patchwell.egg-info/dependency_links.txt +0 -0
- {patchwell-0.1.0 → patchwell-0.2.0}/patchwell.egg-info/top_level.txt +0 -0
- {patchwell-0.1.0 → patchwell-0.2.0}/setup.cfg +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: patchwell
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Transcription, data cleaning and cited research for scripts, pipelines and AI agents. Pay per result.
|
|
5
5
|
License: MIT
|
|
6
6
|
Project-URL: Homepage, https://patchwell.io
|
|
7
7
|
Project-URL: Documentation, https://patchwell.io/quickstart
|
|
8
|
-
Keywords: transcription,data cleaning,deduplication,research,api,
|
|
8
|
+
Keywords: transcription,data cleaning,deduplication,research,api,speech-to-text,csv
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
11
11
|
Classifier: Operating System :: OS Independent
|
|
@@ -58,6 +58,12 @@ d = pw.research("How old was the author of Dracula when it was published?", dept
|
|
|
58
58
|
|
|
59
59
|
# Results as files
|
|
60
60
|
open("clean.xlsx", "wb").write(pw.export(clean, "xlsx"))
|
|
61
|
+
|
|
62
|
+
# Any tool by name, including tools added after this version: the input is the tool's own JSON body
|
|
63
|
+
for name, tool in pw.tools().items(): # every tool, read live from the API
|
|
64
|
+
print(name, tool["price"])
|
|
65
|
+
print(pw.describe("research")["input_schema"]) # what a tool takes
|
|
66
|
+
r = pw.run("research", ask="Which EU countries require e-invoicing in 2026?", depth="deep")
|
|
61
67
|
```
|
|
62
68
|
|
|
63
69
|
## Retries never charge twice
|
|
@@ -42,6 +42,12 @@ d = pw.research("How old was the author of Dracula when it was published?", dept
|
|
|
42
42
|
|
|
43
43
|
# Results as files
|
|
44
44
|
open("clean.xlsx", "wb").write(pw.export(clean, "xlsx"))
|
|
45
|
+
|
|
46
|
+
# Any tool by name, including tools added after this version: the input is the tool's own JSON body
|
|
47
|
+
for name, tool in pw.tools().items(): # every tool, read live from the API
|
|
48
|
+
print(name, tool["price"])
|
|
49
|
+
print(pw.describe("research")["input_schema"]) # what a tool takes
|
|
50
|
+
r = pw.run("research", ask="Which EU countries require e-invoicing in 2026?", depth="deep")
|
|
45
51
|
```
|
|
46
52
|
|
|
47
53
|
## Retries never charge twice
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
clean = pw.clean_data(url="https://example.com/leads.csv")
|
|
6
6
|
notes = pw.transcribe("https://example.com/call.mp3") # waits for long recordings
|
|
7
7
|
answer = pw.research("Which EU countries require e-invoicing in 2026?")
|
|
8
|
+
out = pw.run("rerank", query="refund policy", documents=[...]) # any tool by name, new ones included
|
|
9
|
+
for name, t in pw.tools().items(): print(name, t["price"]) # every tool, live from the API
|
|
8
10
|
|
|
9
11
|
Standard library only, so it runs anywhere (Lambda, Airflow, cron, notebooks). Every call carries an
|
|
10
12
|
Idempotency-Key: a retry after a timeout returns the first response and is never charged twice. Errors raise
|
|
@@ -17,10 +19,11 @@ import json
|
|
|
17
19
|
import os
|
|
18
20
|
import time
|
|
19
21
|
import urllib.error
|
|
22
|
+
import urllib.parse
|
|
20
23
|
import urllib.request
|
|
21
24
|
import uuid
|
|
22
25
|
|
|
23
|
-
__version__ = "0.
|
|
26
|
+
__version__ = "0.2.0"
|
|
24
27
|
__all__ = ["Patchwell", "PatchwellError", "PatchwellTimeout", "verify_webhook"]
|
|
25
28
|
|
|
26
29
|
DEFAULT_BASE = "https://patchwell.io"
|
|
@@ -122,7 +125,29 @@ class Patchwell:
|
|
|
122
125
|
r.pop("_retry_after", None)
|
|
123
126
|
return r
|
|
124
127
|
|
|
125
|
-
# ------------------------------------------------------------------
|
|
128
|
+
# ------------------------------------------------------------------ any tool, by name
|
|
129
|
+
def tools(self) -> dict:
|
|
130
|
+
"""Every tool you can call, live from GET /v1/tools: {name: {name, line, category, price, input, returns,
|
|
131
|
+
run, describe, ...}}. New tools appear here (and work with run()) without a new SDK version."""
|
|
132
|
+
r = self.request("GET", "/v1/tools")
|
|
133
|
+
return r.get("tools", {}) if isinstance(r, dict) else {}
|
|
134
|
+
|
|
135
|
+
def describe(self, tool: str) -> dict:
|
|
136
|
+
"""One tool's input as a JSON Schema, its options, limits and price (GET /v1/tools/{tool})."""
|
|
137
|
+
r = self.request("GET", f"/v1/tools/{urllib.parse.quote(str(tool), safe='')}")
|
|
138
|
+
if isinstance(r, dict):
|
|
139
|
+
r.pop("_retry_after", None)
|
|
140
|
+
return r
|
|
141
|
+
|
|
142
|
+
def run(self, tool: str, input: dict | None = None, *, wait: bool = True, timeout: float = 4 * 3600,
|
|
143
|
+
**fields) -> dict:
|
|
144
|
+
"""Run any tool by name (POST /v1/run/{tool}): the input is that tool's own JSON body, as a dict, as keyword
|
|
145
|
+
arguments, or both. Waits for long jobs like the named methods; idempotency_key and callback_url work
|
|
146
|
+
the same way. Example: pw.run("describe_image", url="https://example.com/a.png")."""
|
|
147
|
+
body = dict(input or {}, **fields)
|
|
148
|
+
return self._tool(f"/v1/run/{urllib.parse.quote(str(tool), safe='')}", body, wait, timeout)
|
|
149
|
+
|
|
150
|
+
# ------------------------------------------------------------------ the core tools (thin wrappers)
|
|
126
151
|
def clean_data(self, url: str | None = None, *, rows: list | None = None, csv_text: str | None = None,
|
|
127
152
|
content: bytes | None = None, filename: str | None = None, inputs: list | None = None,
|
|
128
153
|
wait: bool = True, timeout: float = 3600, **options) -> dict:
|
|
@@ -199,7 +224,13 @@ class Patchwell:
|
|
|
199
224
|
timeout: float = 24 * 3600) -> dict:
|
|
200
225
|
"""Queue many items for one tool (each the input that tool takes, optionally {"custom_id", "input"}). They
|
|
201
226
|
run in parallel at this key's share, each priced like a single call; failed items are free. wait=True blocks
|
|
202
|
-
until the batch ends and returns it; read the items with batch_results().
|
|
227
|
+
until the batch ends and returns it; read the items with batch_results().
|
|
228
|
+
|
|
229
|
+
Already scraped reels? Pass the scraper's rows as items, or its dataset export link (JSON or JSONL) as
|
|
230
|
+
items_url, with tool "transcribe". Each row's audioUrl or videoUrl is transcribed, and each result line
|
|
231
|
+
carries the reel's url, shortCode, ownerUsername, caption and timestamp under "details". Patchwell doesn't
|
|
232
|
+
fetch from Instagram, and Instagram's media links expire a few hours after the scrape: an expired one fails
|
|
233
|
+
free with reason "media_link_expired"."""
|
|
203
234
|
body = {"tool": tool, "items": items, "items_url": items_url, "max_cost_usd": max_cost_usd,
|
|
204
235
|
"callback_url": callback_url}
|
|
205
236
|
r = self.request("POST", "/v1/batches", {k: v for k, v in body.items() if v is not None})
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: patchwell
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Transcription, data cleaning and cited research for scripts, pipelines and AI agents. Pay per result.
|
|
5
5
|
License: MIT
|
|
6
6
|
Project-URL: Homepage, https://patchwell.io
|
|
7
7
|
Project-URL: Documentation, https://patchwell.io/quickstart
|
|
8
|
-
Keywords: transcription,data cleaning,deduplication,research,api,
|
|
8
|
+
Keywords: transcription,data cleaning,deduplication,research,api,speech-to-text,csv
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
11
11
|
Classifier: Operating System :: OS Independent
|
|
@@ -58,6 +58,12 @@ d = pw.research("How old was the author of Dracula when it was published?", dept
|
|
|
58
58
|
|
|
59
59
|
# Results as files
|
|
60
60
|
open("clean.xlsx", "wb").write(pw.export(clean, "xlsx"))
|
|
61
|
+
|
|
62
|
+
# Any tool by name, including tools added after this version: the input is the tool's own JSON body
|
|
63
|
+
for name, tool in pw.tools().items(): # every tool, read live from the API
|
|
64
|
+
print(name, tool["price"])
|
|
65
|
+
print(pw.describe("research")["input_schema"]) # what a tool takes
|
|
66
|
+
r = pw.run("research", ask="Which EU countries require e-invoicing in 2026?", depth="deep")
|
|
61
67
|
```
|
|
62
68
|
|
|
63
69
|
## Retries never charge twice
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools>=68"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "patchwell"
|
|
7
|
-
version = "0.
|
|
8
|
-
description = "Transcription, data cleaning and cited research for scripts, pipelines and AI agents. Pay per result."
|
|
9
|
-
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.9"
|
|
11
|
-
license = { text = "MIT" }
|
|
12
|
-
dependencies = []
|
|
13
|
-
keywords = ["transcription", "data cleaning", "deduplication", "research", "api", "
|
|
14
|
-
classifiers = ["Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent"]
|
|
15
|
-
|
|
16
|
-
[project.urls]
|
|
17
|
-
Homepage = "https://patchwell.io"
|
|
18
|
-
Documentation = "https://patchwell.io/quickstart"
|
|
19
|
-
|
|
20
|
-
[tool.setuptools]
|
|
21
|
-
packages = ["patchwell"]
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "patchwell"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Transcription, data cleaning and cited research for scripts, pipelines and AI agents. Pay per result."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
dependencies = []
|
|
13
|
+
keywords = ["transcription", "data cleaning", "deduplication", "research", "api", "speech-to-text", "csv"]
|
|
14
|
+
classifiers = ["Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent"]
|
|
15
|
+
|
|
16
|
+
[project.urls]
|
|
17
|
+
Homepage = "https://patchwell.io"
|
|
18
|
+
Documentation = "https://patchwell.io/quickstart"
|
|
19
|
+
|
|
20
|
+
[tool.setuptools]
|
|
21
|
+
packages = ["patchwell"]
|
|
@@ -136,61 +136,93 @@ def test_webhook_verification_matches_the_server_signer():
|
|
|
136
136
|
def test_export_returns_bytes(env):
|
|
137
137
|
data = env.pw.export({"rows": [{"a": 1}], "columns": {"a": {"kind": "number"}}}, "csv")
|
|
138
138
|
assert isinstance(data, bytes) and data.lstrip(b"\xef\xbb\xbf").startswith(b"a,") # BOM: Excel opens it right
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
def test_batches_submit_wait_and_read_results():
|
|
142
|
-
sent, polls = [], iter(["queued", "running", "completed"])
|
|
143
|
-
|
|
144
|
-
def t(m, u, h, b, timeout):
|
|
145
|
-
path = u.split("patchwell.io", 1)[1]
|
|
146
|
-
sent.append((m, path, json.loads(b) if b else None))
|
|
147
|
-
if (m, path) == ("POST", "/v1/batches"):
|
|
148
|
-
return 202, {"retry-after": "10"}, json.dumps({"id": "bt_1", "status": "queued"}).encode()
|
|
149
|
-
if path == "/v1/batches/bt_1":
|
|
150
|
-
return 200, {}, json.dumps({"id": "bt_1", "status": next(polls)}).encode()
|
|
151
|
-
if path.startswith("/v1/batches/bt_1/results"):
|
|
152
|
-
return 200, {}, b'{"index": 0, "custom_id": "a", "status": "succeeded"}\n'
|
|
153
|
-
if path == "/v1/quotes":
|
|
154
|
-
return 200, {}, json.dumps({"cost_usd": {"low": 0, "high": 0.3}}).encode()
|
|
155
|
-
return 200, {}, b"{}"
|
|
156
|
-
pw = patchwell.Patchwell("k", base_url="https://patchwell.io", transport=t, sleep=lambda s: None)
|
|
157
|
-
assert pw.quote("research", count=2)["cost_usd"]["high"] == 0.3
|
|
158
|
-
done = pw.batch("research", [{"custom_id": "a", "ask": "q"}], max_cost_usd=1, wait=True)
|
|
159
|
-
assert done["status"] == "completed"
|
|
160
|
-
assert sent[1] == ("POST", "/v1/batches", {"tool": "research", "items": [{"custom_id": "a", "ask": "q"}],
|
|
161
|
-
"max_cost_usd": 1})
|
|
162
|
-
assert pw.batch_results("bt_1") == [{"index": 0, "custom_id": "a", "status": "succeeded"}]
|
|
163
|
-
pw.batch_results("bt_1", status="failed")
|
|
164
|
-
assert sent[-1][1] == "/v1/batches/bt_1/results?status=failed"
|
|
165
|
-
pw.cancel_batch("bt_1")
|
|
166
|
-
pw.cancel_job("fc-9")
|
|
167
|
-
assert [s[1] for s in sent[-2:]] == ["/v1/batches/bt_1/cancel", "/v1/jobs/fc-9/cancel"]
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
def test_a_callers_own_idempotency_key_is_sent_as_is():
|
|
171
|
-
"""2026-11-22 audit: a process-level retry (a cron rerun of the same item) minted a new key and paid twice."""
|
|
172
|
-
seen = []
|
|
173
|
-
|
|
174
|
-
def t(m, u, h, b, timeout):
|
|
175
|
-
seen.append(h.get("Idempotency-Key"))
|
|
176
|
-
return (200, {}, json.dumps({"rows": [], "stats": {}}).encode())
|
|
177
|
-
pw = patchwell.Patchwell("k", transport=t, sleep=lambda s: None)
|
|
178
|
-
pw.clean_data(url="https://x.test/a.csv", idempotency_key="order-1234")
|
|
179
|
-
pw.clean_data(url="https://x.test/a.csv", idempotency_key="order-1234")
|
|
180
|
-
assert seen == ["order-1234", "order-1234"]
|
|
181
|
-
assert "idempotency_key" not in json.dumps(seen)
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
@pytest.mark.parametrize("final,code,retryable", [
|
|
185
|
-
({"status": "failed", "job_id": "fc-1", "error": "container stopped", "code": "internal", "retryable": True},
|
|
186
|
-
"internal", True),
|
|
187
|
-
({"status": "cancelled", "job_id": "fc-1", "error": "cancelled by the caller", "code": "cancelled",
|
|
188
|
-
"retryable": False}, "cancelled", False)])
|
|
189
|
-
def test_a_failed_or_cancelled_job_raises_with_the_servers_code(final, code, retryable):
|
|
190
|
-
answers = [(202, {}, json.dumps({"status": "running", "job_id": "fc-1"}).encode()), (200, {}, json.dumps(final).encode())]
|
|
191
|
-
n = []
|
|
192
|
-
pw = patchwell.Patchwell("k", transport=lambda m, u, h, b, t: n.append(1) or answers[len(n) - 1],
|
|
193
|
-
sleep=lambda s: None)
|
|
194
|
-
with pytest.raises(patchwell.PatchwellError) as e:
|
|
195
|
-
pw.transcribe("https://x.test/a.mp3")
|
|
196
|
-
assert e.value.code == code and e.value.retryable is retryable
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def test_batches_submit_wait_and_read_results():
|
|
142
|
+
sent, polls = [], iter(["queued", "running", "completed"])
|
|
143
|
+
|
|
144
|
+
def t(m, u, h, b, timeout):
|
|
145
|
+
path = u.split("patchwell.io", 1)[1]
|
|
146
|
+
sent.append((m, path, json.loads(b) if b else None))
|
|
147
|
+
if (m, path) == ("POST", "/v1/batches"):
|
|
148
|
+
return 202, {"retry-after": "10"}, json.dumps({"id": "bt_1", "status": "queued"}).encode()
|
|
149
|
+
if path == "/v1/batches/bt_1":
|
|
150
|
+
return 200, {}, json.dumps({"id": "bt_1", "status": next(polls)}).encode()
|
|
151
|
+
if path.startswith("/v1/batches/bt_1/results"):
|
|
152
|
+
return 200, {}, b'{"index": 0, "custom_id": "a", "status": "succeeded"}\n'
|
|
153
|
+
if path == "/v1/quotes":
|
|
154
|
+
return 200, {}, json.dumps({"cost_usd": {"low": 0, "high": 0.3}}).encode()
|
|
155
|
+
return 200, {}, b"{}"
|
|
156
|
+
pw = patchwell.Patchwell("k", base_url="https://patchwell.io", transport=t, sleep=lambda s: None)
|
|
157
|
+
assert pw.quote("research", count=2)["cost_usd"]["high"] == 0.3
|
|
158
|
+
done = pw.batch("research", [{"custom_id": "a", "ask": "q"}], max_cost_usd=1, wait=True)
|
|
159
|
+
assert done["status"] == "completed"
|
|
160
|
+
assert sent[1] == ("POST", "/v1/batches", {"tool": "research", "items": [{"custom_id": "a", "ask": "q"}],
|
|
161
|
+
"max_cost_usd": 1})
|
|
162
|
+
assert pw.batch_results("bt_1") == [{"index": 0, "custom_id": "a", "status": "succeeded"}]
|
|
163
|
+
pw.batch_results("bt_1", status="failed")
|
|
164
|
+
assert sent[-1][1] == "/v1/batches/bt_1/results?status=failed"
|
|
165
|
+
pw.cancel_batch("bt_1")
|
|
166
|
+
pw.cancel_job("fc-9")
|
|
167
|
+
assert [s[1] for s in sent[-2:]] == ["/v1/batches/bt_1/cancel", "/v1/jobs/fc-9/cancel"]
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def test_a_callers_own_idempotency_key_is_sent_as_is():
|
|
171
|
+
"""2026-11-22 audit: a process-level retry (a cron rerun of the same item) minted a new key and paid twice."""
|
|
172
|
+
seen = []
|
|
173
|
+
|
|
174
|
+
def t(m, u, h, b, timeout):
|
|
175
|
+
seen.append(h.get("Idempotency-Key"))
|
|
176
|
+
return (200, {}, json.dumps({"rows": [], "stats": {}}).encode())
|
|
177
|
+
pw = patchwell.Patchwell("k", transport=t, sleep=lambda s: None)
|
|
178
|
+
pw.clean_data(url="https://x.test/a.csv", idempotency_key="order-1234")
|
|
179
|
+
pw.clean_data(url="https://x.test/a.csv", idempotency_key="order-1234")
|
|
180
|
+
assert seen == ["order-1234", "order-1234"]
|
|
181
|
+
assert "idempotency_key" not in json.dumps(seen)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
@pytest.mark.parametrize("final,code,retryable", [
|
|
185
|
+
({"status": "failed", "job_id": "fc-1", "error": "container stopped", "code": "internal", "retryable": True},
|
|
186
|
+
"internal", True),
|
|
187
|
+
({"status": "cancelled", "job_id": "fc-1", "error": "cancelled by the caller", "code": "cancelled",
|
|
188
|
+
"retryable": False}, "cancelled", False)])
|
|
189
|
+
def test_a_failed_or_cancelled_job_raises_with_the_servers_code(final, code, retryable):
|
|
190
|
+
answers = [(202, {}, json.dumps({"status": "running", "job_id": "fc-1"}).encode()), (200, {}, json.dumps(final).encode())]
|
|
191
|
+
n = []
|
|
192
|
+
pw = patchwell.Patchwell("k", transport=lambda m, u, h, b, t: n.append(1) or answers[len(n) - 1],
|
|
193
|
+
sleep=lambda s: None)
|
|
194
|
+
with pytest.raises(patchwell.PatchwellError) as e:
|
|
195
|
+
pw.transcribe("https://x.test/a.mp3")
|
|
196
|
+
assert e.value.code == code and e.value.retryable is retryable
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def test_run_calls_any_tool_by_name_through_the_api(env):
|
|
200
|
+
"""run() needs no per-tool code: it posts the tool's own body to /v1/run/{tool}, and the server runs that tool's
|
|
201
|
+
route, so the result is the same as the named method's."""
|
|
202
|
+
named = env.pw.clean_data(rows=[{"Email": "A@X.COM"}])
|
|
203
|
+
generic = env.pw.run("clean_data", {"rows": [{"Email": "A@X.COM"}]})
|
|
204
|
+
kw = env.pw.run("clean_data", rows=[{"Email": "A@X.COM"}], idempotency_key="row-7")
|
|
205
|
+
same = lambda r: (r["rows"], r["stats"], r["columns"]) # job ids and timings differ
|
|
206
|
+
assert same(generic) == same(named) == same(kw) and env.calls[1]["rows"] == [{"Email": "A@X.COM"}]
|
|
207
|
+
method, path, headers = env.log[-1]
|
|
208
|
+
assert (method, path) == ("POST", "/v1/run/clean_data") and headers["Idempotency-Key"] == "row-7"
|
|
209
|
+
with pytest.raises(patchwell.PatchwellError) as e:
|
|
210
|
+
env.pw.run("no_such_tool", x=1)
|
|
211
|
+
assert e.value.status == 404
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def test_tools_and_describe_read_the_live_catalog(env):
|
|
215
|
+
tools = env.pw.tools()
|
|
216
|
+
assert {"transcribe", "research", "clean_data"} <= set(tools)
|
|
217
|
+
assert tools["research"]["run"] == "/v1/run/research" and tools["research"]["price"]
|
|
218
|
+
d = env.pw.describe("research")
|
|
219
|
+
assert "ask" in d["input_schema"]["properties"]
|
|
220
|
+
assert patchwell.__version__ == "0.2.0"
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
def test_a_tool_name_is_sent_as_one_path_segment():
|
|
224
|
+
sent = []
|
|
225
|
+
pw = patchwell.Patchwell("k", transport=lambda m, u, h, b, t: sent.append(u) or (200, {}, b"{}"))
|
|
226
|
+
pw.run("a/../b?x", wait=False)
|
|
227
|
+
pw.describe("a b")
|
|
228
|
+
assert sent == ["https://patchwell.io/v1/run/a%2F..%2Fb%3Fx", "https://patchwell.io/v1/tools/a%20b"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|