Files
沃巴蒂 ff22ed3a8b feat(deepdata): 引入修改密码、文件预览组件与清洗算子增强,deepflow 改名为 deep-flow
本次同步 09-12 至 09-28 的代码变更,主要内容:

新增功能
- 修改密码:后端新增 ChangePasswordRequest DTO 与UserController/UserService
  对应接口,前端新增 ChangePasswordDialog 并在 Header 接入入口
- 文件预览组件重构:file-preview 目录拆分出 VideoPreview(支持 blobUrl 直传)、
  ImagePreview、AudioPreview,index.tsx 统一调度各类型预览器
- 新增 my_ops 算子模块:markitdown_parser、mineru_pdf_parser、text_quality_evaluator
- 新增 tools/minio-file-server MinIO 文件服务

功能增强
- 数据清洗:cleaning_task_service/scheduler/routes 重构,
  data_juicer_executor 与 wrapper 增强,OperatorTable/LogsTable/TaskDetail 同步调整
- 数据标注:annotation sync.py、project.py 接口与schema 更新
- 数据采集、算子市场、首页与菜单路由相关页面调整
- DataJuicer 算子接入(useOperatorOperations、dj_ops_schema)

结构调整
- deepflow/ 更名为 deep-flow/(419 个文件重命名)
- 新增 helm 部署编排、GitHub Actions 之外的自建镜像构建脚本

未纳入本次提交
- scripts-backup/、runtime/python-executor-backup/、components_backup/(备份目录)
- *.backup*、__pycache__ 产物
- zh_core_web_sm-3.8.0-py3-none-any.whl(46MB 构建产物)
- DataX/(内嵌独立仓库,远程亦未收录其源码)
2026-10-03 22:44:56 +08:00

222 lines
5.2 KiB
Markdown

# Ray Executor
## Overview
Ray Executor is a Ray-based distributed execution framework responsible for executing data processing operators, task scheduling, and distributed computing.
## Architecture
```
runtime/python-executor/
└── deepdata/
├── core/
│ ├── base_op.py # BaseOp, Mapper, Filter, Slicer, LLM
│ ├── dataset.py # Dataset processing
│ └── constant.py # Constant definitions
├── scheduler/
│ ├── scheduler.py # TaskScheduler, Task, TaskStatus
│ ├── func_task_scheduler.py # Function task scheduling
│ └── cmd_task_scheduler.py # Command task scheduling
├── wrappers/
│ ├── executor.py # Ray executor entry point
│ ├── deepdata_wrapper.py # DeepData task wrapper
│ └── data_juicer_wrapper.py # DataJuicer integration
└── common/utils/ # Utility functions
├── bytes_transform.py
├── file_scanner.py
├── lazy_loader.py
└── text_splitter.py
```
## Components
### 1. Base Classes
#### BaseOp
Base class for all operators:
```python
class BaseOp:
def __init__(self, *args, **kwargs):
self.accelerator = kwargs.get('accelerator', "cpu")
self.text_key = kwargs.get('text_key', "text")
# ... other configuration
def execute(self, sample):
raise NotImplementedError
```
#### Mapper
Base class for data transformation operators (1:1):
```python
class Mapper(BaseOp):
def execute(self, sample: Dict) -> Dict:
# Transformation logic
return processed_sample
```
#### Filter
Base class for data filtering operators (returns bool):
```python
class Filter(BaseOp):
def execute(self, sample: Dict) -> bool:
# Filtering logic
return True # Keep or filter out
```
#### Slicer
Base class for data slicing operators (1:N):
```python
class Slicer(BaseOp):
def execute(self, sample: Dict) -> List[Dict]:
# Slicing logic
return [sample1, sample2, ...]
```
#### LLM
Base class for LLM operators:
```python
class LLM(Mapper):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.llm = self.get_llm(*args, **kwargs)
def build_llm_prompt(self, *args, **kwargs):
raise NotImplementedError
```
### 2. Task Scheduler
Async task scheduler:
```python
class TaskScheduler:
def __init__(self, max_concurrent: int = 10):
self.tasks: Dict[str, Task] = {}
self.semaphore = asyncio.Semaphore(max_concurrent)
async def submit(self, task_id, task, *args, **kwargs):
# Submit task
pass
def get_task_status(self, task_id: str) -> Optional[TaskResult]:
# Get task status
pass
def cancel_task(self, task_id: str) -> bool:
# Cancel task
pass
```
### 3. Operator Execution
#### Operator Registration
```python
from deepdata.core.base_op import OPERATORS
OPERATORS.register_module(
module_name='YourOperatorName',
module_path="ops.user.operator_package.process"
)
```
#### Execute Operator
```python
from deepdata.core.base_op import Mapper
class MyMapper(Mapper):
def execute(self, sample):
text = sample.get('text', '')
processed = text.upper()
sample['text'] = processed
return sample
```
## Quick Start
### Prerequisites
- Python 3.11+
- Ray 2.7.0+
- Poetry
### Installation
```bash
cd runtime/python-executor
poetry install
```
### Start Ray Head
```bash
ray start --head
```
### Start Ray Worker
```bash
ray start --head-address=<head-ip>:6379
```
## Usage
### Submit Task to Ray
```python
from ray import remote
@remote
def execute_operator(sample, operator_config):
# Execute operator logic
return result
# Submit task
result_ref = execute_operator.remote(sample, config)
result = ray.get(result_ref)
```
### Use Task Scheduler
```python
from deepdata.scheduler.scheduler import TaskScheduler
scheduler = TaskScheduler(max_concurrent=10)
task_id = "task-001"
scheduler.submit(task_id, my_function, arg1, arg2)
status = scheduler.get_task_status(task_id)
```
## Development
### Adding a New Operator
1. Create operator directory in `runtime/ops/`
2. Implement `process.py` and `__init__.py`
3. Register operator in `__init__.py`
4. Test the operator
### Debugging Operators
```bash
# Local test
python -c "from ops.user.operator_package.process import YourOperatorName; op = YourOperatorName(); print(op.execute({'text': 'test'}))"
```
## Performance
### Parallel Execution
Ray automatically handles parallel execution and resource allocation.
### Fault Tolerance
Ray provides automatic task retry and failover.
### Resource Management
Ray dynamically allocates CPU, GPU, and memory resources.
## Documentation
- [Ray Documentation](https://docs.ray.io/)
- [AGENTS.md](./AGENTS.md)
## Related Links
- [Runtime README](../README.md)
- [Operator Ecosystem](../ops/README.md)