Skip to content

Commit

Permalink
Liqun/custom image (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
liqul authored Oct 10, 2024
1 parent 683501b commit cf76c3b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
3 changes: 2 additions & 1 deletion docker/ces_container/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ groupmod -g $GROUP_ID taskweaver

chown -R taskweaver:taskweaver /app

su taskweaver -c "python -m taskweaver.ces.kernel.launcher"
su taskweaver -c "python -m venv --system-site-packages venv"
su taskweaver -c "bash -c 'source venv/bin/activate; python -m taskweaver.ces.kernel.launcher'"

4 changes: 0 additions & 4 deletions taskweaver/ces/kernel/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ def start_app():
if __name__ == "__main__":
if sys.path[0] == "":
del sys.path[0]
import site

user_site_packages = site.getusersitepackages()
if user_site_packages not in sys.path:
sys.path.append(site.getusersitepackages())
logger.info("Starting process...")
logger.info("sys.path: %s", sys.path)
logger.info("os.getcwd(): %s", os.getcwd())
Expand Down
14 changes: 8 additions & 6 deletions tests/unit_tests/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ def test_environment_start_outside_container():
cwd = os.path.dirname(os.path.abspath(__file__))
sessions = os.path.join(cwd, "sessions")
try:
env = Environment("local", env_mode=EnvMode.Container)
env = Environment(
"local",
env_mode=EnvMode.Container,
custom_image="taskweavercontainers/taskweaver-executor:0.3",
)
env.start_session(
session_id="session_id",
session_dir=os.path.join(sessions, "session_id"),
Expand All @@ -177,13 +181,11 @@ def test_environment_start_outside_container():
connection_file = glob.glob(conn_file_glob)[0]
ports_file = os.path.join(ces_dir, "ports.json")
assert os.path.isfile(ports_file)

connect_and_execute_code(connection_file, ports_file)

saved_file = os.path.join(session_dir, "cwd", "filename.txt")
assert os.path.isfile(saved_file)
code = "!pip install yfinance\nimport sys\nprint(sys.path)\nimport yfinance as yf\nprint(yf.__version__)"
connect_and_execute_code(connection_file, ports_file, code=code)

env.stop_session("session_id")

finally:
# delete sessions
shutil.rmtree(sessions)

0 comments on commit cf76c3b

Please sign in to comment.