Skip to content

Commit

Permalink
Merge pull request #2 from DSri01/main
Browse files Browse the repository at this point in the history
Fixed Windows Docker Code File Not found Issue
  • Loading branch information
vndee authored Oct 21, 2024
2 parents a9d4cd1 + bf0e716 commit e26e006
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
34 changes: 18 additions & 16 deletions llm_sandbox/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import docker
import tarfile
import tempfile
from typing import List, Optional, Union

from docker.models.images import Image
Expand Down Expand Up @@ -163,27 +164,28 @@ def run(self, code: str, libraries: Optional[List] = None) -> ConsoleOutput:
for library in libraries:
command = get_libraries_installation_command(self.lang, library)
_ = self.execute_command(command)
with tempfile.TemporaryDirectory() as directory_name:

code_file = f"/tmp/code.{get_code_file_extension(self.lang)}"
if self.lang == SupportedLanguage.GO:
code_dest_file = "/example/code.go"
else:
code_dest_file = code_file
code_file = os.path.join(directory_name,f"code.{get_code_file_extension(self.lang)}")
if self.lang == SupportedLanguage.GO:
code_dest_file = "/example/code.go"
else:
code_dest_file = f"/tmp/code.{get_code_file_extension(self.lang)}"# code_file

with open(code_file, "w") as f:
f.write(code)
with open(code_file, "w") as f:
f.write(code)

self.copy_to_runtime(code_file, code_dest_file)
self.copy_to_runtime(code_file, code_dest_file)

output = ConsoleOutput("")
commands = get_code_execution_command(self.lang, code_dest_file)
for command in commands:
if self.lang == SupportedLanguage.GO:
output = self.execute_command(command, workdir="/example")
else:
output = self.execute_command(command)
output = ConsoleOutput("")
commands = get_code_execution_command(self.lang, code_dest_file)
for command in commands:
if self.lang == SupportedLanguage.GO:
output = self.execute_command(command, workdir="/example")
else:
output = self.execute_command(command)

return output
return output

def copy_from_runtime(self, src: str, dest: str):
if not self.container:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "llm-sandbox"
version = "0.1.1"
version = "0.1.1-alpha"
description = "Lightweight and portable LLM sandbox runtime (code interpreter) Python library"
authors = ["Duy Huynh <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit e26e006

Please sign in to comment.