Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/macos-x86-cpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: macos-x86-cpu
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
build:
name: macos-x86-cpu
runs-on: macos-latest
steps:
- name: cancel-previous-runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- run: brew install yasm
- run: cargo build
- run: cargo test
- uses: actions/setup-python@v2
with:
python-version: '3.8'
architecture: 'x64'
- run: cd flow-python && python3.8 setup.py install --user
- run: cd flow-python/examples && cargo run --example run_with_plugins -- -p logical_test
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# MegFlow

[![GitHub license](https://img.shields.io/badge/license-apache--2--Clause-brightgreen.svg)](./LICENSE)
[![ubuntu](https://img.shields.io/github/workflow/status/MegEngine/MegFlow/ubuntu-x86-cpu?label=ubuntu)](https://github.com/MegEngine/MegFlow/actions/workflows/ubuntu-x86-cpu.yml?query=workflow%3A)
[![macos](https://img.shields.io/github/workflow/status/MegEngine/MegFlow/ubuntu-x86-cpu?label=macos)](https://github.com/MegEngine/MegFlow/actions/workflows/macos-x86-cpu.yml?query=workflow%3A)

MegFlow 是一个面向视觉应用的流式计算框架, 目标是简单、高性能、帮助机器学习应用快速落地。

## Features
Expand Down
3 changes: 1 addition & 2 deletions docs/FAQ.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
Q:`error while loading shared libraries: libpython3.8.xxx`。

A:如果使用 conda 只需要

```bash
$ export LD_LIBRARY_PATH=/home/`whoami`/miniconda3/pkgs/python-3.8.11-h12debd9_0_cpython/lib:${LD_LIBRARY_PATH}`
$ export LD_LIBRARY_PATH=`conda info --base`/pkgs/python-3.8.11-xxx/lib:${LD_LIBRARY_PATH}
```
___
Q:`cargo run --example run_with_plugins -- -p logical_test ` 无法运行怎么办?
Expand Down
4 changes: 2 additions & 2 deletions docs/how-to-add-plugins.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

从一个最简单的例子开始
```
import pyflow
@pyflow.register(name="alias", inputs=["inp"], outputs=["out"])
import megflow
@megflow.register(name="alias", inputs=["inp"], outputs=["out"])
class Node:
def __init__(self, name, args):
pass
Expand Down
2 changes: 1 addition & 1 deletion docs/how-to-build-from-source.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ $ python3 setup.py install --user
**FAQ**:`error while loading shared libraries: libpython3.8.xxx`。如果使用 conda 只需要

```bash
$ export LD_LIBRARY_PATH=/home/`whoami`/miniconda3/pkgs/python-3.8.11-h12debd9_0_cpython/lib:${LD_LIBRARY_PATH}
$ export LD_LIBRARY_PATH=`conda info --base`/pkgs/python-3.8.11-xxx/lib:${LD_LIBRARY_PATH}
```

P.S. 默认 ffmpeg 依赖自动从 github 上拉取源码构建,这会使得首次构建的时间较长。若希望缩短首次构建时间,或者希望依赖一个指定版本的 ffmpeg,可以启用环境变量`CARGO_FEATURE_PREBUILD`并参考[rust-ffmpeg](https://github.com/zmwangx/rust-ffmpeg/wiki/Notes-on-building)自行构建
Expand Down
11 changes: 6 additions & 5 deletions docs/how-to-run-in-15-minutes.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ $ conda activate py38

从 [MegFlow release](https://github.com/MegEngine/MegFlow/releases) 下载对应 python 版本的 .whl 包,安装
```bash
$ python3 -m pip install pyflow-0.1.0-py38-none-linux_x86_64.whl --force-reinstall
$ python3 -m pip install megflow-0.1.0-py38-none-linux_x86_64.whl --force-reinstall
```

.whl 封装了 `pyflow`和 Rust 可执行文件 `run_with_plugins_python_wrap`。完成后应该可以运行
.whl 封装了 `megflow`和 Rust 可执行文件 `run_with_plugins_python_wrap`。完成后应该可以运行
```bash
$ run_with_plugins_python_wrap --help
run_with_plugins 1.0
Expand All @@ -46,7 +46,7 @@ $ python3
Python 3.8.3 (default, May 19 2020, 18:47:26)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyflow
>>> import megflow
```

**FAQ**:`error while loading shared libraries: libpython3.8.xxx`。如果使用 conda 只需要
Expand All @@ -56,7 +56,7 @@ $ export LD_LIBRARY_PATH=/home/`whoami`/miniconda3/pkgs/python-3.8.11-h12debd9_0

被封装的内容安装在 miniconda3 路径下,有兴趣不妨确认一下
```bash
$ cd ${HOME}/miniconda3/envs/py38/lib/python3.8/site-packages/pyflow/
$ cd ${HOME}/miniconda3/envs/py38/lib/python3.8/site-packages/megflow/
$ sudo apt install build-essential -y
$ ldd run_with_plugins # 可看到仅依赖常见库
$ ./run_with_plugins --help
Expand All @@ -73,7 +73,8 @@ $ cd ${MegFlow_PATH}/flow-python/examples
$ run_with_plugins_python_wrap -p logical_test
...
```
> 工作原理:[pyflow](../flow-python/pyflow/__init__.py) 仅是一层接口,由 run_with_plugins “注入”建图/调度/优化等实现。

> 工作原理:[megflow](../flow-python/megflow/__init__.py) 仅是一层接口,由 run_with_plugins “注入”建图/调度/优化等实现。

## Python Built-in Applications

Expand Down
2 changes: 1 addition & 1 deletion flow-python/examples/cat_finder/det.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#!/usr/bin/env python
# coding=utf-8

from pyflow import register
from megflow import register
from loguru import logger
from warehouse.detection_yolox import *
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion flow-python/examples/cat_finder/redis_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import base64
import numpy as np
from loguru import logger
from pyflow import register
from megflow import register

@register(inputs=['inp'], outputs=['out'])
class RedisProxy:
Expand Down
2 changes: 1 addition & 1 deletion flow-python/examples/cat_finder/reid_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import megengine as mge
import numpy as np
from loguru import logger
from pyflow import register
from megflow import register

from warehouse.reid_alignedreid import *
from warehouse.quality_naive import *
Expand Down
2 changes: 1 addition & 1 deletion flow-python/examples/cat_finder/reid_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import numpy as np
import megengine as mge
from loguru import logger
from pyflow import register
from megflow import register

from warehouse.reid_alignedreid import *
from warehouse.quality_naive import *
Expand Down
2 changes: 1 addition & 1 deletion flow-python/examples/cat_finder/shaper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#!/usr/bin/env python
# coding=utf-8

from pyflow import register
from megflow import register
from loguru import logger
from warehouse.quality_naive import Quality
import cv2
Expand Down
2 changes: 1 addition & 1 deletion flow-python/examples/cat_finder/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# coding=utf-8

from loguru import logger
from pyflow import register, Envelope
from megflow import register, Envelope

from warehouse.track_iou import Tracker
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion flow-python/examples/electric_bicycle/det.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import cv2
import numpy as np
from pyflow import register
from megflow import register
from loguru import logger
from warehouse.detection_memd import *

Expand Down
2 changes: 1 addition & 1 deletion flow-python/examples/electric_bicycle/redis_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import base64
import numpy as np
from loguru import logger
from pyflow import register
from megflow import register

@register(inputs=['inp'], outputs=['out'])
class RedisProxy:
Expand Down
2 changes: 1 addition & 1 deletion flow-python/examples/electric_bicycle/shaper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#!/usr/bin/env python
# coding=utf-8

from pyflow import register
from megflow import register
from loguru import logger
from warehouse.quality_naive import Quality
import cv2
Expand Down
2 changes: 1 addition & 1 deletion flow-python/examples/electric_bicycle/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# coding=utf-8

from loguru import logger
from pyflow import register, Envelope
from megflow import register, Envelope

from warehouse.track_iou import Tracker
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion flow-python/examples/logical_test/buffer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# coding=utf-8

from pyflow import res_register
from megflow import res_register

@res_register()
class Buffer:
Expand Down
2 changes: 1 addition & 1 deletion flow-python/examples/logical_test/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#!/usr/bin/env python
# coding=utf-8
from pyflow import register
from megflow import register

instance_id = 0

Expand Down
4 changes: 3 additions & 1 deletion flow-python/examples/logical_test/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

#!/usr/bin/env python
# coding=utf-8
from pyflow import register
from megflow import register
import multiprocessing as mp
from multiprocessing import Process, Pipe

def repeat(n, s, r):
Expand All @@ -31,6 +32,7 @@ def __init__(self, name, args):
self.send = s1
self.recv = r2

mp.set_start_method('fork')
self.p = Process(target=repeat, args=(10, s2, r1))
self.p.start()

Expand Down
2 changes: 1 addition & 1 deletion flow-python/examples/logical_test/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#!/usr/bin/env python
# coding=utf-8
from pyflow import register, Envelope, sleep
from megflow import register, Envelope, sleep

@register(outputs=['out'])
class Source:
Expand Down
12 changes: 6 additions & 6 deletions flow-python/gen_whl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ CONDA_BASE=$(conda info --base)
source $CONDA_BASE/etc/profile.d/conda.sh
conda activate py36
cargo build --example run_with_plugins --release
cp ../target/release/examples/run_with_plugins ./pyflow/run_with_plugins_inner
cp ../target/release/examples/run_with_plugins ./megflow/run_with_plugins_inner
rm -rf ./build
py='py36' python3 setup.py bdist_wheel -p linux-x86_64 -d py36_dist

conda activate py37
cargo build --example run_with_plugins --release
cp ../target/release/examples/run_with_plugins ./pyflow/run_with_plugins_inner
cp ../target/release/examples/run_with_plugins ./megflow/run_with_plugins_inner
rm -rf ./build
py='py37' python3 setup.py bdist_wheel -p linux-x86_64 -d py37_dist

conda activate py38
cargo build --example run_with_plugins --release
cp ../target/release/examples/run_with_plugins ./pyflow/run_with_plugins_inner
cp ../target/release/examples/run_with_plugins ./megflow/run_with_plugins_inner
rm -rf ./build
py='py38' python3 setup.py bdist_wheel -p linux-x86_64 -d py38_dist


rm -rf dist
mkdir dist
cp py36_dist/pyflow-0.1.0-py36-none-linux_x86_64.whl dist/
cp py37_dist/pyflow-0.1.0-py37-none-linux_x86_64.whl dist/
cp py38_dist/pyflow-0.1.0-py38-none-linux_x86_64.whl dist/
cp py36_dist/megflow-0.1.0-py36-none-linux_x86_64.whl dist/
cp py37_dist/megflow-0.1.0-py37-none-linux_x86_64.whl dist/
cp py38_dist/megflow-0.1.0-py38-none-linux_x86_64.whl dist/
rm -rf py36_dist py37_dist py38_dist
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
#!/usr/bin/env python
# coding=utf-8
import os
import sys
import subprocess
import pkg_resources


def main():
bin_exist = pkg_resources.resource_exists('pyflow', 'run_with_plugins')
bin_exist = pkg_resources.resource_exists('megflow', 'run_with_plugins_inner')
if not bin_exist:
print('cannot find run_with_plugins, exit!')
sys.exit(-1)
bin_path = pkg_resources.resource_filename('pyflow', 'run_with_plugins')
bin_path = pkg_resources.resource_filename('megflow', 'run_with_plugins_inner')

sys.argv[0] = bin_path
ret = subprocess.Popen(sys.argv)
ret.wait()


if __name__ == '__main__':
main()


File renamed without changes.
41 changes: 24 additions & 17 deletions flow-python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,27 @@

#!/usr/bin/env python
# coding=utf-8
from setuptools import setup, find_packages
from setuptools import setup
import sys
import os

devel_version = os.environ.get("DEVEL_VERSION")
if not devel_version:
devel_version = "0.1.0" # fall back

py_version = sys.version_info

if __name__ == '__main__':
py = os.getenv('py')
if py is None:
py = 'py{}{}'.format(sys.version_info[0], sys.version_info[1])
assert py.startswith('py3')
minor = int(py[-1])
setup(
options={'bdist_wheel':{'python_tag': py}},
name="pyflow",
version="0.1.0",
packages=["pyflow"],
options={
'bdist_wheel': {
'python_tag': "py{}{}".format(py_version.major,
py_version.minor),
}
},
name="megflow",
version=devel_version,
packages=["megflow"],
author="Megvii IPU-SDK Team",
author_email="megengine@megvii.com",
url="https://github.com/MegEngine/MegFlow",
Expand All @@ -35,7 +41,8 @@
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Programming Language :: Rust',
'Programming Language :: Python :: 3.{}'.format(minor),
'Programming Language :: Python :: {}.{}'.format(
py_version.major, py_version.minor),
'Topic :: Software Development :: Libraries :: Application Frameworks',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Mathematics',
Expand All @@ -44,12 +51,12 @@
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Python Modules',
],
python_requires='>=3.{},<3.{}'.format(minor, minor+1),
package_data={
"":['run_with_plugins_inner']
},
python_requires='>={}.{},<{}.{}'.format(py_version.major,
py_version.minor,
py_version.major,
py_version.minor + 1),
package_data={"": ['run_with_plugins_inner']},
entry_points={
'console_scripts':['run_with_plugins=pyflow.command_line:main'],
'console_scripts':['run_with_plugins=megflow.command_line:main'],
},
)

2 changes: 1 addition & 1 deletion flow-rs/src/loader/python/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use pyo3::{

static ERR_MSG: &str = "use after move";

#[pyclass(name = "Envelope", module = "pyflow")]
#[pyclass(name = "Envelope", module = "megflow")]
pub(crate) struct PyEnvelope {
pub imp: Option<Envelope<PyObject>>,
}
Expand Down
Loading