|
5 | 5 | # This is proprietary source code of DataRobot, Inc. and its affiliates. |
6 | 6 | # |
7 | 7 | # Released under the terms of DataRobot Tool and Utility Agreement. |
8 | | -echo "Starting Custom Model environment with DRUM prediction server" |
9 | 8 |
|
10 | | -if [ "${ENABLE_CUSTOM_MODEL_RUNTIME_ENV_DUMP}" = 1 ]; then |
| 9 | +# ============================================================================= |
| 10 | +# Startup script for Custom Model or MCP Server environments |
| 11 | +# Determines which service to run based on directory contents |
| 12 | +# ============================================================================= |
| 13 | + |
| 14 | +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" |
| 15 | + |
| 16 | +# Configure UV package manager |
| 17 | +export UV_PROJECT=${CODE_DIR} |
| 18 | +unset UV_COMPILE_BYTECODE # Disable compilation (already done in build) |
| 19 | +unset UV_CACHE_DIR # Disable caching for reproducibility |
| 20 | + |
| 21 | +# Activate the virtual environment |
| 22 | +. ${VENV_PATH}/bin/activate |
| 23 | + |
| 24 | +# Sync dependencies using UV |
| 25 | +# --active: Install into the active venv instead of creating a new one |
| 26 | +# --frozen: Skip dependency resolution, use exact versions from lock file |
| 27 | +# --extra: Install the 'agentic_playground' optional dependency group |
| 28 | +# Note: Compilation disabled since kernel venv is already compiled |
| 29 | +uv sync --frozen --active --no-progress --color never --extra agentic_playground || true |
| 30 | + |
| 31 | +# Optional: Dump environment variables for debugging |
| 32 | +if [ "${ENABLE_CUSTOM_MODEL_RUNTIME_ENV_DUMP}" = "1" ]; then |
11 | 33 | echo "Environment variables:" |
12 | 34 | env |
13 | 35 | fi |
14 | 36 |
|
15 | | -export UV_PROJECT=${CODE_DIR} |
16 | | -unset UV_COMPILE_BYTECODE |
17 | | -unset UV_CACHE_DIR |
18 | | -source ${VENV_PATH}/bin/activate |
19 | | -# `--active` to install into active kernel venv (instead of creating local from scratch) |
20 | | -# `--frozen` to skip dependency resolution and just install exactly what's in lock file |
21 | | -# Compilation DISABLED - kernel venv has already been compiled, and having compilation enabled |
22 | | -# would re-compile all site-packages (takes quite some time) |
23 | | -time uv sync --frozen --active --no-progress --color never --extra agentic_playground || true |
24 | | - |
25 | | -echo |
26 | | -echo "Executing command: drum server $*" |
27 | | -echo |
28 | | -exec drum server "$@" |
| 37 | +# ----------------------------------------------------------------------------- |
| 38 | +# Option 1: Custom Model with DRUM Server |
| 39 | +# Requires: custom.py file in the same directory |
| 40 | +# ----------------------------------------------------------------------------- |
| 41 | +if [ -f "$SCRIPT_DIR/custom.py" ]; then |
| 42 | + echo "Starting Custom Model environment with DRUM prediction server" |
| 43 | + |
| 44 | + # Start DRUM server |
| 45 | + echo |
| 46 | + echo "Executing command: drum server $*" |
| 47 | + echo |
| 48 | + exec drum server "$@" |
| 49 | + |
| 50 | +# ----------------------------------------------------------------------------- |
| 51 | +# Option 2: MCP Server |
| 52 | +# Requires: app/ directory in the same location |
| 53 | +# ----------------------------------------------------------------------------- |
| 54 | +elif [ -d "$SCRIPT_DIR/app" ]; then |
| 55 | + echo "Starting Custom Model environment with MCP server" |
| 56 | + |
| 57 | + # Set Python path to script directory for module imports |
| 58 | + export PYTHONPATH="$SCRIPT_DIR" |
| 59 | + |
| 60 | + # Start the MCP server |
| 61 | + exec python -m app.main |
| 62 | + |
| 63 | +# ----------------------------------------------------------------------------- |
| 64 | +# Error: No valid entry point found |
| 65 | +# ----------------------------------------------------------------------------- |
| 66 | +else |
| 67 | + echo "Error: Neither custom.py nor app/ directory found in $SCRIPT_DIR" |
| 68 | + echo "This script requires either:" |
| 69 | + echo " - custom.py file for DRUM-based Custom Models" |
| 70 | + echo " - app/ directory for MCP Server applications" |
| 71 | + exit 1 |
| 72 | +fi |
0 commit comments