-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlaunch
More file actions
executable file
·117 lines (100 loc) · 4.11 KB
/
launch
File metadata and controls
executable file
·117 lines (100 loc) · 4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
# Praxis Launch Script - Simple wrapper for virtual environment management
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Check if first argument is 'stop' to tear down a running instance
if [ "$1" = "stop" ]; then
echo "[STOP] Stopping Praxis..."
# Detect architecture for compose file selection
ARCH=$(uname -m)
if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
COMPOSE_FILES="-f $SCRIPT_DIR/compose.yml -f $SCRIPT_DIR/compose.ARM.yml"
else
COMPOSE_FILES="-f $SCRIPT_DIR/compose.yml"
fi
# Stop Docker Compose containers
if command -v docker &>/dev/null && [ -f "$SCRIPT_DIR/compose.yml" ]; then
docker compose $COMPOSE_FILES down --remove-orphans
fi
echo "[STOP] Done."
exit 0
fi
# Check if first argument is 'compose' for Docker Compose execution
# We short-circuit, if using Docker, to re-run the script within our container
if [ "$1" = "compose" ]; then
shift # Remove 'compose' from arguments
echo "[DOCKER] Starting Praxis in Docker Compose environment..."
# Detect architecture and set compose file flags
ARCH=$(uname -m)
if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
echo "[DOCKER] Detected ARM64 architecture - using CPU-only configuration"
COMPOSE_FILES="-f $SCRIPT_DIR/compose.yml -f $SCRIPT_DIR/compose.ARM.yml"
else
echo "[DOCKER] Detected x86_64 architecture - using GPU configuration"
COMPOSE_FILES="-f $SCRIPT_DIR/compose.yml"
fi
# Resolve --data-path arguments to absolute host paths and add as volume mounts.
# Inside the container these are mounted at the same absolute path.
# Handles: --data-path p1 p2 --data-path p3 (nargs="+" with action="extend")
EXTRA_VOLUMES=""
RESOLVED_ARGS=()
CONSUMING_DATA_PATHS=false
for arg in "$@"; do
if $CONSUMING_DATA_PATHS; then
# Stop consuming if we hit another flag
if [[ "$arg" == -* ]]; then
CONSUMING_DATA_PATHS=false
if [ "$arg" = "--data-path" ]; then
# Another --data-path flag: keep consuming
CONSUMING_DATA_PATHS=true
RESOLVED_ARGS+=("$arg")
else
RESOLVED_ARGS+=("$arg")
fi
else
# This arg is a data path value — resolve it
abs_path="$(cd "$SCRIPT_DIR" && realpath -m "$arg" 2>/dev/null || echo "$arg")"
EXTRA_VOLUMES="$EXTRA_VOLUMES -v $abs_path:$abs_path:ro"
RESOLVED_ARGS+=("$abs_path")
fi
elif [ "$arg" = "--data-path" ]; then
CONSUMING_DATA_PATHS=true
RESOLVED_ARGS+=("$arg")
else
RESOLVED_ARGS+=("$arg")
fi
done
# Run in Docker Compose with all remaining arguments
# Include port publishing for API server access
docker compose $COMPOSE_FILES run --rm --remove-orphans --service-ports $EXTRA_VOLUMES agent ./launch "${RESOLVED_ARGS[@]}"
exit $?
fi
# Check if we're running inside a Docker container
if [ -f /.dockerenv ] || [ -n "${CONTAINER:-}" ]; then
echo "[DOCKER] Running inside container..."
# Ensure .venv directory exists and is writable
mkdir -p "$SCRIPT_DIR/.venv"
fi
# Ensure we have a functional virtual environment and activate it
if [ ! -f "$SCRIPT_DIR/.venv/bin/activate" ]; then
echo "Creating virtual environment..."
python3 -m venv "$SCRIPT_DIR/.venv"
fi
echo "[SYSTEM] Activated virtual environment."
. "$SCRIPT_DIR/.venv/bin/activate"
# Install praxis package if not already installed
if [ -f "$SCRIPT_DIR/pyproject.toml" ]; then
if ! python -c "import praxis" 2>/dev/null; then
echo "[ENV] Installing Praxis in development mode..."
pip install -e "$SCRIPT_DIR"
echo "[ENV] Praxis installation complete"
else
echo "[ENV] Praxis is installed."
fi
fi
# Pass all arguments directly to main.py
python "$SCRIPT_DIR/main.py" "$@"
EXIT_CODE=$?
# Deactivate the virtual environment and exit with the command's exit code
deactivate
exit $EXIT_CODE