From 74b8c13a7d37a36af46caef0b79a3e52b43ff868 Mon Sep 17 00:00:00 2001 From: Wei Ouyang Date: Fri, 6 Dec 2024 13:56:01 -0800 Subject: [PATCH] Support browser runner and enhance vector store (#723) * Use redis as vector search * Fix publish_to * Fix syntax * add runner; bump hypha-rpc * Enhance vector store, support persistence to s3 * bump version * rename service * small fix * Fix score return * Enhance vector store, support persistence to s3 * bump version * rename service * small fix * Fix score return * Fix unload * Update workspace.py * Update workspace.py * refine clean up logic * Print error * Improve task scheduling * add activity tracker * Fix teardown * Improve lifetime management * Fix applications and daemon * Fix time * Fix activity monitor * Fix event bus; add timeout * dump vector store * Fix vector dump * Fix errors * Fix tests * wait long enough * Fix artifact unload and load * Fix workspaces unload * Disable schechdule check * Add update * Add update * Add delay * Fix test * Long delay * Default to 60s --- CHANGELOG.md | 2 +- docs/getting-started.md | 2 +- docs/hypha-quick-tour.ipynb | 6 +- docs/migration-guide.md | 10 +- docs/service-type-annotation.md | 2 +- helm-charts/aks-hypha.md | 2 +- helm-charts/hypha-server/Chart.yaml | 2 +- helm-charts/hypha-server/values.yaml | 2 +- hypha/VERSION | 2 +- hypha/apps.py | 146 ++++- hypha/artifact.py | 173 +++++- hypha/core/__init__.py | 39 +- hypha/core/activity.py | 131 +++++ hypha/core/auth.py | 2 + hypha/core/store.py | 192 ++++++- hypha/core/workspace.py | 165 ++++-- hypha/http.py | 2 +- hypha/plugin_parser.py | 23 +- hypha/{core => }/queue.py | 0 hypha/runner/__init__.py | 14 +- hypha/runner/browser.py | 32 +- hypha/s3.py | 7 +- hypha/server.py | 5 +- hypha/taskiq_utils/__init__.py | 0 hypha/taskiq_utils/exceptions.py | 17 + hypha/taskiq_utils/redis_backend.py | 199 +++++++ hypha/taskiq_utils/redis_broker.py | 117 ++++ hypha/taskiq_utils/schedule_source.py | 92 +++ hypha/templates/apps/login_template.html | 36 +- .../hypha-core-app/hypha-app-webpython.js | 2 +- hypha/templates/index.html | 2 + hypha/templates/ws/index.html | 14 +- hypha/vectors.py | 284 ++++++++- requirements.txt | 6 +- setup.py | 6 +- tests/conftest.py | 8 +- tests/testASGIWebPythonPlugin.imjoy.html | 2 +- tests/testFunctionsPlugin.imjoy.html | 2 +- tests/testUnreliablePlugin.imjoy.html | 2 +- tests/testWebPythonPlugin.imjoy.html | 2 +- tests/testWebWorkerPlugin.imjoy.html | 2 +- tests/testWindowPlugin1.imjoy.html | 2 +- tests/test_event_bus.py | 2 +- tests/test_redis.py | 64 ++- tests/test_server_apps.py | 139 ++++- tests/test_services.py | 4 +- tests/test_vectors.py | 543 ++++++++++++++---- tests/test_workspace.py | 14 +- 48 files changed, 2173 insertions(+), 349 deletions(-) create mode 100644 hypha/core/activity.py rename hypha/{core => }/queue.py (100%) create mode 100644 hypha/taskiq_utils/__init__.py create mode 100644 hypha/taskiq_utils/exceptions.py create mode 100644 hypha/taskiq_utils/redis_backend.py create mode 100644 hypha/taskiq_utils/redis_broker.py create mode 100644 hypha/taskiq_utils/schedule_source.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 12cae0f9..574f962e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### 0.20.41 - - Add `time_limit` for server apps to limit the running time + - Add `stop_after_inactive` option for server apps to stop the server app after a period of inactivity. - Support launching server apps worker in a separate service ### 0.20.40 diff --git a/docs/getting-started.md b/docs/getting-started.md index 99c2a77d..31cbfd51 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -220,7 +220,7 @@ svc = await get_remote_service("http://localhost:9527/ws-user-scintillating-lawy Include the following script in your HTML file to load the `hypha-rpc` client: ```html - + ``` Use the following code in JavaScript to connect to the server and access an existing service: diff --git a/docs/hypha-quick-tour.ipynb b/docs/hypha-quick-tour.ipynb index d82664e4..5a87389b 100644 --- a/docs/hypha-quick-tour.ipynb +++ b/docs/hypha-quick-tour.ipynb @@ -2,7 +2,7 @@ "cells": [ { "attachments": {}, - "cell_type": "markdown", + "close_after_inactive: "markdown", "metadata": {}, "source": [ "# Hypha Demos\n", @@ -10,7 +10,7 @@ "## Install client library" ] }, - { + {close_after_inactive "cell_type": "code", "execution_count": null, "metadata": {}, @@ -24,7 +24,7 @@ " # For native python with pip\n", " import subprocess\n", " subprocess.call(['pip', 'install', 'hypha-rpc'])" - ] + ]close_after_inactive }, { "attachments": {}, diff --git a/docs/migration-guide.md b/docs/migration-guide.md index 27cfb483..ee3d772b 100644 --- a/docs/migration-guide.md +++ b/docs/migration-guide.md @@ -15,7 +15,7 @@ To connect to the server, instead of installing the `imjoy-rpc` module, you will pip install -U hypha-rpc # new install ``` -We also changed our versioning strategy, we use the same version number for the server and client, so it's easier to match the client and server versions. For example, `hypha-rpc` version `0.20.41` is compatible with Hypha server version `0.20.41`. +We also changed our versioning strategy, we use the same version number for the server and client, so it's easier to match the client and server versions. For example, `hypha-rpc` version `0.20.42` is compatible with Hypha server version `0.20.42`. #### 2. Change the imports to use `hypha-rpc` @@ -128,10 +128,10 @@ loop.run_forever() To connect to the server, instead of using the `imjoy-rpc` module, you will need to use the `hypha-rpc` module. The `hypha-rpc` module is a standalone module that provides the RPC connection to the Hypha server. You can include it in your HTML using a script tag: ```html - + ``` -We also changed our versioning strategy, we use the same version number for the server and client, so it's easier to match the client and server versions. For example, `hypha-rpc` version `0.20.41` is compatible with Hypha server version `0.20.41`. +We also changed our versioning strategy, we use the same version number for the server and client, so it's easier to match the client and server versions. For example, `hypha-rpc` version `0.20.42` is compatible with Hypha server version `0.20.42`. #### 2. Change the connection method and use camelCase for service function names @@ -149,7 +149,7 @@ Here is a suggested list of search and replace operations to update your code: Here is an example of how the updated code might look: ```html - + + +