forked from microsoft/TaskWeaver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
333 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Use the official Python 3.10 image as the base image | ||
FROM python:3.10 | ||
|
||
# Set the working directory to /app | ||
WORKDIR /app | ||
|
||
# Copy the requrements file | ||
COPY requirements.txt /app/requirements.txt | ||
|
||
# Install any necessary dependencies | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
# Copy the project code | ||
COPY taskweaver/ces /app/taskweaver/ces | ||
COPY taskweaver/plugin /app/taskweaver/plugin | ||
COPY taskweaver/__init__.py /app/taskweaver/__init__.py | ||
# Add the taskweaver directories to the PYTHONPATH | ||
ENV PYTHONPATH="${PYTHONPATH}:/app/taskweaver" | ||
|
||
CMD ["python", "/app/taskweaver/ces/docker_entry.py"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
param ( | ||
[string]$imageName | ||
) | ||
|
||
if (-not $imageName) { | ||
Write-Host "Please provide an image name as an argument." | ||
exit 1 | ||
} | ||
|
||
$taskweaverPath = "..\taskweaver" | ||
$requirementsPath = "..\requirements.txt" | ||
|
||
if (Test-Path $taskweaverPath) { | ||
Write-Host "Using local files from $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 | ||
} | ||
|
||
# Build the Docker image | ||
docker build -t $imageName . | ||
|
||
# Remove temporary files | ||
Remove-Item -Path ".\taskweaver" -Recurse -Force | ||
Remove-Item -Path ".\requirements.txt" -Force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
if [ -z "$1" ]; then | ||
echo "Please provide an image name as an argument." | ||
exit 1 | ||
fi | ||
|
||
imageName="$1" | ||
taskweaverPath="../taskweaver" | ||
requirementsPath="../requirements.txt" | ||
|
||
if [ -d "$taskweaverPath" ]; then | ||
echo "Using local files from $folderPath" | ||
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" | ||
fi | ||
|
||
# Build the Docker image | ||
docker build -t "$imageName" . | ||
|
||
rm -rf taskweaver | ||
rm requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import os | ||
import time | ||
|
||
from taskweaver.ces import Environment, EnvMode | ||
|
||
# Flag to control the main loop | ||
keep_running = True | ||
|
||
env_id = os.getenv( | ||
"TASKWEAVER_ENV_ID", | ||
"local", | ||
) | ||
env_dir = os.getenv( | ||
"TASKWEAVER_ENV_DIR", | ||
os.path.realpath(os.getcwd()), | ||
) | ||
session_id = os.getenv( | ||
"TASKWEAVER_SESSION_ID", | ||
"session_id", | ||
) | ||
port_start = int( | ||
os.getenv( | ||
"TASKWEAVER_PORT_START", | ||
"12300", | ||
), | ||
) | ||
kernel_id = os.getenv( | ||
"TASKWEAVER_KERNEL_ID", | ||
"kernel_id", | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
env = Environment(env_id, env_dir, env_mode=EnvMode.InsideContainer) | ||
env.start_session(session_id, port_start=port_start, kernel_id=kernel_id) | ||
|
||
print(f"Session {session_id} is running at {env_dir} inside a container.") | ||
|
||
# Keep the script running until it receives a termination signal | ||
try: | ||
# Keep the script running indefinitely | ||
while True: | ||
time.sleep(10) # Sleep for 10 seconds | ||
except KeyboardInterrupt: | ||
# Handle Ctrl-C or other interruption signals | ||
pass | ||
finally: | ||
# Clean up and shut down the kernel | ||
env.stop_session(session_id) |
Oops, something went wrong.