|
|
@@ -59,13 +59,6 @@ class RemoteRuntime(Runtime):
|
|
|
status_message_callback: Optional[Callable] = None,
|
|
|
):
|
|
|
self.config = config
|
|
|
- if self.config.sandbox.api_hostname == 'localhost':
|
|
|
- self.config.sandbox.api_hostname = 'api.all-hands.dev/v0/runtime'
|
|
|
- logger.info(
|
|
|
- 'Using localhost as the API hostname is not supported in the RemoteRuntime. Please set a proper hostname.\n'
|
|
|
- 'Setting it to default value: api.all-hands.dev/v0/runtime'
|
|
|
- )
|
|
|
- self.api_url = f'https://{self.config.sandbox.api_hostname.rstrip("/")}'
|
|
|
|
|
|
if self.config.sandbox.api_key is None:
|
|
|
raise ValueError(
|
|
|
@@ -82,7 +75,7 @@ class RemoteRuntime(Runtime):
|
|
|
)
|
|
|
|
|
|
self.runtime_builder = RemoteRuntimeBuilder(
|
|
|
- self.api_url, self.config.sandbox.api_key
|
|
|
+ self.config.sandbox.remote_runtime_api_url, self.config.sandbox.api_key
|
|
|
)
|
|
|
self.runtime_id: str | None = None
|
|
|
self.runtime_url: str | None = None
|
|
|
@@ -97,7 +90,11 @@ class RemoteRuntime(Runtime):
|
|
|
self.container_image: str = self.config.sandbox.base_container_image
|
|
|
self.container_name = 'oh-remote-runtime-' + self.instance_id
|
|
|
logger.debug(f'RemoteRuntime `{sid}` config:\n{self.config}')
|
|
|
- response = send_request(self.session, 'GET', f'{self.api_url}/registry_prefix')
|
|
|
+ response = send_request(
|
|
|
+ self.session,
|
|
|
+ 'GET',
|
|
|
+ f'{self.config.sandbox.remote_runtime_api_url}/registry_prefix',
|
|
|
+ )
|
|
|
response_json = response.json()
|
|
|
registry_prefix = response_json['registry_prefix']
|
|
|
os.environ['OH_RUNTIME_RUNTIME_IMAGE_REPO'] = (
|
|
|
@@ -123,7 +120,7 @@ class RemoteRuntime(Runtime):
|
|
|
response = send_request(
|
|
|
self.session,
|
|
|
'GET',
|
|
|
- f'{self.api_url}/image_exists',
|
|
|
+ f'{self.config.sandbox.remote_runtime_api_url}/image_exists',
|
|
|
params={'image': self.container_image},
|
|
|
)
|
|
|
if response.status_code != 200 or not response.json()['exists']:
|
|
|
@@ -157,7 +154,10 @@ class RemoteRuntime(Runtime):
|
|
|
|
|
|
# Start the sandbox using the /start endpoint
|
|
|
response = send_request(
|
|
|
- self.session, 'POST', f'{self.api_url}/start', json=start_request
|
|
|
+ self.session,
|
|
|
+ 'POST',
|
|
|
+ f'{self.config.sandbox.remote_runtime_api_url}/start',
|
|
|
+ json=start_request,
|
|
|
)
|
|
|
if response.status_code != 201:
|
|
|
raise RuntimeError(f'Failed to start sandbox: {response.text}')
|
|
|
@@ -215,7 +215,7 @@ class RemoteRuntime(Runtime):
|
|
|
response = send_request(
|
|
|
self.session,
|
|
|
'POST',
|
|
|
- f'{self.api_url}/stop',
|
|
|
+ f'{self.config.sandbox.remote_runtime_api_url}/stop',
|
|
|
json={'runtime_id': self.runtime_id},
|
|
|
)
|
|
|
if response.status_code != 200:
|