Skip to content

Commit

Permalink
v1.1.2
Browse files Browse the repository at this point in the history
fix bugs
  • Loading branch information
StoneT2000 committed Dec 6, 2022
1 parent 87678d3 commit 2bf45f3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion luxai_runner/ext_to_command.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ext_to_command = {
".js": "node",
".py": "python",
".out": "./agent.out",
".out": "./",
".java": "java",
}
38 changes: 26 additions & 12 deletions luxai_runner/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 2bf45f3

Please sign in to comment.