-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'chatbot_extension' into main
- Loading branch information
Showing
29 changed files
with
1,738 additions
and
331 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Build and Publish Docker Image | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # Trigger the workflow on pushes to the main branch | ||
pull_request: | ||
branches: | ||
- main # Trigger the workflow on pull requests to the main branch | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/[email protected] | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/[email protected] | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push Docker image (latest tag) | ||
uses: docker/[email protected] | ||
with: | ||
context: . | ||
file: Dockerfile | ||
push: true | ||
tags: ghcr.io/${{ github.repository }}:latest | ||
labels: | | ||
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} |
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 |
---|---|---|
|
@@ -4,7 +4,6 @@ __pycache__/ | |
*.egg-info/ | ||
build/ | ||
dist/ | ||
docs/ | ||
user_docs/ | ||
tests/cache | ||
tests/generated_json_schemas | ||
|
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Use an image with Python 3.11 | ||
FROM python:3.11-slim | ||
|
||
# Set the working directory | ||
WORKDIR /app/ | ||
|
||
# Create a non-root user | ||
RUN groupadd -r bioimageio_colab && useradd -r -g bioimageio_colab bioimageio_colab | ||
|
||
# Install necessary system packages | ||
RUN apt-get update && apt-get install -y \ | ||
curl \ | ||
jq \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Upgrade pip | ||
RUN pip install --upgrade pip | ||
|
||
# Copy the requirements file for SAM to the docker environment | ||
COPY ./requirements.txt /app/requirements.txt | ||
COPY ./requirements-sam.txt /app/requirements-sam.txt | ||
|
||
# Install the required packages for SAM | ||
RUN pip install -r /app/requirements-sam.txt | ||
|
||
# Copy the python script to the docker environment | ||
COPY ./bioimageio_colab/register_sam_service.py /app/register_sam_service.py | ||
|
||
# Change ownership of the application directory to the non-root user | ||
RUN chown -R bioimageio_colab:bioimageio_colab /app/ | ||
|
||
# Fetch the Hypha server version and reinstall or upgrade hypha-rpc to the matching version | ||
RUN HYPHA_VERSION=$(curl -s https://hypha.aicell.io/config.json | jq -r '.hypha_version') && \ | ||
pip install --upgrade "hypha-rpc<=$HYPHA_VERSION" | ||
|
||
# Switch to the non-root user | ||
USER bioimageio_colab | ||
|
||
# Register the segmentation model as a hypha service | ||
ENTRYPOINT ["python", "register_sam_service.py"] |
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import argparse | ||
from hypha_rpc import connect_to_server, login | ||
import asyncio | ||
|
||
|
||
async def create_workspace_token(args): | ||
# Get a user login token | ||
token = await login({"server_url": args.server_url}) | ||
|
||
# Connect to the Hypha server | ||
server = await connect_to_server( | ||
{ | ||
"server_url": args.server_url, | ||
"token": token, | ||
} | ||
) | ||
|
||
# Check if the workspace already exists | ||
user_workspaces = await server.list_workspaces() | ||
exists = any( | ||
[args.workspace_name == workspace["name"] for workspace in user_workspaces] | ||
) | ||
|
||
# Create a workspace | ||
if not exists or args.overwrite: | ||
workspace = await server.create_workspace( | ||
{ | ||
"name": args.workspace_name, | ||
"description": args.description, | ||
"owners": args.owners, | ||
"allow_list": args.allow_list, | ||
"deny_list": args.deny_list, | ||
"visibility": "public", # public/protected | ||
"persistent": True, # keeps the workspace alive even after a server restart | ||
}, | ||
overwrite=args.overwrite, | ||
) | ||
# Check if the workspace was created | ||
assert any( | ||
[ | ||
args.workspace_name == workspace["name"] | ||
for workspace in await server.list_workspaces() | ||
] | ||
) | ||
print(f"Workspace created: {workspace['name']}") | ||
else: | ||
print(f"Workspace already exists: {args.workspace_name}") | ||
|
||
# Connect to the workspace | ||
server = await connect_to_server( | ||
{ | ||
"server_url": args.server_url, | ||
"token": token, | ||
"workspace": args.workspace_name, | ||
} | ||
) | ||
|
||
# List workspace services | ||
services = await server.list_services() | ||
if len(services) == 0: | ||
print("No services in workspace") | ||
else: | ||
print("Services in workspace:") | ||
for service in services: | ||
print(f"- {service['name']}") | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser( | ||
description="Create the BioImageIO Colab workspace." | ||
) | ||
parser.add_argument( | ||
"--server_url", | ||
default="https://hypha.aicell.io", | ||
type=str, | ||
help="URL of the Hypha server", | ||
) | ||
parser.add_argument( | ||
"--workspace_name", | ||
default="bioimageio-colab", | ||
type=str, | ||
help="Name of the workspace", | ||
) | ||
parser.add_argument( | ||
"--description", | ||
default="The BioImageIO Colab workspace for serving interactive segmentation models.", | ||
type=str, | ||
help="Description of the workspace", | ||
) | ||
parser.add_argument( | ||
"--owners", | ||
nargs="+", | ||
default=[], | ||
type=str, | ||
help="User emails that own the workspace", # user email of workspace creator is added automatically | ||
) | ||
parser.add_argument( | ||
"--allow_list", | ||
nargs="+", | ||
default=[], | ||
type=str, | ||
help="User emails allowed access to the workspace", | ||
) | ||
parser.add_argument( | ||
"--deny_list", | ||
nargs="+", | ||
default=[], | ||
type=str, | ||
help="User emails denied access to the workspace", | ||
) | ||
parser.add_argument( | ||
"--overwrite", | ||
action="store_true", | ||
default=False, | ||
help="Overwrite the workspace if it already exists", | ||
) | ||
|
||
args = parser.parse_args() | ||
asyncio.run(create_workspace_token(args)) |
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.