hypha-rpc 0.20.84__tar.gz → 0.20.85__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.
Files changed (31) hide show
  1. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/PKG-INFO +1 -1
  2. hypha_rpc-0.20.85/hypha_rpc/VERSION +3 -0
  3. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/hypha_rpc/__init__.py +4 -0
  4. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/hypha_rpc/rpc.py +4 -0
  5. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/hypha_rpc/sync.py +34 -0
  6. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/hypha_rpc/websocket_client.py +40 -0
  7. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/hypha_rpc.egg-info/PKG-INFO +1 -1
  8. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/pyproject.toml +1 -1
  9. hypha_rpc-0.20.84/hypha_rpc/VERSION +0 -3
  10. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/MANIFEST.in +0 -0
  11. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/README.md +0 -0
  12. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/hypha_rpc/pyodide_sse.py +0 -0
  13. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/hypha_rpc/pyodide_websocket.py +0 -0
  14. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/hypha_rpc/utils/__init__.py +0 -0
  15. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/hypha_rpc/utils/launch.py +0 -0
  16. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/hypha_rpc/utils/mcp.py +0 -0
  17. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/hypha_rpc/utils/pydantic.py +0 -0
  18. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/hypha_rpc/utils/schema.py +0 -0
  19. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/hypha_rpc/utils/serve.py +0 -0
  20. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/hypha_rpc/webrtc_client.py +0 -0
  21. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/hypha_rpc.egg-info/SOURCES.txt +0 -0
  22. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/hypha_rpc.egg-info/dependency_links.txt +0 -0
  23. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/hypha_rpc.egg-info/requires.txt +0 -0
  24. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/hypha_rpc.egg-info/top_level.txt +0 -0
  25. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/setup.cfg +0 -0
  26. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/tests/test_mcp.py +0 -0
  27. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/tests/test_reconnection_runner.py +0 -0
  28. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/tests/test_schema.py +0 -0
  29. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/tests/test_server_compatibility.py +0 -0
  30. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/tests/test_utils.py +0 -0
  31. {hypha_rpc-0.20.84 → hypha_rpc-0.20.85}/tests/test_websocket_rpc.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hypha_rpc
3
- Version: 0.20.84
3
+ Version: 0.20.85
4
4
  Summary: Hypha RPC client for connecting to Hypha server for data management and AI model serving
5
5
  Author-email: Wei Ouyang <oeway007@gmail.com>
6
6
  Requires-Python: >=3.9
@@ -0,0 +1,3 @@
1
+ {
2
+ "version": "0.20.85"
3
+ }
@@ -12,12 +12,14 @@ from .sync import connect_to_server as connect_to_server_sync
12
12
  from .sync import get_remote_service as get_remote_service_sync
13
13
  from .sync import get_rtc_service as get_rtc_service_sync
14
14
  from .sync import login as login_sync
15
+ from .sync import logout as logout_sync
15
16
  from .sync import register_rtc_service as register_rtc_service_sync
16
17
  from .webrtc_client import get_rtc_service, register_rtc_service
17
18
  from .websocket_client import (
18
19
  connect_to_server,
19
20
  get_remote_service,
20
21
  login,
22
+ logout,
21
23
  setup_local_client,
22
24
  )
23
25
 
@@ -113,9 +115,11 @@ __all__ = [
113
115
  "api",
114
116
  "RPC",
115
117
  "login",
118
+ "logout",
116
119
  "connect_to_server",
117
120
  "get_remote_service",
118
121
  "login_sync",
122
+ "logout_sync",
119
123
  "connect_to_server_sync",
120
124
  "get_remote_service_sync",
121
125
  "get_rtc_service",
@@ -1408,6 +1408,10 @@ class RPC(MessageEmitter):
1408
1408
  config["workspace"] = config.get(
1409
1409
  "workspace", self._local_workspace or self._connection.workspace
1410
1410
  )
1411
+ if config["workspace"] is None:
1412
+ raise ValueError(
1413
+ "Workspace is not set. Please ensure the connection has a workspace or set local_workspace."
1414
+ )
1411
1415
  skip_context = config.get("require_context", False)
1412
1416
  exclude_keys = ["id", "config", "name", "description", "type", "docs", "app_id", "service_schema"]
1413
1417
  filtered_service = {k: v for k, v in service.items() if k not in exclude_keys}
@@ -240,6 +240,40 @@ def login(config):
240
240
  server.disconnect()
241
241
 
242
242
 
243
+ def logout(config):
244
+ """Logout from the Hypha server."""
245
+ server_url = normalize_server_url(config.get("server_url"))
246
+ service_id = config.get("login_service_id", "public/hypha-login")
247
+ callback = config.get("logout_callback")
248
+ ssl = config.get("ssl")
249
+
250
+ server = connect_to_server(
251
+ {"name": "initial logout client", "server_url": server_url, "ssl": ssl}
252
+ )
253
+ try:
254
+ svc = server.get_service(service_id)
255
+ assert svc, f"Service {service_id} not found on the server."
256
+
257
+ # Check if logout function exists for backward compatibility
258
+ if "logout" not in svc:
259
+ raise RuntimeError(
260
+ "Logout is not supported by this server. "
261
+ "Please upgrade the Hypha server to a version that supports logout."
262
+ )
263
+
264
+ context = svc.logout({})
265
+ if callback:
266
+ callback(context)
267
+ else:
268
+ print(f"Please open your browser to logout at {context['logout_url']}")
269
+
270
+ return context
271
+ except Exception as error:
272
+ raise error
273
+ finally:
274
+ server.disconnect()
275
+
276
+
243
277
  def register_rtc_service(server, service_id, config=None):
244
278
  """Register an RTC service on the Hypha server."""
245
279
  assert isinstance(
@@ -687,6 +687,46 @@ async def login(config):
687
687
  await server.disconnect()
688
688
 
689
689
 
690
+ async def logout(config):
691
+ """Logout from the hypha server."""
692
+ server_url = config.get("server_url")
693
+ service_id = config.get("login_service_id", "public/hypha-login")
694
+ callback = config.get("logout_callback")
695
+ ssl = config.get("ssl")
696
+ additional_headers = config.get("additional_headers")
697
+
698
+ server = await connect_to_server(
699
+ {
700
+ "name": "initial logout client",
701
+ "server_url": server_url,
702
+ "ssl": ssl,
703
+ "additional_headers": additional_headers,
704
+ }
705
+ )
706
+ try:
707
+ svc = await server.get_service(service_id)
708
+ assert svc, f"Failed to get the login service: {service_id}"
709
+
710
+ # Check if logout function exists for backward compatibility
711
+ if "logout" not in svc:
712
+ raise RuntimeError(
713
+ "Logout is not supported by this server. "
714
+ "Please upgrade the Hypha server to a version that supports logout."
715
+ )
716
+
717
+ context = await svc.logout({})
718
+ if callback:
719
+ await callback(context)
720
+ else:
721
+ print(f"Please open your browser to logout at {context['logout_url']}")
722
+
723
+ return context
724
+ except Exception as error:
725
+ raise error
726
+ finally:
727
+ await server.disconnect()
728
+
729
+
690
730
  class ServerContextManager:
691
731
  """Server context manager."""
692
732
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hypha_rpc
3
- Version: 0.20.84
3
+ Version: 0.20.85
4
4
  Summary: Hypha RPC client for connecting to Hypha server for data management and AI model serving
5
5
  Author-email: Wei Ouyang <oeway007@gmail.com>
6
6
  Requires-Python: >=3.9
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "hypha_rpc"
7
- version = "0.20.84"
7
+ version = "0.20.85"
8
8
  description = "Hypha RPC client for connecting to Hypha server for data management and AI model serving"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -1,3 +0,0 @@
1
- {
2
- "version": "0.20.84"
3
- }
File without changes
File without changes
File without changes