Skip to content

Commit baa8ac2

Browse files
committed
fix: change tos var to param-var and use it in code pipeline spec
- Reorder TOS_REGION parameter to appear after TOS_BUCKET_NAME in both template and build parameters - Remove Env flag from TOS_BUCKET_NAME and TOS_REGION in pipeline template definition - Update code-pipeline template to use dynamic parameters for bucket name and region - Add cp_pipeline_id and cp_pipeline_name to cloud launch type config clearing (cherry picked from commit 60df9f2a37a58ded3f0e9d06824b75e457c33539)
1 parent aaec572 commit baa8ac2

File tree

6 files changed

+19
-8
lines changed

6 files changed

+19
-8
lines changed

agentkit/toolkit/builders/ve_pipeline.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def build(self, config: VeCPCRBuilderConfig) -> BuildResult:
224224
if 'pipeline_id' in resources:
225225
builder_config.cp_pipeline_id = resources['pipeline_id']
226226

227-
error_msg = f"Build failed: {str(e)}"
227+
error_msg = str(e)
228228

229229
return BuildResult(
230230
success=False,
@@ -681,6 +681,8 @@ def _upload_to_tos(self, archive_path: str, config: VeCPCRBuilderConfig) -> str:
681681
except Exception as e:
682682
if "AccountDisable" in str(e):
683683
raise Exception(f"Tos Service is not enabled, please enable it in the console. Enable services at: https://console.volcengine.com/agentkit/region:agentkit+cn-beijing/auth")
684+
if "TooManyBuckets" in str(e):
685+
raise Exception(f"You have reached the maximum number of buckets allowed. Please delete some buckets and try again.")
684686
raise Exception(f"Failed to upload to TOS: {str(e)}")
685687

686688
def _prepare_cr_resources(self, config: VeCPCRBuilderConfig) -> CRServiceConfig:
@@ -939,10 +941,10 @@ def _prepare_pipeline_resources(self, config: VeCPCRBuilderConfig, tos_url: str,
939941
{"Key": "DOCKERFILE_PATH", "Value": "/workspace/agentkit-app/Dockerfile", "Dynamic": True, "Env": True},
940942
{"Key": "DOWNLOAD_PATH", "Value": "/workspace", "Dynamic": True, "Env": True},
941943
{"Key": "PROJECT_ROOT_DIR", "Value": "/workspace/agentkit-app", "Dynamic": True, "Env": True},
942-
{"Key": "TOS_BUCKET_NAME", "Value": "", "Dynamic": True, "Env": True},
944+
{"Key": "TOS_BUCKET_NAME", "Value": "", "Dynamic": True},
945+
{"Key": "TOS_REGION", "Value": "", "Dynamic": True},
943946
{"Key": "TOS_PROJECT_FILE_NAME", "Value": "", "Dynamic": True, "Env": True},
944947
{"Key": "TOS_PROJECT_FILE_PATH", "Value": "", "Dynamic": True, "Env": True},
945-
{"Key": "TOS_REGION", "Value": "", "Dynamic": True, "Env": True},
946948
{"Key": "CR_NAMESPACE", "Value": "", "Dynamic": True, "Env": True},
947949
{"Key": "CR_INSTANCE", "Value": "", "Dynamic": True, "Env": True},
948950
{"Key": "CR_DOMAIN", "Value": "", "Dynamic": True, "Env": True},
@@ -1032,9 +1034,9 @@ def download_and_show_logs(run_id: str):
10321034
# Prepare build parameters for pipeline execution
10331035
build_parameters = [
10341036
{"Key": "TOS_BUCKET_NAME", "Value": config.tos_bucket},
1037+
{"Key": "TOS_REGION", "Value": config.tos_region},
10351038
{"Key": "TOS_PROJECT_FILE_NAME", "Value": os.path.basename(config.tos_object_key)},
10361039
{"Key": "TOS_PROJECT_FILE_PATH", "Value": config.tos_object_key},
1037-
{"Key": "TOS_REGION", "Value": config.tos_region},
10381040
{"Key": "PROJECT_ROOT_DIR", "Value": f"/workspace/{agent_name}"},
10391041
{"Key": "DOWNLOAD_PATH", "Value": "/workspace"},
10401042
{"Key": "DOCKERFILE_PATH", "Value": f"/workspace/{agent_name}/Dockerfile"},

agentkit/toolkit/executors/base_executor.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,9 @@ def _clear_deploy_config(self, config, launch_type: str):
428428
strategy_config['runtime_apikey'] = ""
429429
strategy_config['runtime_apikey_name'] = AUTO_CREATE_VE
430430
strategy_config['runtime_role_name'] = AUTO_CREATE_VE
431+
if launch_type == 'cloud':
432+
strategy_config['cp_pipeline_id'] = ""
433+
strategy_config['cp_pipeline_name'] = ""
431434

432435
config.update_strategy_config(launch_type, strategy_config)
433436
self.logger.debug(f"Cleared deploy config for {launch_type}")

agentkit/toolkit/resources/templates/code-pipeline-tos-cr-step.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ stages:
1212
displayName: TOS 下载
1313
component: [email protected]/tos-download
1414
inputs:
15-
bucketName: {{ bucket_name }}
16-
bucketRegion: {{ bucket_region }}
15+
bucketName: $(parameters.TOS_BUCKET_NAME)
16+
bucketRegion: $(parameters.TOS_REGION)
1717
path: $TOS_PROJECT_FILE_PATH
1818
targetPath: $DOWNLOAD_PATH
1919
- step: step-c6

agentkit/toolkit/volcengine/services/cr_service.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ def is_quota_exceeded(error: Exception) -> bool:
6161
def is_already_exists(error: Exception) -> bool:
6262
return "AlreadyExists" in str(error)
6363

64+
@staticmethod
65+
def is_insufficient_balance(error: Exception) -> bool:
66+
return "Insufficient.Balance" in str(error)
67+
6468
@staticmethod
6569
def handle_auto_create_error(
6670
error: Exception,
@@ -81,6 +85,8 @@ def handle_auto_create_error(
8185
"""
8286
if CRErrorHandler.is_quota_exceeded(error):
8387
result.error = f"Failed to create CR {resource_type}: account quota exceeded. Please upgrade your account quota or clean up unused CR {resource_type}s."
88+
elif CRErrorHandler.is_insufficient_balance(error):
89+
result.error = f"Failed to create CR {resource_type}: insufficient balance. Please ensure that you have enough balance in your account to create a container registry instance."
8490
else:
8591
result.error = f"Failed to create CR {resource_type}: {str(error)}"
8692

agentkit/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
VERSION = "0.1.11"
15+
VERSION = "0.1.12"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "agentkit-sdk-python"
3-
version = "0.1.11"
3+
version = "0.1.12"
44
description = "Python SDK for transforming any AI agent into a production-ready application. Framework-agnostic primitives for runtime, memory, authentication, and tools with volcengine-managed infrastructure."
55
readme = "README.md"
66
requires-python = ">=3.10"

0 commit comments

Comments
 (0)