dynamic imports

This commit is contained in:
elleven11 2023-04-11 22:54:40 -04:00
parent a427869f1a
commit e07aa1d253

View File

@ -1,14 +1,14 @@
from typing import List
from .executor_types import ExecuteResult, Executor
from .leetcode_env.leetcode_env.utils import SubmissionFormatter
from .leetcode_env.leetcode_env.environment import LeetCodeEnv
from .leetcode_env.leetcode_env.leetcode_types import ProgrammingLanguage, LeetCodeSubmission
from .leetcode_env.leetcode_env.utils import id_from_slug
class LeetExecutor(Executor):
from .leetcode_env.leetcode_env.utils import SubmissionFormatter
from .leetcode_env.leetcode_env.leetcode_types import ProgrammingLanguage
def __init__(self, lang: ProgrammingLanguage, executor: Executor, formatter: SubmissionFormatter):
from .leetcode_env.leetcode_env.environment import LeetCodeEnv
self.lang = lang
self.executor = executor
self.formatter = formatter
@ -18,6 +18,8 @@ class LeetExecutor(Executor):
return self.executor.execute(func, tests, timeout)
def evaluate(self, name: str, func: str, test: str, timeout: int = 5) -> bool:
from .leetcode_env.leetcode_env.utils import id_from_slug
from .leetcode_env.leetcode_env.leetcode_types import LeetCodeSubmission
submission = LeetCodeSubmission(
code=self.formatter.to_leetcode(func),
lang=self.lang,
@ -29,4 +31,3 @@ class LeetExecutor(Executor):
_, reward, _, _ = self.env.step(submission)
return reward