Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
liqul committed Feb 23, 2024
1 parent 59eefb2 commit 891fce9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 23 deletions.
3 changes: 1 addition & 2 deletions ces_container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ COPY taskweaver/ces /app/taskweaver/ces
COPY taskweaver/plugin /app/taskweaver/plugin
COPY taskweaver/module /app/taskweaver/module
COPY taskweaver/__init__.py /app/taskweaver/__init__.py

RUN mv /app/taskweaver/ces/docker_entry.py /app/docker_entry.py
COPY docker_entry.py /app/docker_entry.py

ENV PYTHONPATH "${PYTHONPATH}:/app"

Expand Down
7 changes: 2 additions & 5 deletions ces_container/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ if (Test-Path $taskweaverPath) {
Copy-Item -Path $taskweaverPath -Destination ".\taskweaver" -Recurse
Copy-Item -Path $requirementsPath -Destination ".\requirements.txt"
} else {
Write-Host "Cloning repository and using repository files"
git clone https://github.com/microsoft/TaskWeaver.git
Move-Item -Path ".\TaskWeaver\taskweaver" -Destination ".\taskweaver"
Move-Item -Path ".\TaskWeaver\requirements.txt" -Destination ".\requirements.txt"
Remove-Item -Path ".\TaskWeaver" -Recurse -Force
Write-Host "Local files not found."
exit 1
}

# Build the Docker image
Expand Down
7 changes: 2 additions & 5 deletions ces_container/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ if [ -d "$taskweaverPath" ]; then
cp -r "$taskweaverPath" .
cp "$requirementsPath" .
else
echo "Cloning repository and using repository files"
git clone https://github.com/microsoft/TaskWeaver.git
mv ".TaskWeaver/taskweaver" .
mv ".TaskWeaver/requirements.txt" .
rm -rf ".TaskWeaver"
echo "Local files not found."
exit 1
fi

# Build the Docker image
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import os
import sys
import time

sys.path.append("/app")

from taskweaver.ces import Environment, EnvMode

# Flag to control the main loop
Expand Down
13 changes: 5 additions & 8 deletions taskweaver/ces/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ def __init__(
self.env_dir = env_dir if env_dir is not None else os.getcwd()
self.mode = env_mode
if self.mode == EnvMode.SubProcess or self.mode == EnvMode.InsideContainer:
self.multi_kernel_manager = self._init_kernel_manager()
self.multi_kernel_manager = TaskWeaverMultiKernelManager(
default_kernel_name="taskweaver",
kernel_spec_manager=KernelSpecProvider(),
)
elif self.mode == EnvMode.OutsideContainer:
try:
import docker
Expand All @@ -150,6 +153,7 @@ def __init__(
self.port_start = 12300
else:
raise ValueError(f"Unsupported environment mode {env_mode}")
atexit.register(self.clean_up)

def clean_up(self) -> None:
for session in self.session_dict.values():
Expand All @@ -158,13 +162,6 @@ def clean_up(self) -> None:
except Exception as e:
logger.error(e)

def _init_kernel_manager(self) -> MultiKernelManager:
atexit.register(self.clean_up)
return TaskWeaverMultiKernelManager(
default_kernel_name="taskweaver",
kernel_spec_manager=KernelSpecProvider(),
)

def _get_connection_file(self, session_id: str, kernel_id: str) -> str:
return os.path.join(
self._get_session(session_id).session_dir,
Expand Down

0 comments on commit 891fce9

Please sign in to comment.