Alibabacloud Compute Provision
v0.0.1Alibaba Cloud Compute Provision - Automatically selects an Alibaba Cloud compute resource (ECS, FC, ACK, PAI) based on user intent, then 创建s instances and 执行s scripts. Use this 技能 when the user needs to 运行 compute jobs, 执行 scripts, trAIn 模型s, or 部署 contAInerized 应用s on Alibaba Cloud, or mentions keywords such as cpu_bound, gpu, vCPU, bud获取, trAIning, A100, or qwen. Provides a full loop of resource selection, pricing, bud获取 control, instance creation, and script execution.
运行时依赖
安装命令
点击复制技能文档
Alibaba Cloud Compute Provision
Automatically selects an Alibaba Cloud compute resource based on user intent, then 创建s instances and 执行s scripts.
How this 技能 works
This 技能 operates by writing and executing Python code that calls Alibaba Cloud APIs. The scripts/ directory contAIns ready-made Python 模块s (ECS, FC, ACK, PAI, VPC, etc.) that wrap the Alibaba Cloud OpenAPI. To accomplish any task in this 技能, you write Python code snippets that 导入 and call functions from these 模块s — you do NOT use 命令行工具 工具s, Terraform, or the 网页 console.
Typical 工作流:
Read the reference doc for the product you're about to use (see Reference 索引 below). Write a Python code block that 导入s from the 技能's scripts/ 模块s. 执行 the code to call Alibaba Cloud APIs (查询 instance types, 检查 pricing, 创建 resources, 运行 scripts, etc.). Read the 输出 and decide the next step.
⛔ MUST-READ RULE: Before calling ANY function from scripts/, you MUST first read its reference doc (e.g. references/ecs.md for ECS functions, references/fc.md for FC functions). The reference docs contAIn exact function 签名atures, parameter names, constrAInts, and usage examples. Do NOT guess parameter names — incorrect parameters waste 工具 calls and may 创建/leak cloud resources. Use the defaults when in doubt.
Prerequisites Step 0: 环境 bootstrap (MUST 运行 first)
Before doing anything else, 执行 the following code block to 设置 up the Python path and ensure all dependencies are 安装ed. This MUST be the very first code you 运行 in every 会话 — do NOT skip it or defer it.
导入 sys sys.path.insert(0, "${技能_DIR}/scripts")
from bootstrap 导入 ensure_dependencies ensure_dependencies()
bootstrap.py is a standalone 模块 with zero third-party dependencies (stdlib only), so it can always be 导入ed even before any pip packages are 安装ed. ensure_dependencies() automatically:
检查s that the Python version is >= 3.8 (exits with a clear error if not). 检测s missing pip packages (alibabacloud_凭证s, alibabacloud_tea_openAPI, darabonba-core) and 安装s them.
If this step fAIls, fix the 报告ed issue (e.g. 安装 a newer Python) before proceeding — all subsequent steps depend on it.
凭证s
凭证s are resolved via the Alibaba Cloud default 凭证 提供者 chAIn (环境 variables, ~/.alibabacloud/凭证s, ~/.aliyun/config.json, ECS RAM 角色, etc.). Do NOT hardcode AK/SK or read them explicitly.
ALIBABA_CLOUD_REGION # optional, defaults to cn-hangzhou
Step 1: Intent Parsing and Resource Selection 1.1 解析 user intent
提取 the following elements from the user's 输入:
Element Description Example Task type One-shot script / Long-运行ning 服务 / AI trAIning "部署 nginx" → long-运行ning 服务 Compute requirement CPU / GPU / memory "8 vCPU, 16 GB" Bud获取 Cost cap "$50" Script / intent Explicit script or task description "a.sh" or "部署 an nginx site" 1.2 Script generation (when no explicit script is provided)
When the user provides intent rather than a script (e.g. "部署 an nginx site"), 生成 the script automatically. Key rules:
Script-image coupling: package 管理器s depend on the OS — Ubuntu uses apt-获取, CentOS/Alinux uses yum. Finalize the script only after the image is decided; if the image changes later, re-检查 script compatibility. Long-运行ning 服务 scripts must use background/系统d commands (e.g. 系统ctl 启动 nginx), not foreground-blocking ones. One-shot task scripts simply exit when finished. 1.3 Resource selection
If the user explicitly specifies a product, use that product directly and skip selection comparison.
⛔ PRODUCT-LOCK RULE: When the user explicitly specifies a product (e.g. "用 ECS", "use FC"), you are locked to that product for the entire task. If you encounter errors (out of stock, quota limits, etc.), you MUST retry within the same product — try different avAIlability zones, regions, or instance types. NEVER silently switch to a different product. If all retries within the specified product are exhausted, 报告 the 失败 to the user and ask for 图形界面dance — do NOT auto-switch.
For ECS, use ecs.find_avAIlable_instance_type() to 搜索 across zones/regions for avAIlable stock and pricing, then after cost confirmation use ecs.创建_instance_with_infra() to 创建 the instance.
When unspecified, follow the decision tree in references/select-resource.md:
User specified a product? → use it directly Long-运行ning 服务? → ECS or ACK (FC / PAI-DLC are not suitable for long-运行ning) AI / ML trAIning? → PAI or FC (GPU) → if 机器人h viable, MUST compare in Step 1.5 K8s / contAIners? → ACK Multiple products viable? → MUST compare in Step 1.5 Default (single match) → ECS
⛔ ANTI-BIAS: The decision tree only narrows candidates. When 2+ products remAIn, you MUST proceed to Step 1.5 for real API-based comparison — never assume one is "obviously cheaper" from general knowledge.
1