sandbox.py 841 B

12345678910111213141516171819202122232425262728293031323334353637
  1. from abc import ABC, abstractmethod
  2. from typing import Dict, Tuple
  3. from opendevin.runtime.docker.process import Process
  4. from opendevin.runtime.plugins.mixin import PluginMixin
  5. class Sandbox(ABC, PluginMixin):
  6. background_commands: Dict[int, Process] = {}
  7. @abstractmethod
  8. def execute(self, cmd: str) -> Tuple[int, str]:
  9. pass
  10. @abstractmethod
  11. def execute_in_background(self, cmd: str) -> Process:
  12. pass
  13. @abstractmethod
  14. def kill_background(self, id: int) -> Process:
  15. pass
  16. @abstractmethod
  17. def read_logs(self, id: int) -> str:
  18. pass
  19. @abstractmethod
  20. def close(self):
  21. pass
  22. @abstractmethod
  23. def copy_to(self, host_src: str, sandbox_dest: str, recursive: bool = False):
  24. pass
  25. @abstractmethod
  26. def get_working_directory(self):
  27. pass