Skip to content

Commit

Permalink
Add .serve() for python client
Browse files Browse the repository at this point in the history
  • Loading branch information
oeway committed Aug 9, 2024
1 parent 5d0e87d commit f26ff1e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions javascript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion javascript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hypha-rpc",
"version": "0.20.14",
"version": "0.20.15",
"description": "Hypha RPC client for connecting to Hypha server for data management and AI model serving.",
"main": "index.js",
"types": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion python/hypha_rpc/VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "0.20.14"
"version": "0.20.15"
}
3 changes: 3 additions & 0 deletions python/hypha_rpc/utils/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ async def wrapper(*args, **kwargs):
new_args, new_kwargs = fill_missing_args_and_kwargs(
original_func_sig, args, kwargs
)
# TODO: Validate the input types
return await original_func(*new_args, **new_kwargs)

else:
Expand All @@ -182,6 +183,7 @@ def wrapper(*args, **kwargs):
new_args, new_kwargs = fill_missing_args_and_kwargs(
original_func_sig, args, kwargs
)
# TODO: Validate the input types
return original_func(*new_args, **new_kwargs)

wrapper.__schema__ = {
Expand Down Expand Up @@ -372,6 +374,7 @@ def process_arguments(args, kwargs):
arg = annotation.model_validate(arg)
except ValidationError:
pass
# TODO: Validate the input, for primitive types and Pydantic models
final_args.append(arg)

final_kwargs = {}
Expand Down
8 changes: 8 additions & 0 deletions python/hypha_rpc/websocket_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,14 @@ async def handle_disconnect(message):
"type": "object",
},
)

def serve():
loop = asyncio.get_event_loop()
loop.run_forever()

wm.serve = schema_function(
serve, name="serve", description="Start the event loop", parameters={}
)
return wm


Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "hypha_rpc"
version = "0.20.14"
version = "0.20.15"
description = "Hypha RPC client for connecting to Hypha server for data management and AI model serving"
readme = "README.md"
requires-python = ">=3.6"
Expand Down

0 comments on commit f26ff1e

Please sign in to comment.