├── .coveragerc
├── .github
└── workflows
│ ├── pre-commit_hooks.yaml
│ └── test.yml
├── .gitignore
├── .pre-commit-config.yaml
├── .readthedocs.yml
├── .version
├── CONTRIBUTING.md
├── LICENSE.md
├── README.md
├── benchmark
└── test_benchmark.py
├── docs
├── Makefile
├── api.rst
├── cli.rst
├── conf.py
├── index.rst
├── influances.rst
├── license.rst
├── versions.rst
└── welcome.rst
├── mypy.ini
├── pyproject.toml
├── pytest.ini
├── setup.cfg
└── src
├── flupy
├── __init__.py
├── cli
│ ├── __init__.py
│ ├── cli.py
│ └── utils.py
├── fluent.py
└── py.typed
└── tests
├── test_cli.py
├── test_cli_utils.py
├── test_flu.py
└── test_version.py
/.coveragerc:
--------------------------------------------------------------------------------
1 | [report]
2 | exclude_lines =
3 | pragma: no cover
4 | if TYPE_CHECKING:
5 | raise AssertionError
6 | raise NotImplementedError
7 | @overload
8 | pass
9 |
--------------------------------------------------------------------------------
/.github/workflows/pre-commit_hooks.yaml:
--------------------------------------------------------------------------------
1 | name: pre-commit hooks
2 |
3 | on: [push]
4 |
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 |
9 | steps:
10 |
11 | - uses: actions/checkout@v1
12 |
13 | - name: python setup 3.9
14 | uses: actions/setup-python@v1
15 | with:
16 | python-version: '3.9'
17 |
18 | - name: Install Poetry
19 | uses: snok/install-poetry@v1
20 | with:
21 | version: 1.7.1
22 | virtualenvs-create: true
23 | virtualenvs-in-project: true
24 |
25 | - name: Install dependencies
26 | run: |
27 | poetry install --with dev
28 |
29 | - name: run tests
30 | run: |
31 | poetry run pre-commit run --all
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: tests
2 |
3 | on: [push]
4 |
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 |
9 | strategy:
10 | matrix:
11 | python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
12 |
13 | steps:
14 |
15 | - uses: actions/checkout@v1
16 |
17 | - name: python setup ${{ matrix.python-version }}
18 | uses: actions/setup-python@v1
19 | with:
20 | python-version: ${{ matrix.python-version }}
21 |
22 | - name: Install Poetry
23 | uses: snok/install-poetry@v1
24 | with:
25 | version: 1.7.1
26 | virtualenvs-create: true
27 | virtualenvs-in-project: true
28 |
29 | - name: Install dependencies
30 | run: |
31 | poetry install --with dev
32 |
33 | - name: run tests
34 | run: |
35 | poetry run pytest --cov=src/flupy src/tests --cov-report=xml
36 |
37 | - name: upload coverage to codecov
38 | uses: codecov/codecov-action@v1
39 | with:
40 | token: ${{ secrets.CODECOV_TOKEN }}
41 | file: ./coverage.xml
42 | flags: unittests
43 | name: codecov-umbrella
44 | fail_ci_if_error: true
45 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | docs/*
2 | # Temporary Python files
3 | *.pyc
4 | *.egg-info
5 | __pycache__
6 | .ipynb_checkpoints
7 |
8 | # pyenv
9 | .python-version
10 |
11 | .benchmarks
12 | poetry.lock
13 |
14 | pip-wheel-metadata/
15 |
16 | .vscode
17 |
18 | # Temporary OS files
19 | Icon*
20 |
21 | # Pytest cache
22 | .pytest_cache/*
23 |
24 | # Virtual environment
25 | venv/*
26 |
27 | # Temporary virtual environment files
28 | /.cache/
29 | /.venv/
30 |
31 | # Temporary server files
32 | .env
33 | *.pid
34 | *.swp
35 |
36 | # Generated documentation
37 | /docs/gen/
38 | /docs/apidocs/
39 | /docs/_build/
40 | /site/
41 | /*.html
42 | /*.rst
43 | /docs/*.png
44 |
45 | # Google Drive
46 | *.gdoc
47 | *.gsheet
48 | *.gslides
49 | *.gdraw
50 |
51 | # Testing and coverage results
52 | /.pytest/
53 | /.coverage
54 | /.coverage.*
55 | /htmlcov/
56 | /xmlreport/
57 | /pyunit.xml
58 | /tmp/
59 | *.tmp
60 |
61 | # Build and release directories
62 | /build/
63 | /dist/
64 | *.spec
65 |
66 | # Sublime Text
67 | *.sublime-workspace
68 |
69 | # Eclipse
70 | .settings
71 |
--------------------------------------------------------------------------------
/.pre-commit-config.yaml:
--------------------------------------------------------------------------------
1 | repos:
2 | - repo: https://github.com/pre-commit/mirrors-isort
3 | rev: v5.10.1
4 | hooks:
5 | - id: isort
6 | args: ['--multi-line=3', '--trailing-comma', '--force-grid-wrap=0', '--use-parentheses', '--line-width=88']
7 |
8 |
9 | - repo: https://github.com/pre-commit/pre-commit-hooks
10 | rev: v5.0.0
11 | hooks:
12 | - id: trailing-whitespace
13 | - id: check-added-large-files
14 | - id: check-yaml
15 | - id: mixed-line-ending
16 | args: ['--fix=lf']
17 |
18 | - repo: https://github.com/humitos/mirrors-autoflake.git
19 | rev: v1.1
20 | hooks:
21 | - id: autoflake
22 | args: ['--in-place', '--remove-all-unused-imports']
23 |
24 | - repo: https://github.com/psf/black
25 | rev: 25.1.0
26 | hooks:
27 | - id: black
28 | language_version: python3.9
29 |
30 | - repo: https://github.com/pre-commit/mirrors-mypy
31 | rev: v1.15.0
32 | hooks:
33 | - id: mypy
34 | files: flupy/
35 | args: ["--config-file", "mypy.ini"]
36 |
37 |
--------------------------------------------------------------------------------
/.readthedocs.yml:
--------------------------------------------------------------------------------
1 | build:
2 | image: latest
3 | python:
4 | version: 3.8
5 | setup_py_install: true
6 |
--------------------------------------------------------------------------------
/.version:
--------------------------------------------------------------------------------
1 | 1.0.11
2 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # For Contributors
2 |
3 | ## Setup
4 |
5 | ### Requirements
6 |
7 | * Make:
8 | * Windows: http://mingw.org/download/installer
9 | * Mac: http://developer.apple.com/xcode
10 | * Linux: http://www.gnu.org/software/make
11 | * pipenv: http://docs.pipenv.org
12 | * Pandoc: http://johnmacfarlane.net/pandoc/installing.html
13 | * Graphviz: http://www.graphviz.org/Download.php
14 |
15 | To confirm these system dependencies are configured correctly:
16 |
17 | ```sh
18 | $ make doctor
19 | ```
20 |
21 | ### Installation
22 |
23 | Install project dependencies into a virtual environment:
24 |
25 | ```sh
26 | $ make install
27 | ```
28 |
29 | ## Development Tasks
30 |
31 | ### Testing
32 |
33 | Manually run the tests:
34 |
35 | ```sh
36 | $ make test
37 | ```
38 |
39 | or keep them running on change:
40 |
41 | ```sh
42 | $ make watch
43 | ```
44 |
45 | > In order to have OS X notifications, `brew install terminal-notifier`.
46 |
47 | ### Documentation
48 |
49 | Build the documentation:
50 |
51 | ```sh
52 | $ make docs
53 | ```
54 |
55 | ### Static Analysis
56 |
57 | Run linters and static analyzers:
58 |
59 | ```sh
60 | $ make pylint
61 | $ make pycodestyle
62 | $ make pydocstyle
63 | $ make check # includes all checks
64 | ```
65 |
66 | ## Continuous Integration
67 |
68 | The CI server will report overall build status:
69 |
70 | ```sh
71 | $ make ci
72 | ```
73 |
74 | ## Release Tasks
75 |
76 | Release to PyPI:
77 |
78 | ```sh
79 | $ make upload
80 | ```
81 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | # License
2 |
3 | **The MIT License (MIT)**
4 |
5 | Copyright © 2017, Oliver Rice
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # flupy
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | ---
20 |
21 | **Documentation**: https://flupy.readthedocs.io/en/latest/
22 |
23 | **Source Code**: https://github.com/olirice/flupy
24 |
25 | ---
26 |
27 | ## Overview
28 | Flupy implements a [fluent interface](https://en.wikipedia.org/wiki/Fluent_interface) for operating on python iterables. All flupy methods return generators and are evaluated lazily. This allows expressions to transform arbitrary size data in extremely limited memory.
29 |
30 | You can think of flupy as a light weight, 0 dependency, pure python alternative to the excellent [Apache Spark](https://spark.apache.org/) project.
31 |
32 | ## Setup
33 |
34 | ### Requirements
35 |
36 | * Python 3.6+
37 |
38 | ### Installation
39 |
40 | Install flupy with pip:
41 | ```sh
42 | $ pip install flupy
43 | ```
44 |
45 | ### Library
46 | ```python
47 | from itertools import count
48 | from flupy import flu
49 |
50 | # Processing an infinite sequence in constant memory
51 | pipeline = (
52 | flu(count())
53 | .map(lambda x: x**2)
54 | .filter(lambda x: x % 517 == 0)
55 | .chunk(5)
56 | .take(3)
57 | )
58 |
59 | for item in pipeline:
60 | print(item)
61 |
62 | # Returns:
63 | # [0, 267289, 1069156, 2405601, 4276624]
64 | # [6682225, 9622404, 13097161, 17106496, 21650409]
65 | # [26728900, 32341969, 38489616, 45171841, 52388644]
66 | ```
67 |
68 | ### CLI
69 | The flupy command line interface brings the same syntax for lazy piplines to your shell. Inputs to the `flu` command are auto-populated into a `Fluent` context named `_`.
70 | ````
71 | $ flu -h
72 | usage: flu [-h] [-f FILE] [-i [IMPORT [IMPORT ...]]] command
73 |
74 | flupy: a fluent interface for python
75 |
76 | positional arguments:
77 | command flupy command to execute on input
78 |
79 | optional arguments:
80 | -h, --help show this help message and exit
81 | -f FILE, --file FILE path to input file
82 | -i [IMPORT [IMPORT ...]], --import [IMPORT [IMPORT ...]]
83 | modules to import
84 | Syntax: :