C2-151 commited on
Commit
c4d1578
·
1 Parent(s): 073cc53

Download pybullet-object-models at runtime to bypass Docker limits

Browse files
Files changed (2) hide show
  1. Dockerfile +0 -5
  2. main.py +14 -0
Dockerfile CHANGED
@@ -36,11 +36,6 @@ ENV PATH=/home/user/.local/bin:$PATH
36
  # Thiết lập thư mục làm việc của user (Spaces thường map vào home của user)
37
  WORKDIR $HOME/app
38
 
39
- # Clone pybullet-object-models (shallow) bằng quyền user và cài đặt dạng edit mode (tránh tạo file wheel trên memory/tmp)
40
- RUN git clone --depth 1 https://github.com/eleramp/pybullet-object-models.git \
41
- && rm -rf pybullet-object-models/.git \
42
- && pip install --no-cache-dir -e ./pybullet-object-models
43
-
44
  # Copy lại code vào home của user và phân quyền (chỉ copy 1 lần)
45
  COPY --chown=user . $HOME/app
46
 
 
36
  # Thiết lập thư mục làm việc của user (Spaces thường map vào home của user)
37
  WORKDIR $HOME/app
38
 
 
 
 
 
 
39
  # Copy lại code vào home của user và phân quyền (chỉ copy 1 lần)
40
  COPY --chown=user . $HOME/app
41
 
main.py CHANGED
@@ -18,6 +18,20 @@ from typing import Optional
18
 
19
  import pybullet as pb
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  from llm_panda import config
22
  from llm_panda import logger as _logger_setup
23
  from llm_panda.llm_agent import LLMAgent, RemoteLLMPlanner
 
18
 
19
  import pybullet as pb
20
 
21
+ import sys
22
+ import os
23
+ import subprocess
24
+ import tempfile
25
+
26
+ try:
27
+ import pybullet_object_models
28
+ except ImportError:
29
+ print("Downloading pybullet-object-models at runtime to bypass Docker limits...", flush=True)
30
+ target_dir = os.path.join(tempfile.gettempdir(), "pybullet-object-models")
31
+ if not os.path.exists(target_dir):
32
+ subprocess.run(["git", "clone", "--depth", "1", "https://github.com/eleramp/pybullet-object-models.git", target_dir], check=True)
33
+ sys.path.insert(0, target_dir)
34
+
35
  from llm_panda import config
36
  from llm_panda import logger as _logger_setup
37
  from llm_panda.llm_agent import LLMAgent, RemoteLLMPlanner