Skip to content

Commit

Permalink
Add a simple notebook to control dreamer service from jupyter
Browse files Browse the repository at this point in the history
  • Loading branch information
robballantyne committed Aug 20, 2023
1 parent ca6e17d commit 495d0a7
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ WEB_PASSWORD=password
WORKSPACE=/workspace/
CF_TUNNEL_TOKEN=
CF_QUICK_TUNNELS=true
JUPYTER_PORT=8888
JUPYTER_PORT_HOST=8888
JUPYTER_TOKEN=password
JUPYTER_MODE=notebook
SSH_PORT=22
SSH_PORT_HOST=2222
RCLONE_PORT_HOST=53682
9 changes: 9 additions & 0 deletions build/COPY_ROOT/opt/ai-dock/bin/preflight.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

function main() {
move_to_workspace
copy_notebook
update_horde
set_safe_envs
write_config
Expand All @@ -17,6 +18,14 @@ function move_to_workspace() {
fi
}

function copy_notebook() {
if micromamba env list | grep 'jupyter' > /dev/null 2>&1; then
if [[ ! -f "${WORKSPACE}/dreamer.ipynb" ]]; then
cp /usr/local/share/ai-dock/dreamer.ipynb ${WORKSPACE}
fi
fi
}

function update_horde() {
/opt/horde/bin/update-hordelib.sh
/opt/horde/bin/update-horde-worker.sh
Expand Down
81 changes: 81 additions & 0 deletions build/COPY_ROOT/usr/local/share/ai-dock/dreamer.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "9f9fd726-736c-40f9-b4b3-d4439c6fe94f",
"metadata": {},
"outputs": [],
"source": [
"# Stop the dreamer service\n",
"\n",
"!supervisorctl stop dreamer:*"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "715b36cb-ae96-4887-acb9-fd393fa1c2d8",
"metadata": {},
"outputs": [],
"source": [
"# Start the dreamer service\n",
"\n",
"!supervisorctl start dreamer:*"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "df0afee2-8e20-4206-bccf-fecac674f481",
"metadata": {},
"outputs": [],
"source": [
"# View the live logs\n",
"\n",
"!logtail.sh"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9950e252-a1ad-4f7e-baef-0703b1cd3bd6",
"metadata": {},
"outputs": [],
"source": [
"# Get secure web UI link\n",
"\n",
"!grep -b0 -a0 'trycloudflare.com' /var/log/supervisor/quicktunnel-horde-webui.log"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "08cbd5a5-0d3f-44d0-a952-cc0d0dd35a2a",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Horde",
"language": "python",
"name": "horde"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
7 changes: 6 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
args:
IMAGE_BASE: ${IMAGE_BASE}
tags:
- "ghcr.io/ai-dock/horde-dreamer:${IMAGE_TAG}"
- "ghcr.io/ai-dock/ai-horde-dreamer:${IMAGE_TAG}"

image: ghcr.io/ai-dock/ai-horde-dreamer:${IMAGE_TAG}

Expand Down Expand Up @@ -42,6 +42,8 @@ services:
- ${RCLONE_PORT_HOST}:53682
# AI Horde web UI
- ${HORDE_WEBUI_PORT_HOST}:7860
# Jupyter
- ${JUPYTER_PORT_HOST}:${JUPYTER_PORT}

environment:
# AI-Horde-Worker branch or commit hash
Expand All @@ -63,6 +65,9 @@ services:
# Allows running true SSH alongside provider proxy SSH
- SSH_PORT=${SSH_PORT}
- WORKSPACE=${WORKSPACE}
- JUPYTER_PORT=${JUPYTER_PORT}
- JUPYTER_TOKEN=${JUPYTER_TOKEN}
- JUPYTER_MODE=${JUPYTER_MODE}
- CF_TUNNEL_TOKEN=${CF_TUNNEL_TOKEN}
- CF_QUICK_TUNNELS=${CF_QUICK_TUNNELS}
#- PROVISIONING_SCRIPT=https://raw.githubusercontent.com/ai-dock/base-image/main/demo/provisioning.sh

0 comments on commit 495d0a7

Please sign in to comment.