Loading...
Loading...
Manage the full lifecycle of Alibaba Cloud PAI DSW (Data Science Workshop) instances — create, update, query, list, start, stop, and look up ECS specs. Triggers: PAI DSW, DSW instance, create instance, start instance, stop instance, update instance, query instance, instance list, ECS spec, CreateInstance, UpdateInstance, GetInstance, ListInstances, StartInstance, StopInstance, ListEcsSpecs
npx skill4agent add aliyun/alibabacloud-aiops-skills alibabacloud-pai-dsw-managePAI Workspace + DSW Instance + ECS Spec + Image + VPC + Datasetpai-dsw/2022-01-01Pre-check: Aliyun CLI >= 3.3.1 requiredRunto verify the version is 3.3.1 or higher. If not installed or the version is too low, seealiyun versionfor installation instructions.references/cli-installation-guide.md[MUST] Then runto enable automatic plugin installation.aliyun configure set --auto-plugin-install true
# macOS (recommended)
brew install aliyun-cli
# Verify version
aliyun version
# Enable automatic plugin installation
aliyun configure set --auto-plugin-install true
# Install pai-dsw plugin
aliyun plugin install --names pai-dswPre-check: Alibaba Cloud Credentials RequiredSecurity Rules:
- NEVER read, echo, or print AK/SK values (e.g.,
is FORBIDDEN)echo $ALIBABA_CLOUD_ACCESS_KEY_ID- NEVER ask the user to input AK/SK directly in the conversation or command line
- NEVER use
with literal credential valuesaliyun configure set- ONLY use
to check credential statusaliyun configure listbashaliyun configure listCheck the output for a valid profile (AK, STS, or OAuth identity).If no valid profile exists, STOP here.
- Obtain credentials from Alibaba Cloud Console
- Configure credentials outside of this session (via
in a terminal or environment variables in a shell profile)aliyun configure- Return and retry after
shows a valid profilealiyun configure list
references/ram-policies.md[MUST] Permission Failure Handling: When any command or API call fails due to permission errors at any point during execution, follow this process:
- Read
to get the full list of permissions required by this skillreferences/ram-policies.md- Use the
skill to guide the user through requesting the necessary permissionsram-permission-diagnose- Pause and wait until the user confirms that the required permissions have been granted
IMPORTANT: Parameter Confirmation — Before executing any command or API call, ALL user-customizable parameters (e.g., RegionId, instance names, CIDR blocks, passwords, domain names, resource specifications, etc.) MUST be confirmed with the user. Do NOT assume or use default values without explicit user approval.
| Parameter | Required | Description | Default |
|---|---|---|---|
| Required | PAI workspace ID | None — user must provide |
| Required | Instance name (letters, digits, underscores only; max 27 chars) | None — user must provide |
| Required (post-paid) | ECS compute spec, e.g., | None |
| Mutually exclusive with | Image ID from PAI console | None |
| Mutually exclusive with | Container image URL. See | None |
| Required | Region, e.g., | None — user must confirm |
| Optional | Visibility scope: | |
| Required (update/get/start/stop) | Instance ID ( | None |
| Optional | VPC ID for private network access | None |
| Optional | VSwitch ID within the VPC | None |
| Optional | Security group ID | None |
| Required (spec query) | Accelerator type: | None — user must confirm |
| Optional | Dataset mounts in CLI list format: `DatasetId=<> MountPath=<> MountAccess=RO | RW` |
| Optional | CLI read timeout in seconds (for long-running operations) | |
| Optional | CLI connection timeout in seconds | |
How to get WorkspaceId: If the user doesn't know their workspace ID, run:bashaliyun aiworkspace list-workspaces --region <region> --user-agent AlibabaCloud-Agent-SkillsThis returns all workspaces the user has access to. Select the appropriate one based onor ask the user to confirm.WorkspaceNameReference: Create and Manage Workspaces
Full command syntax and parameter details:.references/related-commands.mdEveryCLI command must includealiyun.--user-agent AlibabaCloud-Agent-Skills
aliyun pai-dsw list-ecs-specs --accelerator-type <CPU|GPU> --region <region>[MUST] Region confirmation: Theparameter is required. Spec availability varies by region — always confirm the region with the user before querying.--region
[MUST] Determine accelerator type correctly:
- User mentions a spec name (e.g.,
): Query BOTH CPU and GPU types, then matchecs.hfc6.10xlargein results. Use the returnedInstanceTypefield to confirm the classification.AcceleratorType- User specifies image type: GPU image URL (contains
or-gpu-) → query GPU specs; CPU image URL → query CPU specs.cu- User describes use case only: GPU for 大模型训练/深度学习, CPU for 数据分析/轻量任务. Always confirm with user if ambiguous.
- [IMPORTANT] Do NOT guess from spec name prefix — the naming convention is unreliable. Always verify via API response.
[MUST] Choose accelerator type based on user requirements:
- Default recommendation: GPU for 大模型训练/深度学习, CPU for 数据分析/轻量任务
- Match image type (strong indicator): If user specifies a GPU image URL (contains
or-gpu-), query GPU specs. If CPU image, query CPU specs.cu- Spec name requires verification: If user mentions a spec name, query both types and find the match in results
- Always confirm with user before querying if the use case is ambiguous and no spec name is provided
InstanceTypeecs.hfc6.10xlargeAcceleratorTypeCPUGPUIsAvailabletrueSpotStockStatusWithStockNoStockCPUMemoryGPUGPUTypePrice[MUST] Availability check logic:
- For pay-as-you-go/subscription: Check
IsAvailable == true- For spot instances: Check
ANDIsAvailable == trueSpotStockStatus == "WithStock"- DO NOT use
alone to judge availability — many specs haveSpotStockStatusbutIsAvailable: trueSpotStockStatus: "NoStock"- Example:
withecs.hfc6.10xlarge→ Available for pay-as-you-goIsAvailable: true, SpotStockStatus: "NoStock"
[MUST] Idempotency guarantee: The CreateInstance API does not support ClientToken, so idempotency is ensured via a check-then-act pattern. Before creating, you must callto check if the name already exists.list-instances --instance-name <name>
aliyun pai-dsw list-instances \
--instance-name <name> \
--region <region> \
--resource-id ALL \
--user-agent AlibabaCloud-Agent-SkillsTotalCount == 0TotalCount >= 1InstancesInstanceNameinstance.InstanceName === targetNameInstanceIdget-instance --instance-id <id>EcsSpecImageUrlAccessibilityInstanceIdInstanceName === targetName[WARNING] Critical: Exact name match requiredThefilter may return partial matches. For example:--instance-name
- Query:
--instance-name llm_train_001- Response may include:
,llm_train_001,llm_train_001_v2llm_train_001_backupYou MUST verify exact match by checking:for instance in response.Instances: if instance.InstanceName == targetName: # EXACT string equality # Name already exists - DO NOT createDo NOT assume name is available just becausebut you "think" no exact match. IfTotalCount > 0, carefully check each instance's InstanceName field.TotalCount >= 1
aliyun pai-dsw create-instance--workspace-id--instance-name--ecs-spec--region--image-url--image-id[MUST] Region confirmation: Theparameter is required and must be confirmed with the user. Do NOT use CLI default region without explicit user approval. Spec availability and pricing vary by region.--region
[MUST] Match EcsSpec with image type:
- GPU image URL (contains
or-gpu-) → Must select a GPU spec (e.g.,cu)ecs.gn6v-c4g1.xlarge- CPU image URL (contains
) → Must select a CPU spec (e.g.,-cpu-)ecs.c6.large- The spec type MUST match the image type, otherwise the instance will fail to start
- Use case (大模型训练/数据分析) is only a recommendation, image type is the definitive indicator
Dataset mounting (optional): If the user specifies a dataset to mount, use theparameter in CLI list format:--datasetsbash--datasets DatasetId=<dataset-id> MountPath=<mount-path> MountAccess=RO[MUST] Dataset parameters require explicit user confirmation — do NOT assume or auto-generate dataset configurations.Official images:.references/common-images.mdAdvanced usage (VPC, datasets):.references/related-commands.md
{"InstanceId": "dsw-xxxxx", ...}[IMPORTANT] Return immediately after creation: Afterreturnscreate-instance, do NOT block waiting forInstanceIdstatus. Instead:Running
- Return the
and current status (InstanceId) to the user immediatelyCreating- Provide the user with a command to check status later:
bashaliyun pai-dsw get-instance --instance-id <instance-id> --user-agent AlibabaCloud-Agent-Skills- Inform the user that instance startup typically takes 2–5 minutes
Why this matters: Blocking polling prevents the agent from responding to other user requests. DSW instance creation is a long-running operation; the agent should return control to the user promptly.
aliyun pai-dsw list-instances--workspace-id--status--page-number--page-sizealiyun pai-dsw get-instance --instance-id <id>When to poll: Only poll when the user explicitly asks to wait for a status change (e.g., "wait until it's running"). Otherwise, return the current status immediately.Timeout limits: Maximum 60 polls (30 minutes total). If exceeded, stop and prompt user to check manually.Polling interval: 10–30 seconds between calls.CLI timeout: For long-running operations, increase read timeout:bashaliyun pai-dsw get-instance --instance-id <id> --read-timeout 30 --user-agent AlibabaCloud-Agent-SkillsOnce, access the instance viaStatus == "Running".InstanceUrlFor complete status transitions, see Instance Status Values in.references/related-commands.md
aliyun pai-dsw stop-instance --instance-id <id>Status transition:→Running→StoppingStoppedSave environment image: To save the environment as a custom image before stopping, use the PAI Console. See Create a DSW Instance Image for instructions.
aliyun pai-dsw update-instance --instance-id <id>--instance-name--ecs-spec--image-id--accessibility--datasets[MUST] Before updating:
- Call
to check current status and configurationget-instance- Check if update is needed:
- For
: Compare current--ecs-specwith target spec. If already equal, skip update and inform userEcsSpec- For
/--image-id: Compare current--image-url/ImageIdwith targetImageUrl- For
: Compare current--instance-namewith targetInstanceName- If already at target configuration, return current instance info — do not call update-instance
- If update is needed, use
to auto-start after update--start-instance true[IMPORTANT] Always update the specified instance by its. Do NOT substitute with another instance that already has the target spec — the user's request is to upgrade the specific instance, not to find an alternative.InstanceId
aliyun pai-dsw start-instance --instance-id <id>RunningPrerequisite: Instance must be inorStoppedstate. CallFailedto confirm before starting.get-instance
references/verification-method.mdget-instanceStatus == "Running"InstanceUrlThis skill does not expose instance deletion (irreversible operation — use the console).To stop incurring charges, stop the instance via Step 5 ().stop-instance
list-instances --instance-name <name>PRIVATEget-instance--resource-id ALLlist-instanceslist-ecs-specs| Document | Path |
|---|---|
| CLI Installation | |
| RAM Policies | |
| CLI Commands | |
| Verification | |
| Acceptance Criteria | |
| Common Images | |
| PAI DSW API Overview | help.aliyun.com |