Skip to content

Commit b576b09

Browse files
authored
Add Env UI and rename put_secret to set_secret (#756)
* support get/set env and secret * fix permission * enhance get_secret * add env ui; change put_secret to set_secret * Bump hypha-rpc version to 0.20.58 * Limit token client_id * Enhance UI for token generation
1 parent 5b8aad3 commit b576b09

24 files changed

+425
-58
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
### 0.20.55
44

5-
- Add `get_secret` and `put_secret` to the artifact manager to allow storing and retrieving secret values in the artifact.
5+
- Add `get_secret` and `set_secret` to the artifact manager to allow storing and retrieving secret values in the artifact.
66
- Add `set_env` and `get_env` to workspace to allow setting and retrieving environment variables in the workspace.
7+
- Provide environment variables in the web ui.
78

89
### 0.20.41
910

docker-compose/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ This directory contains a Docker Compose setup for running Hypha Server with Min
4545

4646
The Hypha Server provides the backend API for the Hypha application.
4747

48-
- Image: `ghcr.io/amun-ai/hypha:0.20.55`
48+
- Image: `ghcr.io/amun-ai/hypha:0.20.58`
4949
- Port: 9520
5050
- Data: Stored in the local directory `./data/hypha`
5151

docker-compose/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: '3.8'
22

33
services:
44
hypha-server:
5-
image: ghcr.io/amun-ai/hypha:0.20.55
5+
image: ghcr.io/amun-ai/hypha:0.20.58
66
ports:
77
- "${HYPHA_PORT:-9527}:9527"
88
environment:

docs/artifact-manager.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -973,16 +973,15 @@ else:
973973
```
974974

975975
---
976+
### `set_secret(artifact_id: str, secret_key: str, secret_value: str) -> None`
976977

977-
### `put_secret(artifact_id: str, secret_key: str, secret_value: str) -> None`
978-
979-
Sets a secret value for an artifact. This operation requires read_write permissions.
978+
Sets or removes a secret value for an artifact. This operation requires read_write permissions.
980979

981980
**Parameters:**
982981

983982
- `artifact_id`: The id of the artifact to store the secret in. It can be a UUID generated by `create` or `edit` function, or it can be an alias of the artifact under the current workspace. If you want to refer to an artifact in another workspace, you should use the full alias in the format of `"workspace_id/alias"`.
984983
- `secret_key`: The key name for the secret.
985-
- `secret_value`: The secret value to store. Can be a string or `None`.
984+
- `secret_value`: The secret value to store. Can be a string or `None`. If set to `None`, the secret key will be removed from the artifact.
986985

987986
**Permissions:**
988987

@@ -992,21 +991,21 @@ Sets a secret value for an artifact. This operation requires read_write permissi
992991

993992
```python
994993
# Set a secret value for an artifact
995-
await artifact_manager.put_secret(
994+
await artifact_manager.set_secret(
996995
artifact_id="example-dataset",
997996
secret_key="API_KEY",
998997
secret_value="your-secret-api-key"
999998
)
1000999

10011000
# Update an existing secret
1002-
await artifact_manager.put_secret(
1001+
await artifact_manager.set_secret(
10031002
artifact_id="example-dataset",
10041003
secret_key="API_KEY",
10051004
secret_value="updated-secret-api-key"
10061005
)
10071006

10081007
# Set a secret to None (effectively removing it)
1009-
await artifact_manager.put_secret(
1008+
await artifact_manager.set_secret(
10101009
artifact_id="example-dataset",
10111010
secret_key="API_KEY",
10121011
secret_value=None

docs/getting-started.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ npm install hypha-rpc
265265
Or include it via CDN in your HTML file:
266266

267267
```html
268-
<script src="https://cdn.jsdelivr.net/npm/hypha-rpc@0.20.55/dist/hypha-rpc-websocket.min.js"></script>
268+
<script src="https://cdn.jsdelivr.net/npm/hypha-rpc@0.20.58/dist/hypha-rpc-websocket.min.js"></script>
269269
```
270270

271271
Then use the following JavaScript code to register a service:
@@ -396,7 +396,7 @@ svc = await get_remote_service("http://localhost:9527/ws-user-scintillating-lawy
396396
Include the following script in your HTML file to load the `hypha-rpc` client:
397397

398398
```html
399-
<script src="https://cdn.jsdelivr.net/npm/hypha-rpc@0.20.55/dist/hypha-rpc-websocket.min.js"></script>
399+
<script src="https://cdn.jsdelivr.net/npm/hypha-rpc@0.20.58/dist/hypha-rpc-websocket.min.js"></script>
400400
```
401401

402402
Use the following code in JavaScript to connect to the server and access an existing service:
@@ -618,6 +618,8 @@ async def main():
618618
# Set environment variables
619619
await server.set_env("DATABASE_URL", "postgres://localhost:5432/mydb")
620620
await server.set_env("API_KEY", "your-secret-key")
621+
# Remove an environment variable
622+
await server.set_env("API_KEY", None)
621623

622624
# Get a specific environment variable
623625
db_url = await server.get_env("DATABASE_URL")
@@ -643,11 +645,12 @@ async function main() {
643645
});
644646

645647
// Set environment variables
646-
await server.setEnv("DATABASE_URL", "postgres://localhost:5432/mydb");
647-
await server.setEnv("API_KEY", "your-secret-key");
648-
648+
await server.setEnv({key: "DATABASE_URL", value: "postgres://localhost:5432/mydb", _rkwargs: true});
649+
await server.setEnv({key: "API_KEY", value: "your-secret-key", _rkwargs: true});
650+
// Remove an environment variable
651+
await server.setEnv({key: "API_KEY", value: null, _rkwargs: true});
649652
// Get a specific environment variable
650-
const dbUrl = await server.getEnv("DATABASE_URL");
653+
const dbUrl = await server.getEnv({key: "DATABASE_URL", value: null, _rkwargs: true});
651654
console.log("Database URL:", dbUrl);
652655

653656
// Get all environment variables

docs/migration-guide.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ To connect to the server, instead of installing the `imjoy-rpc` module, you will
1515
pip install -U hypha-rpc # new install
1616
```
1717

18-
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.55` is compatible with Hypha server version `0.20.55`.
18+
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.58` is compatible with Hypha server version `0.20.58`.
1919

2020
#### 2. Change the imports to use `hypha-rpc`
2121

@@ -128,10 +128,10 @@ loop.run_forever()
128128
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:
129129

130130
```html
131-
<script src="https://cdn.jsdelivr.net/npm/hypha-rpc@0.20.55/dist/hypha-rpc-websocket.min.js"></script>
131+
<script src="https://cdn.jsdelivr.net/npm/hypha-rpc@0.20.58/dist/hypha-rpc-websocket.min.js"></script>
132132
```
133133

134-
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.55` is compatible with Hypha server version `0.20.55`.
134+
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.58` is compatible with Hypha server version `0.20.58`.
135135

136136
#### 2. Change the connection method and use camelCase for service function names
137137

@@ -149,7 +149,7 @@ Here is a suggested list of search and replace operations to update your code:
149149
Here is an example of how the updated code might look:
150150

151151
```html
152-
<script src="https://cdn.jsdelivr.net/npm/hypha-rpc@0.20.55/dist/hypha-rpc-websocket.min.js"></script>
152+
<script src="https://cdn.jsdelivr.net/npm/hypha-rpc@0.20.58/dist/hypha-rpc-websocket.min.js"></script>
153153
<script>
154154
async function main(){
155155
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](.
197197
Here is a quick example in JavaScript:
198198

199199
```html
200-
<script src="https://cdn.jsdelivr.net/npm/hypha-rpc@0.20.55/dist/hypha-rpc-websocket.min.js"></script>
200+
<script src="https://cdn.jsdelivr.net/npm/hypha-rpc@0.20.58/dist/hypha-rpc-websocket.min.js"></script>
201201

202202
<script>
203203
async function main(){

docs/quick-guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ if __name__ == "__main__":
4848
### JavaScript
4949

5050
```html
51-
<script src="https://cdn.jsdelivr.net/npm/hypha-rpc@0.20.55/dist/hypha-rpc-websocket.min.js"></script>
51+
<script src="https://cdn.jsdelivr.net/npm/hypha-rpc@0.20.58/dist/hypha-rpc-websocket.min.js"></script>
5252
<script>
5353
async function registerService() {
5454
const server = await hyphaWebsocketClient.connectToServer({
@@ -106,7 +106,7 @@ if __name__ == "__main__":
106106
### JavaScript Client
107107

108108
```html
109-
<script src="https://cdn.jsdelivr.net/npm/hypha-rpc@0.20.55/dist/hypha-rpc-websocket.min.js"></script>
109+
<script src="https://cdn.jsdelivr.net/npm/hypha-rpc@0.20.58/dist/hypha-rpc-websocket.min.js"></script>
110110
<script>
111111
async function useService() {
112112
const server = await hyphaWebsocketClient.connectToServer({

docs/service-type-annotation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ if __name__ == "__main__":
134134
**JavaScript Client: Service Usage**
135135

136136
```html
137-
<script src="https://cdn.jsdelivr.net/npm/hypha-rpc@0.20.55/dist/hypha-rpc-websocket.min.js"></script>
137+
<script src="https://cdn.jsdelivr.net/npm/hypha-rpc@0.20.58/dist/hypha-rpc-websocket.min.js"></script>
138138
<script>
139139
async function main() {
140140
const server = await hyphaWebsocketClient.connectToServer({"server_url": "https://hypha.amun.ai"});

helm-charts/aks-hypha.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ replicaCount: 1
146146
image:
147147
repository: ghcr.io/amun-ai/hypha
148148
pullPolicy: IfNotPresent
149-
tag: "0.20.55"
149+
tag: "0.20.58"
150150
151151
serviceAccount:
152152
create: true

helm-charts/hypha-server/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.20.55
18+
version: 0.20.58
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to

0 commit comments

Comments
 (0)