Skip to content

Commit 3ea423f

Browse files
committed
client
1 parent de702a6 commit 3ea423f

File tree

7 files changed

+1073
-3
lines changed

7 files changed

+1073
-3
lines changed

examples/run.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import asyncio
2+
import os
3+
from datetime import datetime
4+
from typing import List
5+
6+
from inferencesh import Inference, TaskStatus
7+
8+
def main() -> None:
9+
api_key = "YOUR_INFERENCESH_API_KEY"
10+
client = Inference(api_key=api_key)
11+
12+
app = "infsh/text-templating"
13+
14+
try:
15+
result = client.run_sync(
16+
{
17+
"app": app,
18+
"input": {
19+
"template": "{1} / {2}",
20+
"strings": [
21+
"god",
22+
"particle",
23+
]
24+
},
25+
"worker_selection_mode": "private",
26+
},
27+
)
28+
29+
30+
# Print final result
31+
if result.get("status") == TaskStatus.COMPLETED:
32+
print(f"\n✓ task completed successfully!")
33+
print(f"result: {result.get('output', {}).get('result')}")
34+
else:
35+
status = result.get("status")
36+
status_name = TaskStatus(status).name if status is not None else "UNKNOWN"
37+
print(f"\n✗ task did not complete. final status: {status_name}")
38+
39+
except Exception as exc: # noqa: BLE001
40+
print(f"\nerror during run_sync: {type(exc).__name__}: {exc}")
41+
raise # Re-raise to see full traceback
42+
43+
if __name__ == "__main__":
44+
main()

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ classifiers = [
1919
dependencies = [
2020
"pydantic>=2.0.0",
2121
"tqdm>=4.67.0",
22+
# Required for the synchronous client and examples
23+
"requests>=2.31.0",
2224
]
2325

2426
[project.urls]
@@ -42,3 +44,7 @@ test = [
4244
"pytest>=7.0.0",
4345
"pytest-cov>=4.0.0",
4446
]
47+
async = [
48+
"aiohttp>=3.9.0; python_version >= '3.8'",
49+
"aiofiles>=23.2.1; python_version >= '3.8'",
50+
]

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
package_dir={"": "src"},
1111
install_requires=[
1212
"pydantic>=2.0.0",
13+
"tqdm>=4.67.0",
14+
"requests>=2.31.0",
1315
],
1416
python_requires=">=3.7",
1517
classifiers=[

src/inferencesh/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
timing_context,
1818
)
1919
from .utils import StorageDir, download
20+
from .client import Inference, AsyncInference, UploadFileOptions, TaskStatus
2021

2122
__all__ = [
2223
"BaseApp",
@@ -33,4 +34,8 @@
3334
"timing_context",
3435
"StorageDir",
3536
"download",
37+
"Inference",
38+
"AsyncInference",
39+
"UploadFileOptions",
40+
"TaskStatus",
3641
]

0 commit comments

Comments
 (0)