Metadata-Version: 2.5
Name: flowdeck
Version: 0.2.3
Summary: APScheduler 的现代化前台：FastAPI + Vue3，plombery 的完美替代（兼容其 Python API）
Project-URL: Repository, https://github.com/tianshang486/flowdeck
Project-URL: Issues, https://github.com/tianshang486/flowdeck/issues
Author-email: zyxc <1426094384@qq.com>
License: MPL-2.0
License-File: LICENSE
Keywords: apscheduler,dashboard,etl,fastapi,pipeline,scheduler,task,workflow
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
Classifier: Operating System :: OS Independent
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 :: Libraries :: Application Frameworks
Classifier: Topic :: System :: Monitoring
Requires-Python: >=3.10
Requires-Dist: apscheduler<4.0,>=3.11.0
Requires-Dist: fastapi>=0.115.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: pillow>=10.0
Requires-Dist: pydantic-settings>=2.3
Requires-Dist: pydantic>=2.7
Requires-Dist: pyyaml>=6.0
Requires-Dist: sqlalchemy>=2.0
Requires-Dist: uvicorn>=0.30.0
Requires-Dist: websockets>=12.0
Provides-Extra: mssql
Requires-Dist: pyodbc>=5.0; extra == 'mssql'
Provides-Extra: mysql
Requires-Dist: pymysql>=1.1; extra == 'mysql'
Provides-Extra: postgres
Requires-Dist: psycopg[binary]>=3.1; extra == 'postgres'
Description-Content-Type: text/markdown

# FlowDeck

**现代化 Python 任务调度框架**：APScheduler 的 Web 控制台，[plombery](https://github.com/lucoelho/plombery) 的完美替代（兼容其 Python API）。

[中文](#中文) | [English](#english)

---

<a id="中文"></a>

## 中文

代码即配置的 Python 调度框架。FastAPI + Vue3，Web 控制台已内置在 Python 包中——无需 Node 环境，`pip install` 后开箱即用。

### 界面预览

| 总览 | 流水线 |
|---|---|
| ![总览](https://raw.githubusercontent.com/tianshang486/flowdeck/master/docs/screenshots/dashboard.jpg) | ![流水线](https://raw.githubusercontent.com/tianshang486/flowdeck/master/docs/screenshots/pipelines.jpg) |
| **任务配置** | **通知规则** |
| ![任务配置](https://raw.githubusercontent.com/tianshang486/flowdeck/master/docs/screenshots/ui-tasks.jpg) | ![通知规则](https://raw.githubusercontent.com/tianshang486/flowdeck/master/docs/screenshots/notifications.jpg) |

### 核心能力

- **代码即配置**：`@task` 定义任务、`register_pipeline(...)` 注册流水线，Cron / Interval 触发器随代码声明
- **Web 控制台**：仪表盘、流水线管理、实时日志终端、运行统计图表、停机日历、通知规则管理，全部内置
- **界面配置任务**：SQL / 存储过程任务直接在 Web 上编写，保存即热注册进调度器（免重启）
- **补数与重跑**：指定历史日期区间逐日回填（`${data_date}` 自动覆盖）；失败 run 一键重跑整条或从失败任务断点续跑
- **暂停留痕**：UI 暂停后定时触发记为 SKIPPED（有迹可查），手动触发不受影响，重启后状态保持
- **停机日历**：节假日 / 维护窗口按日期区间自动跳过定时触发，手动运行与补数不受影响
- **失败告警**：failed / succeeded / timeout / missed / skipped / alert 六类事件推送到 webhook（企业微信模板开箱即用，任务结果表格可转图片直发企微）
- **漏跑巡检**：每小时自动对比「预期触发数 vs 实际运行数」，漏跑即告警
- **本地时间**：日志与数据库统一使用本地时区（根修 plombery 的 UTC 缺陷）

### 安装

```bash
pip install flowdeck
```

数据库驱动按需安装（包本体不预装任何驱动）：

```bash
pip install "flowdeck[postgres]"   # psycopg[binary]
pip install "flowdeck[mssql]"      # pyodbc（还需系统级 ODBC Driver）
pip install "flowdeck[mysql]"      # pymysql
```

要求 Python >= 3.10。

### 快速开始

**验证安装（纯控制台模式）**

```bash
flowdeck                     # 默认 127.0.0.1:8655
flowdeck --host 0.0.0.0 --port 9000
```

启动后访问 http://127.0.0.1:8655（API 文档见 `/docs`）。

> `flowdeck` 命令只启动「控制台 + 调度器」，不加载业务流水线，适合验证安装、查看历史运行数据、管理通知规则。

**编写流水线**

```python
from pydantic import BaseModel
from flowdeck import task, register_pipeline, Trigger

class ReportParams(BaseModel):
    data_date: str

@task
def extract(params: ReportParams):
    return {"rows": 100}

@task
def load(params: ReportParams, ctx):
    rows = ctx.get_upstream_output("extract")["rows"]
    ctx.logger.info(f"入库 {rows} 行")

register_pipeline(
    id="daily_report",
    name="日报",
    tasks=[extract, load],
    params=ReportParams,
    triggers=[Trigger(cron="0 8 * * *")],
)
```

入口文件末尾启动：

```python
from flowdeck.cli import main
main()
```

运行入口文件即拥有 Web 控制台（http://127.0.0.1:8655）+ 调度器 + 你的全部流水线。

### 与 plombery 的关系

FlowDeck 兼容 plombery 的 Python API（`register_pipeline` / `@task` / `Trigger` 签名一致），并在此基础上扩展了超时控制、并发策略（`parallel` / `skip` / `cancel_previous`）、通知规则、停机日历、补数回填等能力，可直接替换。

---

<a id="english"></a>

## English

A configuration-as-code Python scheduling framework. FastAPI + Vue3, with the web console embedded in the Python package — no Node.js required, ready to use right after `pip install`.

### Screenshots

| Dashboard | Pipelines |
|---|---|
| ![Dashboard](https://raw.githubusercontent.com/tianshang486/flowdeck/master/docs/screenshots/dashboard.jpg) | ![Pipelines](https://raw.githubusercontent.com/tianshang486/flowdeck/master/docs/screenshots/pipelines.jpg) |
| **UI-configured Tasks** | **Notification Rules** |
| ![UI Tasks](https://raw.githubusercontent.com/tianshang486/flowdeck/master/docs/screenshots/ui-tasks.jpg) | ![Notifications](https://raw.githubusercontent.com/tianshang486/flowdeck/master/docs/screenshots/notifications.jpg) |

### Key Features

- **Code as configuration**: define tasks with `@task`, register pipelines with `register_pipeline(...)`, declare Cron / Interval triggers in code
- **Web console**: dashboard, pipeline management, real-time log terminal, run statistics charts, downtime calendar, notification rules — all built in
- **Configure tasks in the UI**: write SQL / stored-procedure tasks directly on the web page; saving hot-registers them into the scheduler (no restart)
- **Backfill & rerun**: backfill a historical date range day by day (`${data_date}` is overridden automatically); rerun a failed run entirely or resume from the failed task
- **Pause with audit trail**: pausing from the UI marks scheduled triggers as SKIPPED (traceable); manual triggers are unaffected; state survives restarts
- **Downtime calendar**: skip scheduled triggers for holidays / maintenance windows by date range (all pipelines or selected ones); manual runs and backfills are unaffected
- **Alerting**: six event types (failed / succeeded / timeout / missed / skipped / alert) pushed to webhooks (WeCom template out of the box; task result tables can be rendered as images and sent directly to WeCom)
- **Missed-run patrol**: hourly comparison of expected vs actual trigger counts, alerting on any miss
- **Local time**: logs and database use the local timezone (fixing plombery's UTC flaw at the root)

### Installation

```bash
pip install flowdeck
```

Install database drivers as needed (the package itself ships none):

```bash
pip install "flowdeck[postgres]"   # psycopg[binary]
pip install "flowdeck[mssql]"      # pyodbc (also requires a system ODBC Driver)
pip install "flowdeck[mysql]"      # pymysql
```

Requires Python >= 3.10.

### Quick Start

**Verify the installation (console-only mode)**

```bash
flowdeck                     # defaults to 127.0.0.1:8655
flowdeck --host 0.0.0.0 --port 9000
```

Then open http://127.0.0.1:8655 (API docs at `/docs`).

> The `flowdeck` command starts only the console + scheduler without any business pipelines — ideal for verifying the installation, browsing historical runs, and managing notification rules.

**Writing pipelines**

```python
from pydantic import BaseModel
from flowdeck import task, register_pipeline, Trigger

class ReportParams(BaseModel):
    data_date: str

@task
def extract(params: ReportParams):
    return {"rows": 100}

@task
def load(params: ReportParams, ctx):
    rows = ctx.get_upstream_output("extract")["rows"]
    ctx.logger.info(f"Loaded {rows} rows")

register_pipeline(
    id="daily_report",
    name="Daily Report",
    tasks=[extract, load],
    params=ReportParams,
    triggers=[Trigger(cron="0 8 * * *")],
)
```

Start at the end of your entry file:

```python
from flowdeck.cli import main
main()
```

Running the entry file gives you the web console (http://127.0.0.1:8655) + scheduler + all your pipelines.

### Relation to plombery

FlowDeck is API-compatible with plombery (`register_pipeline` / `@task` / `Trigger` signatures are identical) and extends it with timeout control, concurrency strategies (`parallel` / `skip` / `cancel_previous`), notification rules, a downtime calendar, and backfilling — a drop-in replacement.

---

## License / 许可证

[MPL-2.0](LICENSE). Commercial use is permitted; modifications to this project's source files must be made available under MPL-2.0 with changes marked. / 允许商业使用；对本项目源码文件的修改必须以 MPL-2.0 开源并标注改动。
