Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions instill/helpers/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import shutil
import subprocess
import tempfile
import time
import uuid

import ray
Expand All @@ -17,6 +16,12 @@
from instill.helpers.errors import ModelConfigException
from instill.utils.logger import Logger

bash_script = """
until curl -s -o /dev/null -w "%{{http_code}}" http://localhost:8265 | grep -q "200"; do
sleep 5
done
"""


def config_check_required_fields(c):
if "build" not in c or c["build"] is None:
Expand Down Expand Up @@ -276,7 +281,6 @@ def run(args):
docker_run = False
try:
name = uuid.uuid4()

Logger.i("[Instill] Starting model image...")
if not args.gpu:
subprocess.run(
Expand Down Expand Up @@ -307,7 +311,14 @@ def run(args):
stdout=subprocess.DEVNULL,
)
docker_run = True
time.sleep(10)
subprocess.run(
f"docker exec {str(name)} /bin/bash -c '{bash_script}'",
shell=True,
check=True,
stdout=subprocess.DEVNULL,
timeout=300,
)

Logger.i("[Instill] Deploying model...")
subprocess.run(
[
Expand Down Expand Up @@ -336,6 +347,8 @@ def run(args):
)
except subprocess.CalledProcessError:
Logger.e("[Instill] Run failed")
except subprocess.TimeoutExpired:
Logger.e("[Instill] Deployment timeout")
except Exception as e:
Logger.e("[Instill] Prepare failed")
Logger.e(e)
Expand Down