Skip to content

Commit

Permalink
Merge pull request #909 from allenai/erick/remove-cloudrendering-default
Browse files Browse the repository at this point in the history
remove cloudrendering default
  • Loading branch information
Eric Kolve authored Oct 6, 2021
2 parents 18fca24 + eb28acd commit 2f8dd9f
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,3 @@ AI2 is a non-profit institute with the mission to contribute to humanity through
<a href="//prior.allenai.org">
<p align="center"><img width="100%" src="https://raw.githubusercontent.com/allenai/ai2thor/main/doc/static/ai2-prior.svg" /></p>
</a>

19 changes: 18 additions & 1 deletion ai2thor/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,22 @@ def _start_unity_thread(self, env, width, height, server_params, image_name):
stdout=open(os.path.join(self.log_dir, "unity.log"), "a"),
stderr=open(os.path.join(self.log_dir, "unity.log"), "a"),
)

try:
if self._build.platform == ai2thor.platform.CloudRendering:
# if Vulkan is not configured correctly then Unity will crash
# immediately after launching
self.server.unity_proc.wait(timeout=1.0)
if self.server.unity_proc.returncode is not None:
message = (
"Unity process has exited - check Player.log for errors. Confirm that Vulkan is properly configured on this system using vulkaninfo from the vulkan-utils package. returncode=%s"
% (self.server.unity_proc.returncode,)
)
raise Exception(message)

except subprocess.TimeoutExpired:
pass

self.unity_pid = proc.pid
atexit.register(lambda: proc.poll() is None and proc.kill())

Expand Down Expand Up @@ -1170,7 +1186,8 @@ def find_build(self, local_build, commit_id, branch, platform):
# is enabled, then it will get selected over Linux64 (assuming a build is available)
for build in builds:
if build.platform.is_valid(request):
if build.commit_id != commits[0]:
# don't emit warnings for CloudRendering since we allow it to fallback to a default
if build.commit_id != commits[0] and build.platform != ai2thor.platform.CloudRendering:
warnings.warn(
"Build for the most recent commit: %s is not available. Using commit build %s"
% (commits[0], build.commit_id)
Expand Down
2 changes: 1 addition & 1 deletion ai2thor/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class WebGL(BasePlatform):

def select_platforms(request):
candidates = []
system_platform_map = dict(Linux=(Linux64, CloudRendering), Darwin=(OSXIntel64,))
system_platform_map = dict(Linux=(Linux64,), Darwin=(OSXIntel64,))
for p in system_platform_map.get(request.system, ()):
if not p.enabled:
continue
Expand Down
10 changes: 10 additions & 0 deletions ai2thor/tests/test_controller.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ai2thor.controller
from ai2thor.server import Event
from ai2thor.platform import CloudRendering, Linux64
import pytest
import numpy as np
import warnings
Expand Down Expand Up @@ -52,6 +53,11 @@ def fake_darwin_system():
def noop_download(self):
pass

def select_platforms_linux_cr(request):
return (Linux64, CloudRendering)

def select_platforms_cr(request):
return (CloudRendering, )

@classmethod
def fake_validate(cls, request):
Expand Down Expand Up @@ -159,6 +165,7 @@ def test_linux_invalid_linux64_invalid_cr(mocker):
mocker.patch("ai2thor.controller.platform_system", fake_linux_system)
mocker.patch("ai2thor.controller.ai2thor.build.Build.exists", fake_exists)
mocker.patch("ai2thor.controller.ai2thor.build.Build.download", noop_download)
mocker.patch("ai2thor.controller.ai2thor.platform.select_platforms", select_platforms_linux_cr)
mocker.patch(
"ai2thor.controller.ai2thor.platform.CloudRendering.validate",
fake_invalid_cr_validate,
Expand All @@ -182,6 +189,7 @@ def test_linux_invalid_linux64_valid_cr(mocker):
mocker.patch("ai2thor.controller.platform_system", fake_linux_system)
mocker.patch("ai2thor.controller.ai2thor.build.Build.exists", fake_exists)
mocker.patch("ai2thor.controller.ai2thor.build.Build.download", noop_download)
mocker.patch("ai2thor.controller.ai2thor.platform.select_platforms", select_platforms_linux_cr)
mocker.patch(
"ai2thor.controller.ai2thor.platform.CloudRendering.validate", fake_validate
)
Expand Down Expand Up @@ -219,6 +227,7 @@ def test_linux_valid_linux64_valid_cloudrendering_enabled_cr(mocker):
mocker.patch("ai2thor.controller.platform_system", fake_linux_system)
mocker.patch("ai2thor.controller.ai2thor.build.Build.exists", fake_exists)
mocker.patch("ai2thor.controller.ai2thor.build.Build.download", noop_download)
mocker.patch("ai2thor.controller.ai2thor.platform.select_platforms", select_platforms_cr)
mocker.patch(
"ai2thor.controller.ai2thor.platform.CloudRendering.validate", fake_validate
)
Expand Down Expand Up @@ -258,6 +267,7 @@ def test_linux_missing_linux64(mocker):
"ai2thor.controller.ai2thor.platform.CloudRendering.validate", fake_validate
)
mocker.patch("ai2thor.platform.CloudRendering.enabled", True)
mocker.patch("ai2thor.controller.ai2thor.platform.select_platforms", select_platforms_linux_cr)

fake_commit_id = "1234567TEST"
c = controller(commit_id=fake_commit_id)
Expand Down
11 changes: 10 additions & 1 deletion ai2thor/tests/test_unity.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ class ThirdPartyCameraMetadata:
rotation = "rotation"
fieldOfView = "fieldOfView"

class TestController(Controller):

def unity_command(self, width, height, headless):
command = super().unity_command(width, height, headless)
# force OpenGLCore to get used so that the tests run in a consistent way
# With low power graphics cards (such as those in the test environment)
# Metal behaves in inconsistent ways causing test failures
command.append("-force-glcore")
return command

def build_controller(**args):
default_args = dict(scene=TEST_SCENE, local_build=True)
Expand All @@ -39,7 +48,7 @@ def build_controller(**args):
# build instead of 'local'
with warnings.catch_warnings():
warnings.simplefilter("ignore")
c = Controller(**default_args)
c = TestController(**default_args)

# used for resetting
c._original_initialization_parameters = c.initialization_parameters
Expand Down

0 comments on commit 2f8dd9f

Please sign in to comment.