Skip to content

Commit 54bea1d

Browse files
committed
fix(sandbox): sandbox management api support passing config
Signed-off-by: Sodawyx <sodawyx@126.com>
1 parent a6c7e20 commit 54bea1d

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

agentrun/sandbox/api/__sandbox_data_async_template.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,22 +86,22 @@ async def create_sandbox_async(
8686
data["ossMountConfig"] = oss_mount_config
8787
if polar_fs_config is not None:
8888
data["polarFsConfig"] = polar_fs_config
89-
return await self.post_async("/", data=data)
89+
return await self.post_async("/", data=data, config=config)
9090

9191
async def delete_sandbox_async(
9292
self, sandbox_id: str, config: Optional[Config] = None
9393
):
9494
self.__refresh_access_token(sandbox_id=sandbox_id, config=config)
95-
return await self.delete_async("/")
95+
return await self.delete_async("/", config=config)
9696

9797
async def stop_sandbox_async(
9898
self, sandbox_id: str, config: Optional[Config] = None
9999
):
100100
self.__refresh_access_token(sandbox_id=sandbox_id, config=config)
101-
return await self.post_async("/stop")
101+
return await self.post_async("/stop", config=config)
102102

103103
async def get_sandbox_async(
104104
self, sandbox_id: str, config: Optional[Config] = None
105105
):
106106
self.__refresh_access_token(sandbox_id=sandbox_id, config=config)
107-
return await self.get_async("/")
107+
return await self.get_async("/", config=config)

agentrun/sandbox/api/sandbox_data.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ async def create_sandbox_async(
9999
data["ossMountConfig"] = oss_mount_config
100100
if polar_fs_config is not None:
101101
data["polarFsConfig"] = polar_fs_config
102-
return await self.post_async("/", data=data)
102+
return await self.post_async("/", data=data, config=config)
103103

104104
def create_sandbox(
105105
self,
@@ -121,34 +121,34 @@ def create_sandbox(
121121
data["ossMountConfig"] = oss_mount_config
122122
if polar_fs_config is not None:
123123
data["polarFsConfig"] = polar_fs_config
124-
return self.post("/", data=data)
124+
return self.post("/", data=data, config=config)
125125

126126
async def delete_sandbox_async(
127127
self, sandbox_id: str, config: Optional[Config] = None
128128
):
129129
self.__refresh_access_token(sandbox_id=sandbox_id, config=config)
130-
return await self.delete_async("/")
130+
return await self.delete_async("/", config=config)
131131

132132
def delete_sandbox(self, sandbox_id: str, config: Optional[Config] = None):
133133
self.__refresh_access_token(sandbox_id=sandbox_id, config=config)
134-
return self.delete("/")
134+
return self.delete("/", config=config)
135135

136136
async def stop_sandbox_async(
137137
self, sandbox_id: str, config: Optional[Config] = None
138138
):
139139
self.__refresh_access_token(sandbox_id=sandbox_id, config=config)
140-
return await self.post_async("/stop")
140+
return await self.post_async("/stop", config=config)
141141

142142
def stop_sandbox(self, sandbox_id: str, config: Optional[Config] = None):
143143
self.__refresh_access_token(sandbox_id=sandbox_id, config=config)
144-
return self.post("/stop")
144+
return self.post("/stop", config=config)
145145

146146
async def get_sandbox_async(
147147
self, sandbox_id: str, config: Optional[Config] = None
148148
):
149149
self.__refresh_access_token(sandbox_id=sandbox_id, config=config)
150-
return await self.get_async("/")
150+
return await self.get_async("/", config=config)
151151

152152
def get_sandbox(self, sandbox_id: str, config: Optional[Config] = None):
153153
self.__refresh_access_token(sandbox_id=sandbox_id, config=config)
154-
return self.get("/")
154+
return self.get("/", config=config)

agentrun/sandbox/client.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ async def stop_sandbox_async(
637637
"""
638638
try:
639639
result = await self.__sandbox_data_api.stop_sandbox_async(
640-
sandbox_id
640+
sandbox_id, config=config
641641
)
642642

643643
# 判断返回结果是否成功
@@ -676,7 +676,9 @@ def stop_sandbox(
676676
ServerError: 服务器错误
677677
"""
678678
try:
679-
result = self.__sandbox_data_api.stop_sandbox(sandbox_id)
679+
result = self.__sandbox_data_api.stop_sandbox(
680+
sandbox_id, config=config
681+
)
680682

681683
# 判断返回结果是否成功
682684
if result.get("code") != "SUCCESS":
@@ -715,7 +717,7 @@ async def delete_sandbox_async(
715717
"""
716718
try:
717719
result = await self.__sandbox_data_api.delete_sandbox_async(
718-
sandbox_id
720+
sandbox_id, config=config
719721
)
720722

721723
# 判断返回结果是否成功
@@ -754,7 +756,9 @@ def delete_sandbox(
754756
ServerError: 服务器错误
755757
"""
756758
try:
757-
result = self.__sandbox_data_api.delete_sandbox(sandbox_id)
759+
result = self.__sandbox_data_api.delete_sandbox(
760+
sandbox_id, config=config
761+
)
758762

759763
# 判断返回结果是否成功
760764
if result.get("code") != "SUCCESS":
@@ -794,7 +798,9 @@ async def get_sandbox_async(
794798
ServerError: 服务器错误
795799
"""
796800
try:
797-
result = await self.__sandbox_data_api.get_sandbox_async(sandbox_id)
801+
result = await self.__sandbox_data_api.get_sandbox_async(
802+
sandbox_id, config=config
803+
)
798804

799805
# 判断返回结果是否成功
800806
if result.get("code") != "SUCCESS":
@@ -834,7 +840,9 @@ def get_sandbox(
834840
ServerError: 服务器错误
835841
"""
836842
try:
837-
result = self.__sandbox_data_api.get_sandbox(sandbox_id)
843+
result = self.__sandbox_data_api.get_sandbox(
844+
sandbox_id, config=config
845+
)
838846

839847
# 判断返回结果是否成功
840848
if result.get("code") != "SUCCESS":

0 commit comments

Comments
 (0)