-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
449 additions
and
47 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 |
---|---|---|
|
@@ -53,6 +53,6 @@ ModeMenu Label { | |
.log { | ||
height: 30; | ||
width: 1fr; | ||
padding: 1 1; | ||
padding: 1 2; | ||
background: $panel-darken-3; | ||
} |
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,21 +1,61 @@ | ||
from textual.widgets import RichLog | ||
|
||
|
||
async def install_halfstack(log: RichLog, ha_setup: bool) -> None: | ||
pass | ||
|
||
|
||
async def load_fixtures(log: RichLog) -> None: | ||
pass | ||
|
||
|
||
async def detect_cuda(log: RichLog) -> None: | ||
pass | ||
|
||
|
||
async def populate_bundled_images(log: RichLog) -> None: | ||
from .context import current_os | ||
from .types import OSInfo | ||
|
||
|
||
async def detect_os(): | ||
""" | ||
# Detect distribution | ||
KNOWN_DISTRO="(Debian|Ubuntu|RedHat|CentOS|openSUSE|Amazon|Arista|SUSE)" | ||
DISTRO=$(lsb_release -d 2>/dev/null | grep -Eo $KNOWN_DISTRO || grep -Eo $KNOWN_DISTRO /etc/issue 2>/dev/null || uname -s) | ||
if [ $DISTRO = "Darwin" ]; then | ||
DISTRO="Darwin" | ||
STANDALONE_PYTHON_PLATFORM="apple-darwin" | ||
elif [ -f /etc/debian_version -o "$DISTRO" == "Debian" -o "$DISTRO" == "Ubuntu" ]; then | ||
DISTRO="Debian" | ||
STANDALONE_PYTHON_PLATFORM="unknown-linux-gnu" | ||
elif [ -f /etc/redhat-release -o "$DISTRO" == "RedHat" -o "$DISTRO" == "CentOS" -o "$DISTRO" == "Amazon" ]; then | ||
DISTRO="RedHat" | ||
STANDALONE_PYTHON_PLATFORM="unknown-linux-gnu" | ||
elif [ -f /etc/system-release -o "$DISTRO" == "Amazon" ]; then | ||
DISTRO="RedHat" | ||
STANDALONE_PYTHON_PLATFORM="unknown-linux-gnu" | ||
elif [ -f /usr/lib/os-release -o "$DISTRO" == "SUSE" ]; then | ||
DISTRO="SUSE" | ||
STANDALONE_PYTHON_PLATFORM="unknown-linux-gnu" | ||
else | ||
show_error "Sorry, your host OS distribution is not supported by this script." | ||
show_info "Please send us a pull request or file an issue to support your environment!" | ||
exit 1 | ||
fi | ||
""" | ||
current_os.set( | ||
OSInfo( | ||
platform="", | ||
distro="", | ||
) | ||
) | ||
|
||
|
||
async def detect_cuda() -> None: | ||
pass | ||
|
||
|
||
async def pull_image(log: RichLog) -> None: | ||
pass | ||
async def check_docker_desktop_mount() -> None: | ||
""" | ||
echo "validating Docker Desktop mount permissions..." | ||
docker pull alpine:3.8 > /dev/null | ||
docker run --rm -v "$HOME/.pyenv:/root/vol" alpine:3.8 ls /root/vol > /dev/null 2>&1 | ||
if [ $? -ne 0 ]; then | ||
# backend.ai-krunner-DISTRO pkgs are installed in pyenv's virtualenv, | ||
# so ~/.pyenv must be mountable. | ||
show_error "You must allow mount of '$HOME/.pyenv' in the File Sharing preference of the Docker Desktop app." | ||
exit 1 | ||
fi | ||
docker run --rm -v "$ROOT_PATH:/root/vol" alpine:3.8 ls /root/vol > /dev/null 2>&1 | ||
if [ $? -ne 0 ]; then | ||
show_error "You must allow mount of '$ROOT_PATH' in the File Sharing preference of the Docker Desktop app." | ||
exit 1 | ||
fi | ||
echo "${REWRITELN}validating Docker Desktop mount permissions: ok" | ||
""" |
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,25 +1,145 @@ | ||
from textual.widgets import RichLog | ||
from rich.text import Text | ||
|
||
from .context import current_log | ||
|
||
async def install_git_lfs(log: RichLog) -> None: | ||
pass | ||
|
||
async def install_git_lfs() -> None: | ||
log = current_log.get() | ||
log.write(Text.from_markup("[dim green]Installing Git LFS")) | ||
""" | ||
case $DISTRO in | ||
Debian) | ||
$sudo apt-get install -y git-lfs | ||
;; | ||
RedHat) | ||
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh | $sudo bash | ||
$sudo yum install -y git-lfs | ||
;; | ||
SUSE) | ||
$sudo zypper install -y git-lfs | ||
;; | ||
Darwin) | ||
brew install git-lfs | ||
;; | ||
esac | ||
git lfs install | ||
""" | ||
|
||
async def install_git_hooks(log: RichLog) -> None: | ||
pass | ||
|
||
async def install_git_hooks() -> None: | ||
log = current_log.get() | ||
log.write(Text.from_markup("[dim green]Installing Git hooks")) | ||
""" | ||
local magic_str="monorepo standard pre-commit hook" | ||
if [ -f .git/hooks/pre-commit ]; then | ||
grep -Fq "$magic_str" .git/hooks/pre-commit | ||
if [ $? -eq 0 ]; then | ||
: | ||
else | ||
echo "" >> .git/hooks/pre-commit | ||
cat scripts/pre-commit >> .git/hooks/pre-commit | ||
fi | ||
else | ||
cp scripts/pre-commit .git/hooks/pre-commit | ||
chmod +x .git/hooks/pre-commit | ||
fi | ||
local magic_str="monorepo standard pre-push hook" | ||
if [ -f .git/hooks/pre-push ]; then | ||
grep -Fq "$magic_str" .git/hooks/pre-push | ||
if [ $? -eq 0 ]; then | ||
: | ||
else | ||
echo "" >> .git/hooks/pre-push | ||
cat scripts/pre-push >> .git/hooks/pre-push | ||
fi | ||
else | ||
cp scripts/pre-push .git/hooks/pre-push | ||
chmod +x .git/hooks/pre-push | ||
fi | ||
""" | ||
|
||
async def bootstrap_pants(log: RichLog) -> None: | ||
pass | ||
|
||
async def bootstrap_pants(local_execution_root_dir: str) -> None: | ||
log = current_log.get() | ||
log.write(Text.from_markup("[dim green]Bootstrapping Pantsbuild")) | ||
log.write(f"local_execution_root_dir = {local_execution_root_dir}") | ||
""" | ||
pants_local_exec_root=$($docker_sudo $bpython scripts/check-docker.py --get-preferred-pants-local-exec-root) | ||
mkdir -p "$pants_local_exec_root" | ||
$bpython scripts/tomltool.py -f .pants.rc set 'GLOBAL.local_execution_root_dir' "$pants_local_exec_root" | ||
set +e | ||
if command -v pants &> /dev/null ; then | ||
echo "Pants system command is already installed." | ||
else | ||
case $DISTRO in | ||
Darwin) | ||
brew install pantsbuild/tap/pants | ||
;; | ||
*) | ||
curl --proto '=https' --tlsv1.2 -fsSL https://static.pantsbuild.org/setup/get-pants.sh > /tmp/get-pants.sh | ||
bash /tmp/get-pants.sh | ||
if ! command -v pants &> /dev/null ; then | ||
$sudo ln -s $HOME/bin/pants /usr/local/bin/pants | ||
show_note "Symlinked $HOME/bin/pants from /usr/local/bin/pants as we could not find it from PATH..." | ||
fi | ||
;; | ||
esac | ||
fi | ||
pants version | ||
if [ $? -eq 1 ]; then | ||
# If we can't find the prebuilt Pants package, then try the source installation. | ||
show_error "Cannot proceed the installation because Pants is not available for your platform!" | ||
exit 1 | ||
fi | ||
set -e | ||
""" | ||
|
||
async def install_editable_webui(log: RichLog) -> None: | ||
pass | ||
""" | ||
pants export \ | ||
--resolve=python-default \ | ||
--resolve=python-kernel \ | ||
--resolve=pants-plugins \ | ||
--resolve=towncrier \ | ||
--resolve=ruff \ | ||
--resolve=mypy \ | ||
--resolve=black | ||
""" | ||
|
||
|
||
async def check_docker(log: RichLog) -> None: | ||
pass | ||
|
||
|
||
async def check_docker_compose(log: RichLog) -> None: | ||
pass | ||
async def install_editable_webui() -> None: | ||
log = current_log.get() | ||
log.write(Text.from_markup("[dim green]Installing the editable version of webui")) | ||
""" | ||
if ! command -v node &> /dev/null; then | ||
install_node | ||
fi | ||
show_info "Installing editable version of Web UI..." | ||
if [ -d "./src/ai/backend/webui" ]; then | ||
echo "src/ai/backend/webui already exists, so running 'make clean' on it..." | ||
cd src/ai/backend/webui | ||
make clean | ||
else | ||
git clone https://github.com/lablup/backend.ai-webui ./src/ai/backend/webui | ||
cd src/ai/backend/webui | ||
cp configs/default.toml config.toml | ||
local site_name=$(basename $(pwd)) | ||
# The debug mode here is only for 'hard-core' debugging scenarios -- it changes lots of behaviors. | ||
# (e.g., separate debugging of Electron's renderer and main threads) | ||
sed_inplace "s@debug = true@debug = false@" config.toml | ||
# The webserver endpoint to use in the session mode. | ||
sed_inplace "s@#[[:space:]]*apiEndpoint =.*@apiEndpoint = "'"'"http://127.0.0.1:${WEBSERVER_PORT}"'"@' config.toml | ||
sed_inplace "s@#[[:space:]]*apiEndpointText =.*@apiEndpointText = "'"'"${site_name}"'"@' config.toml | ||
# webServerURL lets the electron app use the web UI contents from the server. | ||
# The server may be either a `npm run server:d` instance or a `./py -m ai.backend.web.server` instance. | ||
# In the former case, you may live-edit the webui sources while running them in the electron app. | ||
sed_inplace "s@webServerURL =.*@webServerURL = "'"'"http://127.0.0.1:${WEBSERVER_PORT}"'"@' config.toml | ||
sed_inplace "s@proxyURL =.*@proxyURL = "'"'"http://127.0.0.1:${WSPROXY_PORT}"'"@' config.toml | ||
echo "PROXYLISTENIP=0.0.0.0" >> .env | ||
echo "PROXYBASEHOST=localhost" >> .env | ||
echo "PROXYBASEPORT=${WSPROXY_PORT}" >> .env | ||
fi | ||
npm i | ||
make compile | ||
make compile_wsproxy | ||
cd ../../../.. | ||
""" |
Oops, something went wrong.