How to use the ai2thor.docker function in ai2thor

To help you get started, we’ve selected a few ai2thor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github allenai / ai2thor / ai2thor / controller.py View on Github external
def _start_unity_thread(self, env, width, height, host, port, image_name):
        # get environment variables

        env['AI2THOR_CLIENT_TOKEN'] = self.server.client_token = str(uuid.uuid4())
        env['AI2THOR_HOST'] = host
        env['AI2THOR_PORT'] = str(port)

        env['AI2THOR_SERVER_SIDE_SCREENSHOT'] = 'False' if self.headless else 'True'

        # print("Viewer: http://%s:%s/viewer" % (host, port))
        command = self.unity_command(width, height, headless=self.headless)

        if image_name is not None:
            self.container_id = ai2thor.docker.run(image_name, self.base_dir(), ' '.join(command), env)
            atexit.register(lambda: ai2thor.docker.kill_container(self.container_id))
        else:
            proc = subprocess.Popen(command, env=env)
            self.unity_pid = proc.pid
            atexit.register(lambda: proc.poll() is None and proc.kill())
            returncode = proc.wait()
            if returncode != 0 and not self.killing_unity:
                raise Exception("command: %s exited with %s" % (command, returncode))
github allenai / ai2thor / ai2thor / controller.py View on Github external
self.response_queue,
            host,
            port=port)

        _, port = self.server.wsgi_server.socket.getsockname()

        self.server_thread = threading.Thread(target=self._start_server_thread)

        self.server_thread.daemon = True
        self.server_thread.start()

        if start_unity:
            if platform.system() == 'Linux':

                if self.docker_enabled:
                    image_name = ai2thor.docker.build_image()
                else:

                    if x_display:
                        env['DISPLAY'] = ':' + x_display
                    elif 'DISPLAY' not in env:
                        env['DISPLAY'] = ':0.0'

                    self.check_x_display(env['DISPLAY'])

            if not self.local_executable_path:
                self.download_binary()
                self.lock_release()
                self.prune_releases()

            unity_thread = threading.Thread(
                target=self._start_unity_thread,
github allenai / ai2thor / ai2thor / controller.py View on Github external
raise Exception("Screen resolution must be >= 300x300")

        if self.server_thread is not None:
            print('start() method depreciated. The server has already started when Controller was initialized.')

            # Stops the current server and creates a new one. This is done so
            # that the arguments passed in will be used on the server.
            self.stop() 

        env = os.environ.copy()

        image_name = None

        if self.docker_enabled:
            self.check_docker()
            host = ai2thor.docker.bridge_gateway()

        self.server = ai2thor.server.Server(
            self.request_queue,
            self.response_queue,
            host,
            port=port)

        _, port = self.server.wsgi_server.socket.getsockname()

        self.server_thread = threading.Thread(target=self._start_server_thread)

        self.server_thread.daemon = True
        self.server_thread.start()

        if start_unity:
            if platform.system() == 'Linux':