Skip to content

Commit

Permalink
Merge pull request #17 from iamhatesz/feature/unique-tmp-code
Browse files Browse the repository at this point in the history
  • Loading branch information
vndee authored Jan 29, 2025
2 parents c71368c + f864e16 commit 2b7c148
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions llm_sandbox/kubernetes.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import io
import os
import tempfile
import time
import uuid
import tarfile
from pathlib import Path
from typing import List, Optional

from kubernetes import client as k8s_client, config
Expand Down Expand Up @@ -156,16 +158,18 @@ def run(self, code: str, libraries: Optional[List] = None) -> ConsoleOutput:
f"Failed to install library {library}: {output}"
)

code_file = f"/tmp/code.{get_code_file_extension(self.lang)}"
code_file_name = f"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_dest_file = f"/tmp/{code_file_name}"

with open(code_file, "w") as f:
f.write(code)
with tempfile.TemporaryDirectory() as tmp_dir:
code_file = Path(tmp_dir) / code_file_name
with open(code_file, "w") as f:
f.write(code)
self.copy_to_runtime(str(code_file), code_dest_file)

self.copy_to_runtime(code_file, code_dest_file)
commands = get_code_execution_command(self.lang, code_dest_file)

output = KubernetesConsoleOutput(0, "")
Expand Down

0 comments on commit 2b7c148

Please sign in to comment.