From 4c42dfa7110bb17ffcd7dab4c478655ccdddfaa6 Mon Sep 17 00:00:00 2001 From: raf-be Date: Mon, 26 Aug 2024 16:00:09 +0200 Subject: [PATCH] Adds Flake8, Mypy and unittest exection workflow for Github. Signed-off-by: raf-be --- .github/workflows/linter.yml | 41 ++++++++++++++++++++++++++++++++++++ tests/test_decorators.py | 5 ++++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/linter.yml diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 0000000..912b717 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,41 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python Linter And Unittest + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.8 + uses: actions/setup-python@v5 + with: + python-version: "3.8" + - name: Install dependencies + # TODO: add Scaler as a test dependency once it's published to Pypi + run: | + python -m pip install --upgrade pip + pip install flake8 pyproject-flake8 mypy + pip install -r requirements.txt + pip install pandas dask distributed + - name: Lint with flake8 + run: | + pflake8 . + - name: Lint with MyPy + run: | + mypy . + - name: Run python unittest + run: | + python -m unittest discover -v tests diff --git a/tests/test_decorators.py b/tests/test_decorators.py index aeda338..4286dc0 100644 --- a/tests/test_decorators.py +++ b/tests/test_decorators.py @@ -13,7 +13,9 @@ from parfun.combine.collection import list_concat from parfun.combine.dataframe import df_concat from parfun.decorators import parfun -from parfun.entry_point import get_parallel_backend, set_parallel_backend, set_parallel_backend_context +from parfun.entry_point import ( + BACKEND_REGISTRY, get_parallel_backend, set_parallel_backend, set_parallel_backend_context +) from parfun.partition.api import per_argument from parfun.partition.collection import list_by_chunk from parfun.partition.dataframe import df_by_row @@ -101,6 +103,7 @@ def test_parallel_concurrent_generator(self): self.assertGreater(duration, expected_duration) self.assertAlmostEqual(duration, expected_duration, delta=expected_duration * 0.2) # within 20% of expected + @unittest.skipUnless("scaler_local" in BACKEND_REGISTRY, "Scaler backend not installed") def test_parallel_nested_calls(self): """Makes sure that the decorators handles nested parallel function calls."""