Christopher Tan commited on
Commit
37e001d
·
1 Parent(s): 48941d1

Refactoring environment installs and removing debugging code

Browse files
Files changed (3) hide show
  1. app.py +34 -55
  2. install_roboeval_runtime.sh +163 -176
  3. run.sh +10 -4
app.py CHANGED
@@ -15,43 +15,19 @@ import subprocess
15
  import sys
16
  import datetime
17
 
18
- # Verify base dependencies are available
19
- print("===== Checking Base Environment Dependencies =====", flush=True)
20
 
21
- try:
22
- import gradio as gr
23
- print(f"✓ gradio imported successfully (version: {gr.__version__})", flush=True)
24
- except ImportError as e:
25
- print(f"✗ gradio import failed: {e}", flush=True)
26
- print("ERROR: Gradio is required but not installed. Please install it:", flush=True)
27
- print(" pip install gradio>=4.0.0", flush=True)
28
- sys.exit(1)
29
 
30
- try:
31
- import numpy
32
- print(f"✓ numpy imported successfully (version: {numpy.__version__})", flush=True)
33
- except ImportError as e:
34
- print(f"✗ numpy import failed: {e}", flush=True)
35
- print("ERROR: NumPy is required but not installed.", flush=True)
36
- sys.exit(1)
37
-
38
- try:
39
- from PIL import Image
40
- print("✓ pillow imported successfully", flush=True)
41
- except ImportError as e:
42
- print(f"✗ pillow import failed: {e}", flush=True)
43
- print("ERROR: Pillow is required but not installed.", flush=True)
44
- sys.exit(1)
45
-
46
- try:
47
- import huggingface_hub
48
- print(f"✓ huggingface_hub imported successfully (version: {huggingface_hub.__version__})", flush=True)
49
- except ImportError as e:
50
- print(f"✗ huggingface_hub import failed: {e}", flush=True)
51
- print("ERROR: huggingface_hub is required but not installed.", flush=True)
52
- sys.exit(1)
53
-
54
- print("===== All base dependencies verified successfully =====\n", flush=True)
55
 
56
  # --- Headless defaults ---
57
  os.environ.setdefault("MUJOCO_GL", "egl")
@@ -61,17 +37,18 @@ os.environ.setdefault("XDG_RUNTIME_DIR", "/tmp")
61
  # Note: Model dependencies are installed in separate conda environments
62
  # RoboEval and git packages are installed at runtime using GH_TOKEN environment variable
63
 
64
- print(f"===== Application Startup at {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')} =====\n")
65
 
66
  # Check and install RoboEval if needed (runtime installation)
67
  def check_and_install_roboeval():
68
  """Check if RoboEval is installed, install if missing"""
69
  try:
70
  import roboeval
71
- print("✓ RoboEval is already installed", flush=True)
72
  return True
73
  except ImportError:
74
- print("⚠️ RoboEval not found. Checking if installation is needed...", flush=True)
 
75
  # RoboEval installation is handled by run.sh before app.py starts
76
  # If we get here, it means installation failed or is in progress
77
  return False
@@ -95,12 +72,12 @@ def verify_environments():
95
  import shutil
96
  conda_path = shutil.which("conda")
97
  if not conda_path:
98
- print("⚠️ Warning: conda not found in PATH. Skipping environment verification.")
99
- print(" Assuming environments will be available when needed.")
100
  return True, False # Assume OpenPI exists, OpenVLA disabled
101
  except (FileNotFoundError, subprocess.TimeoutExpired):
102
- print("⚠️ Warning: Could not check for conda. Skipping environment verification.")
103
- print(" Assuming environments will be available when needed.")
104
  return True, False # Assume OpenPI exists, OpenVLA disabled
105
 
106
  # If conda is available, check environments
@@ -113,29 +90,30 @@ def verify_environments():
113
  )
114
 
115
  if result.returncode != 0:
116
- print(f"⚠️ Warning: conda env list failed: {result.stderr}")
117
- print(" Assuming environments will be available when needed.")
118
  return True, False
119
 
120
  has_openpi = "openpi_env" in result.stdout
121
  has_openvla = "openvla_env" in result.stdout
122
 
123
- print("Environment check:")
124
- print(f" {'✓' if has_openpi else '✗'} openpi_env")
125
- print(f" {'✓' if has_openvla else '✗'} openvla_env (optional)")
 
126
 
127
- if not has_openpi:
128
  print("⚠️ Warning: openpi_env not found in conda env list.")
129
  print(" Will attempt to use it anyway - check will happen when worker starts.")
130
 
131
  return has_openpi, has_openvla
132
 
133
  except subprocess.TimeoutExpired:
134
- print("⚠️ Warning: conda env list timed out. Skipping verification.")
135
  return True, False
136
  except Exception as e:
137
- print(f"⚠️ Warning: Error checking conda environments: {e}")
138
- print(" Assuming environments will be available when needed.")
139
  return True, False
140
 
141
  HAS_OPENPI, HAS_OPENVLA = verify_environments()
@@ -208,10 +186,10 @@ def _stderr_reader(proc: subprocess.Popen, model_key: str):
208
  # EOF - process likely exited
209
  break
210
  _WORKER_STDERR[model_key].append(line)
211
- # Also print to console for debugging
212
- print(f"[{model_key} worker stderr] {line}", end="", flush=True)
213
  except Exception as e:
214
- # Log any errors in the stderr reader itself
215
  print(f"[{model_key} stderr reader error] {e}", flush=True)
216
  finally:
217
  # Try to read any remaining buffered output
@@ -219,7 +197,8 @@ def _stderr_reader(proc: subprocess.Popen, model_key: str):
219
  remaining = proc.stderr.read()
220
  if remaining:
221
  _WORKER_STDERR[model_key].append(remaining)
222
- print(f"[{model_key} worker stderr (remaining)] {remaining}", flush=True)
 
223
  except:
224
  pass
225
 
 
15
  import sys
16
  import datetime
17
 
18
+ # Verbose mode: set ROBOEVAL_VERBOSE=1 to see detailed output
19
+ ROBOEVAL_VERBOSE = os.environ.get("ROBOEVAL_VERBOSE", "0") == "1"
20
 
21
+ def log_verbose(*args, **kwargs):
22
+ """Print only if verbose mode is enabled"""
23
+ if ROBOEVAL_VERBOSE:
24
+ print(*args, **kwargs)
 
 
 
 
25
 
26
+ # Import base dependencies
27
+ import gradio as gr
28
+ import numpy
29
+ from PIL import Image
30
+ import huggingface_hub
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
  # --- Headless defaults ---
33
  os.environ.setdefault("MUJOCO_GL", "egl")
 
37
  # Note: Model dependencies are installed in separate conda environments
38
  # RoboEval and git packages are installed at runtime using GH_TOKEN environment variable
39
 
40
+ log_verbose(f"===== Application Startup at {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')} =====\n")
41
 
42
  # Check and install RoboEval if needed (runtime installation)
43
  def check_and_install_roboeval():
44
  """Check if RoboEval is installed, install if missing"""
45
  try:
46
  import roboeval
47
+ log_verbose("✓ RoboEval is already installed", flush=True)
48
  return True
49
  except ImportError:
50
+ if ROBOEVAL_VERBOSE:
51
+ print("⚠️ RoboEval not found. Checking if installation is needed...", flush=True)
52
  # RoboEval installation is handled by run.sh before app.py starts
53
  # If we get here, it means installation failed or is in progress
54
  return False
 
72
  import shutil
73
  conda_path = shutil.which("conda")
74
  if not conda_path:
75
+ log_verbose("⚠️ Warning: conda not found in PATH. Skipping environment verification.")
76
+ log_verbose(" Assuming environments will be available when needed.")
77
  return True, False # Assume OpenPI exists, OpenVLA disabled
78
  except (FileNotFoundError, subprocess.TimeoutExpired):
79
+ log_verbose("⚠️ Warning: Could not check for conda. Skipping environment verification.")
80
+ log_verbose(" Assuming environments will be available when needed.")
81
  return True, False # Assume OpenPI exists, OpenVLA disabled
82
 
83
  # If conda is available, check environments
 
90
  )
91
 
92
  if result.returncode != 0:
93
+ log_verbose(f"⚠️ Warning: conda env list failed: {result.stderr}")
94
+ log_verbose(" Assuming environments will be available when needed.")
95
  return True, False
96
 
97
  has_openpi = "openpi_env" in result.stdout
98
  has_openvla = "openvla_env" in result.stdout
99
 
100
+ if ROBOEVAL_VERBOSE:
101
+ print("Environment check:")
102
+ print(f" {'✓' if has_openpi else '✗'} openpi_env")
103
+ print(f" {'✓' if has_openvla else '✗'} openvla_env (optional)")
104
 
105
+ if not has_openpi and ROBOEVAL_VERBOSE:
106
  print("⚠️ Warning: openpi_env not found in conda env list.")
107
  print(" Will attempt to use it anyway - check will happen when worker starts.")
108
 
109
  return has_openpi, has_openvla
110
 
111
  except subprocess.TimeoutExpired:
112
+ log_verbose("⚠️ Warning: conda env list timed out. Skipping verification.")
113
  return True, False
114
  except Exception as e:
115
+ log_verbose(f"⚠️ Warning: Error checking conda environments: {e}")
116
+ log_verbose(" Assuming environments will be available when needed.")
117
  return True, False
118
 
119
  HAS_OPENPI, HAS_OPENVLA = verify_environments()
 
186
  # EOF - process likely exited
187
  break
188
  _WORKER_STDERR[model_key].append(line)
189
+ # Only print to console in verbose mode
190
+ log_verbose(f"[{model_key} worker stderr] {line}", end="", flush=True)
191
  except Exception as e:
192
+ # Always log errors in the stderr reader itself
193
  print(f"[{model_key} stderr reader error] {e}", flush=True)
194
  finally:
195
  # Try to read any remaining buffered output
 
197
  remaining = proc.stderr.read()
198
  if remaining:
199
  _WORKER_STDERR[model_key].append(remaining)
200
+ # Only print remaining output in verbose mode
201
+ log_verbose(f"[{model_key} worker stderr (remaining)] {remaining}", flush=True)
202
  except:
203
  pass
204
 
install_roboeval_runtime.sh CHANGED
@@ -4,7 +4,17 @@
4
 
5
  set -e
6
 
7
- echo "===== Installing RoboEval at Runtime ====="
 
 
 
 
 
 
 
 
 
 
8
 
9
  # Source conda if available
10
  if [ -f "/opt/conda/etc/profile.d/conda.sh" ]; then
@@ -13,7 +23,7 @@ fi
13
 
14
  # Check if RoboEval is already installed
15
  if python -c "import roboeval" 2>/dev/null; then
16
- echo "✓ RoboEval is already installed, skipping installation"
17
  exit 0
18
  fi
19
 
@@ -29,212 +39,189 @@ CLONE_DIR="/tmp/roboeval_install"
29
  rm -rf $CLONE_DIR
30
 
31
  # Clone with submodules
32
- echo "Cloning RoboEval repository with submodules..."
33
  git clone --recurse-submodules https://${GH_TOKEN}@github.com/helen9975/RoboEval.git $CLONE_DIR
34
 
35
- # Set environment variables for building
36
- export PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1
37
- export USE_BAZEL_VERSION=7.5.0
38
-
39
- # Check if Bazel is available (should be in /usr/local/bin if installed in Dockerfile)
40
- if ! command -v bazel &> /dev/null; then
41
- if [ -f "/usr/local/bin/bazel" ]; then
42
- export PATH="/usr/local/bin:${PATH}"
43
- else
44
- echo "⚠️ Warning: Bazel not found. RoboEval installation may fail."
45
- fi
46
- fi
47
-
48
- # Check if Rust is available (should be in /root/.cargo if installed in Dockerfile)
49
- # Rust is installed in /root/.cargo but script may run as non-root user
50
- # Add to PATH directly if the bin directory exists and is readable
51
- if [ -d "/root/.cargo/bin" ] && [ -x "/root/.cargo/bin/cargo" ]; then
52
- export PATH="/root/.cargo/bin:${PATH}"
53
- echo "✓ Added /root/.cargo/bin to PATH"
54
- elif [ -f "/root/.cargo/env" ]; then
55
- # Try to source if we have permission
56
- source /root/.cargo/env 2>/dev/null || export PATH="/root/.cargo/bin:${PATH}"
57
- echo "✓ Sourced Rust environment from /root/.cargo/env"
58
- elif [ -f "${HOME}/.cargo/env" ]; then
59
- source ${HOME}/.cargo/env
60
- export PATH="${HOME}/.cargo/bin:${PATH}"
61
- echo "✓ Sourced Rust environment from ${HOME}/.cargo/env"
62
- fi
63
-
64
- # Verify Rust is available
65
- if command -v cargo &> /dev/null; then
66
- echo "✓ Rust/Cargo found: $(which cargo)"
67
- cargo --version || true
68
- else
69
- echo "⚠️ Warning: Rust/Cargo not found. RoboEval installation may fail."
70
- echo " Checked paths: /root/.cargo/bin, /root/.cargo/env, ${HOME}/.cargo/env"
71
- echo " PATH: ${PATH}"
72
- fi
73
-
74
- # Install RoboEval
75
- echo "Installing RoboEval from cloned repository..."
76
- echo "Note: This may take several minutes as it builds labmaze with bazel..."
77
-
78
- pip install $CLONE_DIR --no-cache-dir || {
79
- echo "⚠️ RoboEval installation had some errors, but continuing..."
80
- echo "Trying to install pre-built safetensors wheel..."
81
- pip install safetensors --only-binary :all: || pip install "safetensors>=0.4.1" --no-build-isolation || true
82
- }
83
-
84
- # Get site-packages location
85
- SITE_PACKAGES=$(python -c "import site; print(site.getsitepackages()[0])")
86
-
87
- # Copy thirdparty directory
88
- cp -r $CLONE_DIR/thirdparty $SITE_PACKAGES/ || true
89
-
90
- echo "✓ RoboEval installed in base environment"
91
-
92
- # Install git-based packages in openpi_env if it exists
93
- if conda env list | grep -q "openpi_env"; then
94
- echo "Installing git-based packages in openpi_env..."
95
- conda run -n openpi_env pip install --no-cache-dir \
96
- git+https://github.com/huggingface/lerobot@0cf864870cf29f4738d3ade893e6fd13fbd7cdb5 \
97
- git+https://${GH_TOKEN}@github.com/tan7271/OpenPiRoboEval.git#subdirectory=packages/openpi-client --no-deps \
98
- git+https://${GH_TOKEN}@github.com/tan7271/OpenPiRoboEval.git --no-deps --force-reinstall || {
99
- echo "⚠️ Warning: Failed to install git packages in openpi_env"
100
- }
101
-
102
- # Install missing pip-only dependencies that may not be in the environment file yet
103
- # Note: torchvision and torchaudio should be installed via conda, not pip
104
- echo "Installing additional OpenPI dependencies in openpi_env..."
105
- conda run -n openpi_env pip install --no-cache-dir \
106
- draccus>=0.1.0 \
107
- jsonlines>=4.0.0 || {
108
- echo "⚠️ Warning: Failed to install some additional dependencies in openpi_env"
109
- }
110
-
111
- # Install RoboEval directly into openpi_env (handles permissions and dependencies automatically)
112
- echo "Installing RoboEval into openpi_env..."
113
  # Set environment variables for building
114
  export PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1
115
  export USE_BAZEL_VERSION=7.5.0
116
 
117
- # Ensure Bazel is in PATH
118
- if [ -f "/usr/local/bin/bazel" ]; then
119
- export PATH="/usr/local/bin:${PATH}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  fi
 
 
 
 
 
 
121
 
122
- # Source cargo env if it exists
123
- if [ -f "/root/.cargo/env" ]; then
124
- source /root/.cargo/env
125
  fi
126
 
127
- # Install RoboEval into openpi_env
128
- # Pass CLONE_DIR as an environment variable to the subshell
129
- CLONE_DIR_ESC=$(echo "$CLONE_DIR" | sed 's/"/\\"/g')
130
- conda run -n openpi_env bash -c "
131
- export PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1;
132
- export USE_BAZEL_VERSION=7.5.0;
133
- export PATH=\"/usr/local/bin:\$PATH\";
134
- if [ -f \"/root/.cargo/env\" ]; then source /root/.cargo/env; fi;
135
- pip install \"${CLONE_DIR_ESC}\" --no-cache-dir || {
136
- echo '⚠️ RoboEval installation had some errors, but continuing...';
137
- pip install safetensors --only-binary :all: || pip install 'safetensors>=0.4.1' --no-build-isolation || true;
 
 
 
 
 
 
 
 
 
 
138
  }
139
- " || {
140
- echo "⚠️ Warning: RoboEval installation into openpi_env had errors"
141
- }
 
 
 
 
 
142
 
143
- # Also copy thirdparty to user's local site-packages (Python might check there too)
144
- echo "Copying thirdparty to user's local site-packages..."
145
- USER_SITE_PACKAGES="/home/user/.local/lib/python3.12/site-packages"
146
- mkdir -p "$USER_SITE_PACKAGES" 2>/dev/null || true
147
 
148
  # Find thirdparty source
149
- THIRDPARTY_SOURCE=""
150
- if [ -d "${SITE_PACKAGES}/thirdparty" ]; then
151
- THIRDPARTY_SOURCE="${SITE_PACKAGES}/thirdparty"
152
- elif [ -d "$CLONE_DIR/thirdparty" ]; then
153
- THIRDPARTY_SOURCE="$CLONE_DIR/thirdparty"
154
  fi
155
 
156
- if [ -n "$THIRDPARTY_SOURCE" ] && [ -d "$THIRDPARTY_SOURCE" ]; then
157
- # Copy to user's local site-packages (user has write access here)
158
- cp -r "$THIRDPARTY_SOURCE" "$USER_SITE_PACKAGES/" 2>/dev/null || {
159
- echo "⚠️ Warning: Failed to copy thirdparty to user site-packages"
160
  }
161
 
162
  # Verify
163
- if [ -d "$USER_SITE_PACKAGES/thirdparty" ]; then
164
- echo "✓ thirdparty copied to user site-packages: $USER_SITE_PACKAGES"
165
  fi
166
  fi
167
-
168
- echo "✓ RoboEval installed in openpi_env"
169
- fi
170
 
171
- # Install git-based packages in openvla_env if it exists
172
- if conda env list | grep -q "openvla_env"; then
173
- echo "Installing git-based packages in openvla_env..."
174
- conda run -n openvla_env pip install --no-cache-dir \
175
- git+https://github.com/openvla/openvla.git || {
176
- echo "⚠️ Warning: Failed to install OpenVLA in openvla_env"
177
- }
178
 
179
- # Install RoboEval directly into openvla_env (handles permissions and dependencies automatically)
180
- echo "Installing RoboEval into openvla_env..."
181
- # Set environment variables for building
182
- export PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1
183
- export USE_BAZEL_VERSION=7.5.0
184
-
185
- # Ensure Bazel is in PATH
186
- if [ -f "/usr/local/bin/bazel" ]; then
187
- export PATH="/usr/local/bin:${PATH}"
188
  fi
189
 
190
- # Source cargo env if it exists
191
- if [ -f "/root/.cargo/env" ]; then
192
- source /root/.cargo/env
193
- fi
194
 
195
- # Install RoboEval into openvla_env
196
- # Pass CLONE_DIR as an environment variable to the subshell
197
- CLONE_DIR_ESC=$(echo "$CLONE_DIR" | sed 's/"/\\"/g')
198
- conda run -n openvla_env bash -c "
199
- export PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1;
200
- export USE_BAZEL_VERSION=7.5.0;
201
- export PATH=\"/usr/local/bin:\$PATH\";
202
- if [ -f \"/root/.cargo/env\" ]; then source /root/.cargo/env; fi;
203
- pip install \"${CLONE_DIR_ESC}\" --no-cache-dir || {
204
- echo '⚠️ RoboEval installation had some errors, but continuing...';
205
- pip install safetensors --only-binary :all: || pip install 'safetensors>=0.4.1' --no-build-isolation || true;
206
- }
207
- " || {
208
- echo "⚠️ Warning: RoboEval installation into openvla_env had errors"
209
- }
210
 
211
- # Also copy thirdparty to user's local site-packages (Python 3.10 for OpenVLA)
212
- echo "Copying thirdparty to user's local site-packages for OpenVLA..."
213
- USER_SITE_PACKAGES="/home/user/.local/lib/python3.10/site-packages"
214
- mkdir -p "$USER_SITE_PACKAGES" 2>/dev/null || true
215
 
216
- # Find thirdparty source
217
- THIRDPARTY_SOURCE=""
218
- if [ -d "${SITE_PACKAGES}/thirdparty" ]; then
219
- THIRDPARTY_SOURCE="${SITE_PACKAGES}/thirdparty"
220
- elif [ -d "$CLONE_DIR/thirdparty" ]; then
221
- THIRDPARTY_SOURCE="$CLONE_DIR/thirdparty"
222
- fi
223
 
224
- if [ -n "$THIRDPARTY_SOURCE" ] && [ -d "$THIRDPARTY_SOURCE" ]; then
225
- # Copy to user's local site-packages (user has write access here)
226
- cp -r "$THIRDPARTY_SOURCE" "$USER_SITE_PACKAGES/" 2>/dev/null || {
227
- echo "⚠️ Warning: Failed to copy thirdparty to user site-packages for OpenVLA"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  }
229
 
230
- # Verify
231
- if [ -d "$USER_SITE_PACKAGES/thirdparty" ]; then
232
- echo "✓ thirdparty copied to user site-packages: $USER_SITE_PACKAGES"
233
- fi
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  fi
235
-
236
- echo "✓ RoboEval installed in openvla_env"
237
  fi
238
 
239
- echo "✓ RoboEval installation complete"
 
240
 
 
 
4
 
5
  set -e
6
 
7
+ # Verbose mode: set ROBOEVAL_VERBOSE=1 to see detailed output
8
+ VERBOSE=${ROBOEVAL_VERBOSE:-0}
9
+ log_verbose() {
10
+ if [ "$VERBOSE" = "1" ]; then
11
+ echo "$@"
12
+ fi
13
+ }
14
+
15
+ if [ "$VERBOSE" = "1" ]; then
16
+ echo "===== Installing RoboEval at Runtime ====="
17
+ fi
18
 
19
  # Source conda if available
20
  if [ -f "/opt/conda/etc/profile.d/conda.sh" ]; then
 
23
 
24
  # Check if RoboEval is already installed
25
  if python -c "import roboeval" 2>/dev/null; then
26
+ log_verbose "✓ RoboEval is already installed, skipping installation"
27
  exit 0
28
  fi
29
 
 
39
  rm -rf $CLONE_DIR
40
 
41
  # Clone with submodules
42
+ log_verbose "Cloning RoboEval repository with submodules..."
43
  git clone --recurse-submodules https://${GH_TOKEN}@github.com/helen9975/RoboEval.git $CLONE_DIR
44
 
45
+ # Helper function: Ensure build tools (Bazel and Rust) are in PATH
46
+ ensure_build_tools() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  # Set environment variables for building
48
  export PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1
49
  export USE_BAZEL_VERSION=7.5.0
50
 
51
+ # Check if Bazel is available
52
+ if ! command -v bazel &> /dev/null; then
53
+ if [ -f "/usr/local/bin/bazel" ]; then
54
+ export PATH="/usr/local/bin:${PATH}"
55
+ else
56
+ log_verbose "⚠️ Warning: Bazel not found. RoboEval installation may fail."
57
+ fi
58
+ fi
59
+
60
+ # Check if Rust is available
61
+ if [ -d "/root/.cargo/bin" ] && [ -x "/root/.cargo/bin/cargo" ]; then
62
+ export PATH="/root/.cargo/bin:${PATH}"
63
+ log_verbose "✓ Added /root/.cargo/bin to PATH"
64
+ elif [ -f "/root/.cargo/env" ]; then
65
+ source /root/.cargo/env 2>/dev/null || export PATH="/root/.cargo/bin:${PATH}"
66
+ log_verbose "✓ Sourced Rust environment from /root/.cargo/env"
67
+ elif [ -f "${HOME}/.cargo/env" ]; then
68
+ source ${HOME}/.cargo/env
69
+ export PATH="${HOME}/.cargo/bin:${PATH}"
70
+ log_verbose "✓ Sourced Rust environment from ${HOME}/.cargo/env"
71
+ fi
72
+
73
+ # Verify Rust is available
74
+ if command -v cargo &> /dev/null; then
75
+ log_verbose "✓ Rust/Cargo found: $(which cargo)"
76
+ log_verbose "$(cargo --version || true)"
77
+ else
78
+ log_verbose "⚠️ Warning: Rust/Cargo not found. RoboEval installation may fail."
79
+ log_verbose " Checked paths: /root/.cargo/bin, /root/.cargo/env, ${HOME}/.cargo/env"
80
+ log_verbose " PATH: ${PATH}"
81
  fi
82
+ }
83
+
84
+ # Helper function: Install RoboEval from cloned directory
85
+ install_roboeval_from_clone() {
86
+ local env_name=$1
87
+ local clone_dir=$2
88
 
89
+ log_verbose "Installing RoboEval from cloned repository..."
90
+ if [ "$VERBOSE" = "1" ]; then
91
+ echo "Note: This may take several minutes as it builds labmaze with bazel..."
92
  fi
93
 
94
+ if [ -z "$env_name" ] || [ "$env_name" = "base" ]; then
95
+ # Install in base environment
96
+ pip install "$clone_dir" --no-cache-dir || {
97
+ log_verbose "⚠️ RoboEval installation had some errors, but continuing..."
98
+ log_verbose "Trying to install pre-built safetensors wheel..."
99
+ pip install safetensors --only-binary :all: || pip install "safetensors>=0.4.1" --no-build-isolation || true
100
+ }
101
+ else
102
+ # Install in specified conda environment
103
+ local clone_dir_esc=$(echo "$clone_dir" | sed 's/"/\\"/g')
104
+ conda run -n "$env_name" bash -c "
105
+ export PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1;
106
+ export USE_BAZEL_VERSION=7.5.0;
107
+ export PATH=\"/usr/local/bin:\$PATH\";
108
+ if [ -f \"/root/.cargo/env\" ]; then source /root/.cargo/env; fi;
109
+ pip install \"${clone_dir_esc}\" --no-cache-dir || {
110
+ echo '⚠️ RoboEval installation had some errors, but continuing...';
111
+ pip install safetensors --only-binary :all: || pip install 'safetensors>=0.4.1' --no-build-isolation || true;
112
+ }
113
+ " || {
114
+ log_verbose "⚠️ Warning: RoboEval installation into $env_name had errors"
115
  }
116
+ fi
117
+ }
118
+
119
+ # Helper function: Copy thirdparty to user site-packages
120
+ copy_thirdparty_to_user_site() {
121
+ local py_minor=$1 # e.g., "3.12" or "3.10"
122
+ local site_packages=$2
123
+ local clone_dir=$3
124
 
125
+ log_verbose "Copying thirdparty to user's local site-packages..."
126
+ local user_site_packages="/home/user/.local/lib/python${py_minor}/site-packages"
127
+ mkdir -p "$user_site_packages" 2>/dev/null || true
 
128
 
129
  # Find thirdparty source
130
+ local thirdparty_source=""
131
+ if [ -d "${site_packages}/thirdparty" ]; then
132
+ thirdparty_source="${site_packages}/thirdparty"
133
+ elif [ -d "$clone_dir/thirdparty" ]; then
134
+ thirdparty_source="$clone_dir/thirdparty"
135
  fi
136
 
137
+ if [ -n "$thirdparty_source" ] && [ -d "$thirdparty_source" ]; then
138
+ cp -r "$thirdparty_source" "$user_site_packages/" 2>/dev/null || {
139
+ log_verbose "⚠️ Warning: Failed to copy thirdparty to user site-packages"
 
140
  }
141
 
142
  # Verify
143
+ if [ -d "$user_site_packages/thirdparty" ]; then
144
+ log_verbose "✓ thirdparty copied to user site-packages: $user_site_packages"
145
  fi
146
  fi
147
+ }
 
 
148
 
149
+ # Helper function: Install RoboEval into a conda environment
150
+ install_roboeval_into_env() {
151
+ local env_name=$1
152
+ local py_minor=$2 # Python minor version (e.g., "3.12" or "3.10")
 
 
 
153
 
154
+ if ! conda env list | grep -q "$env_name"; then
155
+ return 0 # Environment doesn't exist, skip
 
 
 
 
 
 
 
156
  fi
157
 
158
+ log_verbose "Installing RoboEval into $env_name..."
 
 
 
159
 
160
+ # Ensure build tools are set up
161
+ ensure_build_tools
 
 
 
 
 
 
 
 
 
 
 
 
 
162
 
163
+ # Install RoboEval
164
+ install_roboeval_from_clone "$env_name" "$CLONE_DIR"
 
 
165
 
166
+ # Get site-packages location for base env (for thirdparty source)
167
+ local base_site_packages=$(python -c "import site; print(site.getsitepackages()[0])" 2>/dev/null || echo "")
168
+
169
+ # Copy thirdparty to user site-packages
170
+ copy_thirdparty_to_user_site "$py_minor" "$base_site_packages" "$CLONE_DIR"
 
 
171
 
172
+ log_verbose " RoboEval installed in $env_name"
173
+ }
174
+
175
+ # Ensure build tools are available
176
+ ensure_build_tools
177
+
178
+ # Install RoboEval in base environment
179
+ install_roboeval_from_clone "base" "$CLONE_DIR"
180
+
181
+ # Get site-packages location
182
+ SITE_PACKAGES=$(python -c "import site; print(site.getsitepackages()[0])")
183
+
184
+ # Copy thirdparty directory to base environment
185
+ cp -r $CLONE_DIR/thirdparty $SITE_PACKAGES/ || true
186
+
187
+ log_verbose "✓ RoboEval installed in base environment"
188
+
189
+ # Install git-based packages and RoboEval in openpi_env if it exists
190
+ # Gate behind INSTALL_GIT_DEPS flag (default: install if not set, but can be disabled)
191
+ if [ "${INSTALL_GIT_DEPS:-1}" = "1" ]; then
192
+ if conda env list | grep -q "openpi_env"; then
193
+ log_verbose "Installing git-based packages in openpi_env..."
194
+ conda run -n openpi_env pip install --no-cache-dir \
195
+ git+https://github.com/huggingface/lerobot@0cf864870cf29f4738d3ade893e6fd13fbd7cdb5 \
196
+ git+https://${GH_TOKEN}@github.com/tan7271/OpenPiRoboEval.git#subdirectory=packages/openpi-client --no-deps \
197
+ git+https://${GH_TOKEN}@github.com/tan7271/OpenPiRoboEval.git --no-deps --force-reinstall || {
198
+ log_verbose "⚠️ Warning: Failed to install git packages in openpi_env"
199
  }
200
 
201
+ log_verbose "Installing additional OpenPI dependencies in openpi_env..."
202
+ conda run -n openpi_env pip install --no-cache-dir \
203
+ draccus>=0.1.0 \
204
+ jsonlines>=4.0.0 || {
205
+ log_verbose "⚠️ Warning: Failed to install some additional dependencies in openpi_env"
206
+ }
207
+ fi
208
+ fi
209
+
210
+ # Install RoboEval into openpi_env
211
+ install_roboeval_into_env "openpi_env" "3.12"
212
+
213
+ # Install git-based packages and RoboEval in openvla_env if it exists
214
+ if [ "${INSTALL_GIT_DEPS:-1}" = "1" ]; then
215
+ if conda env list | grep -q "openvla_env"; then
216
+ log_verbose "Installing git-based packages in openvla_env..."
217
+ conda run -n openvla_env pip install --no-cache-dir \
218
+ git+https://github.com/openvla/openvla.git || {
219
+ log_verbose "⚠️ Warning: Failed to install OpenVLA in openvla_env"
220
+ }
221
  fi
 
 
222
  fi
223
 
224
+ # Install RoboEval into openvla_env
225
+ install_roboeval_into_env "openvla_env" "3.10"
226
 
227
+ log_verbose "✓ RoboEval installation complete"
run.sh CHANGED
@@ -24,10 +24,16 @@ fi
24
  # Install RoboEval at runtime if not already installed
25
  # This uses GH_TOKEN environment variable (available at runtime in HuggingFace Spaces)
26
  if [ -n "$GH_TOKEN" ]; then
27
- echo "Installing RoboEval at runtime (if not already installed)..."
28
- bash install_roboeval_runtime.sh || {
29
- echo "⚠️ Warning: RoboEval installation failed. The app will continue but some features may not work."
30
- }
 
 
 
 
 
 
31
  else
32
  echo "⚠️ Warning: GH_TOKEN not set. Skipping RoboEval installation."
33
  echo " Some features may not work. Set GH_TOKEN as a secret in Space settings."
 
24
  # Install RoboEval at runtime if not already installed
25
  # This uses GH_TOKEN environment variable (available at runtime in HuggingFace Spaces)
26
  if [ -n "$GH_TOKEN" ]; then
27
+ # Check if RoboEval is already installed before running installer
28
+ if python -c "import roboeval" 2>/dev/null; then
29
+ # Already installed, skip
30
+ :
31
+ else
32
+ echo "Installing RoboEval at runtime (if not already installed)..."
33
+ bash install_roboeval_runtime.sh || {
34
+ echo "⚠️ Warning: RoboEval installation failed. The app will continue but some features may not work."
35
+ }
36
+ fi
37
  else
38
  echo "⚠️ Warning: GH_TOKEN not set. Skipping RoboEval installation."
39
  echo " Some features may not work. Set GH_TOKEN as a secret in Space settings."