Skip to content

Commit

Permalink
docs(container): enable ray dashboard & state APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
tonywu6 committed Sep 1, 2023
1 parent 360b37a commit ff76ca9
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 12 deletions.
4 changes: 4 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ services:
ports:
# Jupyter
- 8090:8888
# Ray Dashboard
- 8091:8265
command: /home/vscode/scripts/start.sh
volumes:
- type: bind
Expand All @@ -40,6 +42,8 @@ services:
ports:
# Jupyter
- 8092:8888
# Ray Dashboard
- 8093:8265
command: /home/vscode/scripts/start.sh
volumes:
- type: bind
Expand Down
3 changes: 2 additions & 1 deletion .devcontainer/standalone/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ RUN useradd --create-home --home-dir /home/${DEFAULT_USER} \
-u 1001 \
${DEFAULT_USER}

USER ${DEFAULT_USER}
WORKDIR /home/${DEFAULT_USER}

COPY ${BUILD_CWD}/requirements.txt .
Expand All @@ -28,5 +27,7 @@ EXPOSE 8888
# Ray Dashboard
EXPOSE 8265

USER ${DEFAULT_USER}

# Copy content from .devcontainer/standalone/home into /home/vscode
COPY --chown=vscode:vscode ${BUILD_CWD}/home ./
95 changes: 84 additions & 11 deletions .devcontainer/standalone/home/examples/dot.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,48 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "28e20ec8-b632-4479-8008-2a1cf338bb27",
"metadata": {},
"outputs": [],
"source": [
"import types\n",
"\n",
"from packaging.version import Version\n",
"from packaging.specifiers import SpecifierSet\n",
"\n",
"def assert_version_guarantee(module: types.ModuleType, current: str, expected: str):\n",
" current_version = Version(current)\n",
" acceptable_versions = SpecifierSet(expected)\n",
"\n",
" if current_version.is_prerelease:\n",
" satisfied = acceptable_versions.contains(current_version, prereleases=True)\n",
" else:\n",
" satisfied = current_version in acceptable_versions\n",
"\n",
" assert satisfied, (\n",
" f\"This program requires {module.__name__} {expected},\"\n",
" f\" but you have {current}\"\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4e85225e-0401-4c6b-9011-7fac54d7ab06",
"metadata": {},
"outputs": [],
"source": [
"import ray\n",
"import pydantic\n",
"import secretflow as sf\n",
"\n",
"assert_version_guarantee(ray, ray.__version__, '~=2.2.0')\n",
"assert_version_guarantee(pydantic, pydantic.__version__, '>=1.10, <2')\n",
"assert_version_guarantee(sf, sf.__version__, '~=1.0')"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -60,16 +103,6 @@
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2ca5f0db-763e-4d66-8e05-62475b4e78a0",
"metadata": {},
"outputs": [],
"source": [
"import secretflow as sf"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -95,6 +128,36 @@
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9c4f7d3a-5e25-401e-9f74-e92b37287bca",
"metadata": {},
"outputs": [],
"source": [
"import ray.experimental.state.api as state_api"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "72519370-a845-47a7-b225-cdba213be93b",
"metadata": {},
"outputs": [],
"source": [
"state_api.summarize_actors()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "53eb723d-c171-4506-b4c0-1d942222137f",
"metadata": {},
"outputs": [],
"source": [
"state_api.list_objects()"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -191,6 +254,16 @@
"source": [
"sf.reveal(result)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "206ab0b5-45df-45ff-b86e-5ee38f87c862",
"metadata": {},
"outputs": [],
"source": [
"state_api.list_objects()"
]
}
],
"metadata": {
Expand All @@ -209,7 +282,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.17"
"version": "3.8.15"
}
},
"nbformat": 4,
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/standalone/home/scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ source ~/.bashrc
ray start \
--head \
--port=6379 \
--include-dashboard=True \
--dashboard-host "0.0.0.0" \
--resources="{\"$SELF_PARTY\": 4}"

Expand Down
3 changes: 3 additions & 0 deletions .devcontainer/standalone/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
jupyterlab==4.0.3
ray[default]==2.2.0
pydantic==1.10.12
packaging==23.1

0 comments on commit ff76ca9

Please sign in to comment.