-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support current workspace in http proxy (#691)
* support _token and remove prefix in login * allow pass workspace when login * Support current workspace for http endpoint * fix login optional * increase page size for list workspaces * Bump version for hypha-rpc 0.20.38 * Update change logs and login instructions
- Loading branch information
Showing
20 changed files
with
183 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected].37/dist/hypha-rpc-websocket.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected].38/dist/hypha-rpc-websocket.min.js"></script> | ||
``` | ||
|
||
Use the following code in JavaScript to connect to the server and access an existing service: | ||
|
@@ -250,7 +250,7 @@ By default all the clients connected to Hypha server communicate via the websock | |
|
||
### User Login and Token-Based Authentication | ||
|
||
To access the full features of the Hypha server, users need to log in and obtain a token for authentication. The new `login()` function provides a convenient way to display a login URL, once the user click it and login, it can then return the token for connecting to the server. | ||
To access the full features of the Hypha server, users need to log in and obtain a token for authentication. The `login()` function provides a convenient way to display a login URL, once the user click it and login, it can then return the token for connecting to the server. | ||
|
||
Here is an example of how the login process works using the `login()` function: | ||
|
||
|
@@ -294,7 +294,27 @@ The output will provide a URL for the user to open in their browser and | |
|
||
perform the login process. Once the user clicks the link and successfully logs in, the `login()` function will return, providing the token. | ||
|
||
The `login()` function also supports additional arguments: | ||
#### Additional Arguments for Login | ||
|
||
You can specify the `workspace` and `expires_in` arguments in the `login()` function so that the token is generated for a specific workspace and expires after a certain period of time. | ||
|
||
```python | ||
token = await login( | ||
{ | ||
"server_url": SERVER_URL, | ||
"workspace": "my-workspace", | ||
"expires_in": 3600, | ||
} | ||
) | ||
``` | ||
|
||
If a token is generated for a specific workspace, when calling `connect_to_server`, you need to specify the same workspace as well: | ||
|
||
```python | ||
server = await connect_to_server({"server_url": "https://ai.imjoy.io", "token": token, "workspace": "my-workspace"}) | ||
``` | ||
|
||
The `login()` function also supports other additional arguments: | ||
|
||
```python | ||
token = await login( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.37` is compatible with Hypha server version `0.20.37`. | ||
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.38` is compatible with Hypha server version `0.20.38`. | ||
|
||
#### 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 | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected].37/dist/hypha-rpc-websocket.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected].38/dist/hypha-rpc-websocket.min.js"></script> | ||
``` | ||
|
||
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.37` is compatible with Hypha server version `0.20.37`. | ||
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.38` is compatible with Hypha server version `0.20.38`. | ||
|
||
#### 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 | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected].37/dist/hypha-rpc-websocket.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected].38/dist/hypha-rpc-websocket.min.js"></script> | ||
<script> | ||
async function main(){ | ||
const server = await hyphaWebsocketClient.connectToServer({"server_url": "https://hypha.amun.ai"}); | ||
|
@@ -197,7 +197,7 @@ We created a tutorial to introduce this new feature: [service type annotation](. | |
Here is a quick example in JavaScript: | ||
|
||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected].37/dist/hypha-rpc-websocket.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected].38/dist/hypha-rpc-websocket.min.js"></script> | ||
|
||
<script> | ||
async function main(){ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,7 +134,7 @@ if __name__ == "__main__": | |
**JavaScript Client: Service Usage** | ||
|
||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected].37/dist/hypha-rpc-websocket.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected].38/dist/hypha-rpc-websocket.min.js"></script> | ||
<script> | ||
async function main() { | ||
const server = await hyphaWebsocketClient.connectToServer({"server_url": "https://hypha.amun.ai"}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"version": "0.20.37.post3" | ||
"version": "0.20.38" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.