#process #parallel #data-processing #data

processing_chain

Rust 库,用于设置大量数据处理链

5 个版本

0.2.2 2022年11月27日
0.2.1 2022年11月20日
0.2.0 2022年11月12日
0.1.1 2022年9月4日
0.1.0 2022年9月4日

#1093 in 数据结构

MIT 许可证

16KB
324

processing-chain

processing-chain 提供了一种方便的方式来无缝设置大量数据处理的链。

请阅读 docs.rs 上的 API 文档 或查看 示例

processing-chain 基于 Item 的概念,这是一个用于并行启动所有进程的抽象。用户只需定义

  • 要处理的 Item
  • 处理单个 Item 的函数

processing-chain 将通过并行化在整个 Item 上启动进程。用户还可以提供一些额外的处理配置信息(例如,覆盖)。

亮点

  • 设置通用数据处理链

定义 Items

使用 JSON 文件

[
    {
        "name": "item_1",
        "input_item_paths": ["test_1.npy", "test_2.npy", "test_2.npy"],
        "output_item_paths": ["output_1.nc"]
    },
    {
        "name": "item_2",
        "input_item_paths": ["test_1.npy", "test_2.npy"],
        "output_item_paths": ["output_2.nc"]
    },
    {
        "name": "item_3",
        "input_item_paths": ["test_6.npy", "test_7.npy", "test_8.npy"],
        "output_item_paths": ["output_3.nc"]
    }
]

编写 _process_item 函数

在 rust 中

fn _process_item(item: &Item) -> Result<bool> {
    // define how to process a single item
    println!(
        "Processing {} {:?} -> {:?}",
        item.name, item.input_item_path, item.output_item_path
    );
    // ...

    Ok(true)
}

如果你的函数是用 Python 编写的,你不想(现在)将其转换为 Rust,可以使用 inline-python 包。

use inline_python::python;

fn _process_item(item: &Item) -> Result<bool> {
    // define how to process a single item
    python! {
        print("Processing {} {} -> {}".format('item.name, item.input_item_path, item.output_item_path))
	};
    // ...

    Ok(true)
}

一些示例可以在 这里 找到。

依赖

~6–15MB
~186K SLoC