Skip to content

Remote

swerex.deployment.remote.RemoteDeployment

RemoteDeployment(*, logger: Logger | None = None, **kwargs: Any)

Bases: AbstractDeployment

This deployment is only a thin wrapper around the RemoteRuntime. Use this if you have deployed a runtime somewhere else but want to interact with it through the AbstractDeployment interface. For example, if you have an agent that you usually use with a DocerkDeployment interface, you sometimes might want to manually start a docker container for debugging purposes. Then you can use this deployment to explicitly connect to your manually started runtime.

Parameters:

Name Type Description Default
**kwargs Any

Keyword arguments (see RemoteDeploymentConfig for details).

{}
Source code in swerex/deployment/remote.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def __init__(self, *, logger: logging.Logger | None = None, **kwargs: Any):
    """This deployment is only a thin wrapper around the `RemoteRuntime`.
    Use this if you have deployed a runtime somewhere else but want to interact with it
    through the `AbstractDeployment` interface.
    For example, if you have an agent that you usually use with a `DocerkDeployment` interface,
    you sometimes might want to manually start a docker container for debugging purposes.
    Then you can use this deployment to explicitly connect to your manually started runtime.

    Args:
        **kwargs: Keyword arguments (see `RemoteDeploymentConfig` for details).
    """
    self._config = RemoteDeploymentConfig(**kwargs)
    self._runtime: RemoteRuntime | None = None
    self.logger = logger or get_logger("rex-deploy")
    self._hooks = CombinedDeploymentHook()

logger instance-attribute

logger = logger or get_logger('rex-deploy')

runtime property

runtime: RemoteRuntime

Returns the runtime if running.

Raises:

Type Description
DeploymentNotStartedError

If the deployment was not started.

add_hook

add_hook(hook: DeploymentHook)
Source code in swerex/deployment/remote.py
32
33
def add_hook(self, hook: DeploymentHook):
    self._hooks.add_hook(hook)

from_config classmethod

from_config(config: RemoteDeploymentConfig) -> Self
Source code in swerex/deployment/remote.py
35
36
37
@classmethod
def from_config(cls, config: RemoteDeploymentConfig) -> Self:
    return cls(**config.model_dump())

is_alive async

is_alive() -> IsAliveResponse

Checks if the runtime is alive. The return value can be tested with bool().

Raises:

Type Description
DeploymentNotStartedError

If the deployment was not started.

Source code in swerex/deployment/remote.py
50
51
52
53
54
55
56
57
async def is_alive(self) -> IsAliveResponse:
    """Checks if the runtime is alive. The return value can be
    tested with bool().

    Raises:
        DeploymentNotStartedError: If the deployment was not started.
    """
    return await self.runtime.is_alive()

start async

start()

Starts the runtime.

Source code in swerex/deployment/remote.py
59
60
61
62
63
64
65
66
67
68
async def start(self):
    """Starts the runtime."""
    self.logger.info("Starting remote runtime")
    self._runtime = RemoteRuntime(
        auth_token=self._config.auth_token,
        host=self._config.host,
        port=self._config.port,
        timeout=self._config.timeout,
        logger=self.logger,
    )

stop async

stop()

Stops the runtime.

Source code in swerex/deployment/remote.py
70
71
72
73
async def stop(self):
    """Stops the runtime."""
    await self.runtime.close()
    self._runtime = None