Metadata-Version: 2.4
Name: bizy-deploy
Version: 0.2.0
Summary: BizyAir FaaS automated deployment tool
Author-email: SiliconFlow <bizyair@siliconflow.cn>
License-Expression: MIT
Project-URL: Homepage, https://github.com/siliconflow/BizyDeploy
Project-URL: Repository, https://github.com/siliconflow/BizyDeploy
Project-URL: Issues, https://github.com/siliconflow/BizyDeploy/issues
Keywords: faas,deploy,siliconflow,bizyair
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Build Tools
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests
Requires-Dist: hydra-core
Requires-Dist: loguru
Requires-Dist: pyyaml
Provides-Extra: scripts
Requires-Dist: httpx; extra == "scripts"
Requires-Dist: pillow; extra == "scripts"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

## 安装
## 1. 安装（二选一）

```bash
# 公有仓库
pip install git+https://<TOKEN>@github.com/siliconflow/BizyDeploy.git
```

```bash
# 私有仓库
pip install git+ssh://git@github.com/siliconflow/BizyDeploy.git
```

## 使用

```bash
export SF_FAAS_TOKEN=xxxxx
```

### 场景1: 仅更新faas云函数部署 
```
bizy-deploy \
  pipeline=cgr_uat \
  service.sf_faas_token="$SF_FAAS_TOKEN" \
  ++env.function_id=fnjfvlqpdt \
  ++env.deployment_id=fdqd9p8te5 \
  ++func_def.spec.comment="upgrade"
```

### 场景2: 仅更新镜像版本 (最常用)

下面镜像对应云函数地址: https://cloud.siliconflow.cn/sft-d1s6t1r3jrms73f3ltpg/dedicated/functions/fnjfvlqpdt?tab=definition

命令行中的 ++func_def.spec.data 对应控制台“函数定义”中的 YAML 结构 

```bash
bizy-deploy \
  debug=false \
  pipeline=cgr_prod \
  service.sf_faas_token="$SF_FAAS_TOKEN" \
  ++env.function_id=fnjfvlqpdt \
  ++env.deployment_id=fdqd9p8te5 \
  ++func_def.spec.comment="update image to v20251222" \
  ++func_def.spec.data.cgrService.image="hub.6scloud.com/xxx/comfygridruntime:v20251222"
```

### 场景: 云函数模版相关操作

#### 获取 {org_id}/{template_id} 对应云函数模版
```bash
bizy-deploy \
  pipeline=faas_api_op \
  debug=true \
  ++pipeline.0.action='get_template' \
  ++pipeline.0.params.org_id=d1s6t1r3jrms73f3ltpg \
  ++pipeline.0.params.template_id=bizydraft-backend \
  service.sf_faas_token="$SF_FAAS_TOKEN"
```

### 场景4: 从源云函数上获取配置，修改指定参数后上传到目标云函数，并部署等待就绪

```bash
bizy-deploy \
  pipeline=cgr_uat \
  ++pipeline.0.params.function_id=fna5m4t5ky \
  ++env.function_id=fn1tioyopg \
  ++env.deployment_id=fdg8skissk \
  ++func_def.spec.data.comfyagentService.nodeRegisterConfigUrl="https://storage.bizyair.cn/config/comfyagent_node_config_chenchaonan.json" \
  ++func_def.spec.data.comfyuiService.image="hub.6scloud.com/d1s6t1r3jrms73f3ltpg/comfyui-gpu-torch2dot5:v202512241113-feature-add-plugins-default-a8dc7ab" \
  service.sf_faas_token="$SF_FAAS_TOKEN"
```
### 场景5: 得到一个函数的最新定义，创建一个新的定义，修改部署的参数后部署并等待就绪

```bash
bizy-deploy \
  pipeline=faas_api_op \
  ++pipeline.0.action='get_latest_function_definition' \
  ++pipeline.0.params.function_id=fn1tioyopg \
  ++pipeline.0.save_result_as='latest_func_def' \
  ++pipeline.1.action='create_function_definition' \
  ++pipeline.1.params.function_id=fn1tioyopg \
  ++pipeline.1.params.merged_def='${pipe.ctx:latest_func_def}' \
  ++pipeline.1.save_result_as="new_version" \
  ++pipeline.2.action='deploy' \
  ++pipeline.2.params.version='${pipe.ctx:new_version}' \
  ++pipeline.2.params.overrides.spec.siliconServices.0.minReplicas=2 \
  ++pipeline.2.params.overrides.spec.siliconServices.0.maxReplicas=5 \
  ++pipeline.2.params.function_id=fn1tioyopg \
  ++pipeline.2.params.deployment_id="fdg8skissk" \
  ++pipeline.3.action='wait_ready' \
  ++pipeline.3.params.function_id=fn1tioyopg \
  ++pipeline.3.params.deployment_id=fdg8skissk \
  service.sf_faas_token="$SF_FAAS_TOKEN"

```python
python scripts/save_template.py -tpl d1s6t1r3jrms73f3ltpg/bizydraft-backend 
```

<details open>
<summary> Output </summary>

```
✔ Template saved: d1s6t1r3jrms73f3ltpg/bizydraft-backend -> 
outputs/d1s6t1r3jrms73f3ltpg---bizydraft-backend.yaml
```

</details>


#### 更新模版

```bash
bizy-deploy \
  pipeline=faas_api_op \
  ++pipeline.0.action='update_template' \
  ++pipeline.0.params.name=<template_id> \
  ++pipeline.0.params.data.files=<TemplateYamlPath> \
  service.sf_faas_token="<SF_FAAS_TOKEN>"
```

#### 前端更新完成后清理缓存

```bash
# 通过环境变量设置使用
export BIZYAIR_TOKEN=sk-xxx     # 设置bizyair的token，必须
export SILICONFLOW_FASS_DEPLOY_DOMAIN=foo.bar:8192 # 设置内网域名，必须
export BIZYAIR_GROUP_ID=123 # 设置id（ https://console.bizyair.cn/comfy-draft/exclusive-instances 的实例组id），必须
./scripts/ready_instance.sh


# 通过位置参数使用
./scripts/ready_instance.sh sk-xxx foo.bar:8192 123   # 带参使用脚本，传参顺序：token，内网域名，id
```
