From 2bf45f3e8ba06f7810836e967b7dd4806c15b514 Mon Sep 17 00:00:00 2001 From: stone_tao Date: Tue, 6 Dec 2022 13:26:12 -0800 Subject: [PATCH] v1.1.2 fix bugs --- luxai_runner/ext_to_command.py | 2 +- luxai_runner/process.py | 38 +++++++++++++++++++++++----------- setup.py | 2 +- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/luxai_runner/ext_to_command.py b/luxai_runner/ext_to_command.py index 4871b467..1cb7c997 100644 --- a/luxai_runner/ext_to_command.py +++ b/luxai_runner/ext_to_command.py @@ -1,6 +1,6 @@ ext_to_command = { ".js": "node", ".py": "python", - ".out": "./agent.out", + ".out": "./", ".java": "java", } diff --git a/luxai_runner/process.py b/luxai_runner/process.py index d8bf1c50..380e30df 100644 --- a/luxai_runner/process.py +++ b/luxai_runner/process.py @@ -14,6 +14,10 @@ class BotProcess: def __init__(self, command: str, file_path: str, verbose: int = 2, live_log: str = True, direct_import_python_bots = False) -> None: self.command = command + if self.command == "./": + self.is_binary = True + else: + self.is_binary = False self.file_path = file_path self.log = Logger(identifier="", verbosity=verbose) self.live_log = live_log @@ -38,18 +42,28 @@ async def start(self): self.log.info(f"Beginning {self.command} {self.file_path}") # self._agent_process = Popen([self.command, os.path.basename(self.file_path)], stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=cwd) - base_file_path = os.path.basename(self.file_path) - if self.command == "java" and base_file_path.endswith(".java"): - base_file_path = base_file_path[:-5] - self._agent_process = await asyncio.create_subprocess_exec( - self.command, - base_file_path, - stdin=asyncio.subprocess.PIPE, - stdout=asyncio.subprocess.PIPE, - stderr=asyncio.subprocess.PIPE, - cwd=cwd, - limit=1024 * 128 - ) + base_file_path = os.path.basename(self.file_path) + if self.is_binary: + self._agent_process = await asyncio.create_subprocess_exec( + f"./{base_file_path}", + stdin=asyncio.subprocess.PIPE, + stdout=asyncio.subprocess.PIPE, + stderr=asyncio.subprocess.PIPE, + cwd=cwd, + limit=1024 * 128 + ) + else: + if self.command == "java" and base_file_path.endswith(".java"): + base_file_path = base_file_path[:-5] + self._agent_process = await asyncio.create_subprocess_exec( + self.command, + base_file_path, + stdin=asyncio.subprocess.PIPE, + stdout=asyncio.subprocess.PIPE, + stderr=asyncio.subprocess.PIPE, + cwd=cwd, + limit=1024 * 128 + ) self.log.info(f"Started {self.command} {self.file_path}") # following 4 lines from https://stackoverflow.com/questions/375427/a-non-blocking-read-on-a-subprocess-pipe-in-python # used to track stderr data asynchronously diff --git a/setup.py b/setup.py index 834ea933..eae61a88 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ def read(fname): setup( name="luxai2022", - version="1.1.1", + version="1.1.2", author="Lux AI Challenge", description="The Lux AI Challenge Season 2", license="MIT",