Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ $ bazel run //android_env/playground:playground -- \

### 4. Reinforcement Learning (`dm_env`)

To define MDP tasks with rewards and episode resets, see the
To define MDP tasks with rewards and episode resets (after
`pip install "android-env[rl]"`), see the
[Tasks guide](https://github.com/google-deepmind/android_env/blob/gh-pages/docs/tasks_guide.md),
[Example tasks](https://github.com/google-deepmind/android_env/blob/gh-pages/docs/example_tasks.md),
and
Expand Down
3 changes: 2 additions & 1 deletion README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ $ bazel run //android_env/playground:playground -- \

### 4. 强化学习接入 (`dm_env`)

如需定义包含奖励机制与回合重置的 MDP 任务,请参阅[任务指南](https://github.com/google-deepmind/android_env/blob/gh-pages/docs/tasks_guide.md)、[示例任务库](https://github.com/google-deepmind/android_env/blob/gh-pages/docs/example_tasks.md)以及[详细操作说明](https://github.com/google-deepmind/android_env/blob/gh-pages/docs/instructions.md)。
如需定义包含奖励机制与回合重置的 MDP 任务(通过 `pip install "android-env[rl]"`
安装后),请参阅[任务指南](https://github.com/google-deepmind/android_env/blob/gh-pages/docs/tasks_guide.md)、[示例任务库](https://github.com/google-deepmind/android_env/blob/gh-pages/docs/example_tasks.md)以及[详细操作说明](https://github.com/google-deepmind/android_env/blob/gh-pages/docs/instructions.md)。

## 关于 AndroidEnv (About)

Expand Down
37 changes: 5 additions & 32 deletions android_env/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,6 @@ load("@rules_python//python:packaging.bzl", "py_package", "py_wheel")

package(default_visibility = ["//visibility:public"])

py_library(
name = "android_env",
srcs = ["__init__.py"],
deps = [
":env_interface",
":loader",
"//android_env/components:android_device",
"//android_env/components:android_device_loader",
"//android_env/components:config_classes",
"//android_env/rl:environment",
],
)

py_test(
name = "init_test",
srcs = ["init_test.py"],
legacy_create_init = False,
deps = [
":android_env",
":env_interface",
":loader",
"//android_env/components:android_device",
"//android_env/components:android_device_loader",
"//android_env/components:config_classes",
"//android_env/rl:environment",
"@pip//absl_py",
],
)

py_library(
name = "env_interface",
srcs = ["env_interface.py"],
Expand Down Expand Up @@ -78,7 +49,6 @@ py_package(
name = "android_env_pkg",
packages = ["android_env"],
deps = [
":android_env",
":loader",
"//android_env/components:android_device_loader",
"//android_env/mcp:android_mcp_server_lib",
Expand Down Expand Up @@ -112,16 +82,19 @@ py_wheel(
],
},
extra_requires = {
"gym": ["gymnasium>=0.29.1"],
"gym": [
"dm-env>=1.6",
"gymnasium>=0.29.1",
],
"mcp": ["mcp>=1.26,<2"],
"playground": ["ml-collections"],
"rl": ["dm-env>=1.6"],
},
homepage = "https://github.com/google-deepmind/android_env",
license = "Apache License, Version 2.0",
python_requires = ">=3.10",
requires = [
"absl-py>=2.1.0",
"dm-env>=1.6",
"numpy>=2.1.0",
"portpicker>=1.6.0",
"pillow>=10.4.0",
Expand Down
54 changes: 0 additions & 54 deletions android_env/__init__.py

This file was deleted.

5 changes: 0 additions & 5 deletions android_env/components/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ load("@rules_python//python:defs.bzl", "py_library", "py_test")

package(default_visibility = ["//visibility:public"])

py_library(
name = "action_type",
srcs = ["action_type.py"],
)

py_library(
name = "adb_call_parser",
srcs = ["adb_call_parser.py"],
Expand Down
15 changes: 0 additions & 15 deletions android_env/components/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion android_env/components/adb_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def init_server(self, timeout: float | None = None):
"""Initialize the ADB server deamon on the given port.

This function should be called immediately after initializing the first
adb_controller, and before launching the simulator.
adb_controller, and before launching the emulator or connecting to a device.

Args:
timeout: A timeout to use for this operation. If not set the default
Expand Down
2 changes: 1 addition & 1 deletion android_env/components/config_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,6 @@ class AndroidEnvConfig:
task_manager: TaskManagerConfig = dataclasses.field(
default_factory=TaskManagerConfig
)
simulator: AndroidDeviceConfig = dataclasses.field(
device: AndroidDeviceConfig = dataclasses.field(
default_factory=AndroidDeviceConfig
)
23 changes: 1 addition & 22 deletions android_env/components/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,17 @@ class AndroidEnvError(Exception):


class ReadObservationError(AndroidEnvError):
"""When the environment is unable to obtain an observation from a simulator."""
"""When the environment is unable to obtain an observation from the device."""

ERROR_CODE = 1


class CoordinatorError(AndroidEnvError):
"""Error raised by the Coordinator."""

ERROR_CODE = 2


class TooManyRestartsError(CoordinatorError):
"""The number of restarts has exceeded _MAX_RESTART_TRIES."""

ERROR_CODE = 3


class AdbControllerError(AndroidEnvError):
"""Errors that can be raised by ADBController."""

ERROR_CODE = 4


class SimulatorError(AndroidEnvError):
"""Errors that can be raised by a simulator."""

ERROR_CODE = 5


class SendActionError(AndroidEnvError):
"""Raised when action couldn't be sent successfully."""

Expand Down Expand Up @@ -90,10 +72,7 @@ def from_code(code: int, msg: str = '') -> AndroidEnvError | None:
code_to_error = {
0: AndroidEnvError,
1: ReadObservationError,
2: CoordinatorError,
3: TooManyRestartsError,
4: AdbControllerError,
5: SimulatorError,
6: SendActionError,
7: StepCommandError,
8: WaitForAppScreenError,
Expand Down
12 changes: 0 additions & 12 deletions android_env/components/errors_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ class ErrorsTest(parameterized.TestCase):

@parameterized.parameters(
(errors.ReadObservationError, 1),
(errors.CoordinatorError, 2),
(errors.TooManyRestartsError, 3),
(errors.AdbControllerError, 4),
(errors.SimulatorError, 5),
(errors.SendActionError, 6),
(errors.StepCommandError, 7),
(errors.WaitForAppScreenError, 8),
Expand All @@ -42,10 +39,7 @@ def test_error_codes_unique(self):
error_codes = set()
errors_list = (
errors.ReadObservationError,
errors.CoordinatorError,
errors.TooManyRestartsError,
errors.AdbControllerError,
errors.SimulatorError,
errors.SendActionError,
errors.StepCommandError,
errors.WaitForAppScreenError,
Expand All @@ -57,10 +51,7 @@ def test_error_codes_unique(self):

@parameterized.parameters([
errors.ReadObservationError(),
errors.CoordinatorError(),
errors.TooManyRestartsError(),
errors.AdbControllerError(),
errors.SimulatorError(),
errors.SendActionError(),
errors.StepCommandError(),
errors.WaitForAppScreenError(),
Expand All @@ -86,10 +77,7 @@ def test_from_code_unsupported_code(self, code: int):
(0, errors.AndroidEnvError, 'hello'),
(0, errors.AndroidEnvError, ''),
(1, errors.ReadObservationError, 'Could not read obs.'),
(2, errors.CoordinatorError, 'Some error'),
(3, errors.TooManyRestartsError, 'Too many already...'),
(4, errors.AdbControllerError, 'Some adb error...'),
(5, errors.SimulatorError, 'Simulator is not coping.'),
(6, errors.SendActionError, 'Could not send action.'),
(7, errors.StepCommandError, 'Some issue setting up the task.'),
(8, errors.WaitForAppScreenError, 'Waited for too long!'),
Expand Down
70 changes: 0 additions & 70 deletions android_env/init_test.py

This file was deleted.

6 changes: 3 additions & 3 deletions android_env/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ def load(
) -> env_interface.AndroidEnvInterface:
"""Loads an AndroidEnv instance."""

if isinstance(config.simulator, config_classes.AndroidDeviceConfig):
device = android_device_loader.load_android_device(config.simulator)
if isinstance(config.device, config_classes.AndroidDeviceConfig):
device = android_device_loader.load_android_device(config.device)
env = rl_environment.AndroidEnv(device=device)
if config.task != config_classes.TaskConfig():
task = _load_task(config.task)
env = task_wrapper.TaskWrapper(env, task=task, config=config.task_manager)
return env

raise ValueError(f'Unsupported simulator config: {config.simulator}')
raise ValueError(f'Unsupported device config: {config.device}')
Loading
Loading