From 0e16c4cf63bf7f8742e636dd350384d99f86909c Mon Sep 17 00:00:00 2001 From: Jayaram Kancherla Date: Fri, 20 Dec 2024 12:03:31 -0800 Subject: [PATCH] chore: remove Python 3.8 support (#11) --- .github/workflows/pypi-publish.yml | 75 ++++++++++--------- .github/workflows/pypi-test.yml | 47 +++++------- .pre-commit-config.yaml | 15 ++-- CHANGELOG.md | 11 ++- docs/conf.py | 3 - pyproject.toml | 4 + setup.cfg | 2 +- src/genomicarrays/GenomicArrayDataset.py | 12 ++- src/genomicarrays/GenomicArrayDatasetSlice.py | 17 ++++- src/genomicarrays/build_genomicarray.py | 41 +++------- src/genomicarrays/dataloader.py | 4 +- 11 files changed, 113 insertions(+), 118 deletions(-) diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml index 105941c..29657bb 100644 --- a/.github/workflows/pypi-publish.yml +++ b/.github/workflows/pypi-publish.yml @@ -9,43 +9,44 @@ on: jobs: build: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Set up Python 3.9 - uses: actions/setup-python@v5 - with: - python-version: 3.9 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest tox - # - name: Lint with flake8 - # run: | - # # stop the build if there are Python syntax errors or undefined names - # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - # # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with tox - run: | - tox - - name: Build docs - run: | - tox -e docs - - run: touch ./docs/_build/html/.nojekyll - - name: GH Pages Deployment - uses: JamesIves/github-pages-deploy-action@4.1.3 - with: - branch: gh-pages # The branch the action should deploy to. - folder: ./docs/_build/html - clean: true # Automatically remove deleted files from the deploy branch - - name: Build Project and Publish - run: | - python -m tox -e clean,build - - name: Publish package - uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 - with: - user: __token__ - password: ${{ secrets.PYPI_PASSWORD }} + - uses: actions/checkout@v4 + + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: 3.11 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox + + - name: Test with tox + run: | + tox + + - name: Build docs + run: | + tox -e docs + + - run: touch ./docs/_build/html/.nojekyll + + - name: GH Pages Deployment + uses: JamesIves/github-pages-deploy-action@v4 + with: + branch: gh-pages # The branch the action should deploy to. + folder: ./docs/_build/html + clean: true # Automatically remove deleted files from the deploy branch + + - name: Build Project and Publish + run: | + python -m tox -e clean,build + + - name: Publish package + uses: pypa/gh-action-pypi-publish@v1.12.2 + with: + user: __token__ + password: ${{ secrets.PYPI_PASSWORD }} diff --git a/.github/workflows/pypi-test.yml b/.github/workflows/pypi-test.yml index 03e64f8..90aa16a 100644 --- a/.github/workflows/pypi-test.yml +++ b/.github/workflows/pypi-test.yml @@ -1,40 +1,33 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: Test the library +name: Run tests on: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] jobs: build: - runs-on: ubuntu-latest strategy: matrix: - python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] name: Python ${{ matrix.python-version }} steps: - - uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest tox - # - name: Lint with flake8 - # run: | - # # stop the build if there are Python syntax errors or undefined names - # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - # # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with tox - run: | - tox + - uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: "pip" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox + + - name: Test with tox + run: | + tox diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b97703f..e60a5f4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,13 +17,13 @@ repos: - id: mixed-line-ending args: ['--fix=auto'] # replace 'auto' with 'lf' to enforce Linux/Mac line endings or 'crlf' for Windows -- repo: https://github.com/PyCQA/docformatter - rev: eb1df347edd128b30cd3368dddc3aa65edcfac38 - hooks: - - id: docformatter - additional_dependencies: [tomli] - args: [--in-place, --wrap-descriptions=120, --wrap-summaries=120] - # --config, ./pyproject.toml +# - repo: https://github.com/PyCQA/docformatter +# rev: master +# hooks: +# - id: docformatter +# additional_dependencies: [tomli] +# args: [--in-place, --wrap-descriptions=120, --wrap-summaries=120] +# # --config, ./pyproject.toml # - repo: https://github.com/psf/black # rev: 24.8.0 @@ -37,6 +37,7 @@ repos: hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] + - id: ruff-format ## If like to embrace black styles even in the docs: # - repo: https://github.com/asottile/blacken-docs diff --git a/CHANGELOG.md b/CHANGELOG.md index 205cc5e..1008d8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,10 @@ # Changelog -## Version 0.1 (development) +## Version 0.2.0 -- Feature A added -- FIX: nasty bug #1729 fixed -- add your changes here! +- chore: Remove Python 3.8 (EOL) +- precommit: Replace docformatter with ruff's formatter + +## Version 0.1.0 + +- Initial version of the package diff --git a/docs/conf.py b/docs/conf.py index b65f5fc..c2b94f1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -179,9 +179,6 @@ autosummary_generate = True autosummary_imported_members = True - - - # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for diff --git a/pyproject.toml b/pyproject.toml index 0514df9..45716dd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,10 @@ extend-ignore = ["F821"] [tool.ruff.pydocstyle] convention = "google" +[tool.ruff.format] +docstring-code-format = true +docstring-code-line-length = 20 + [tool.ruff.per-file-ignores] "__init__.py" = ["E402", "F401"] diff --git a/setup.cfg b/setup.cfg index 35e60b8..5da207b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -41,7 +41,7 @@ package_dir = =src # Require a min/specific Python version (comma-separated conditions) -python_requires = >=3.8 +python_requires = >=3.9 # Add here dependencies of your project (line-separated), e.g. requests>=2.2,<3.0. # Version specifiers like >=2.2,<3.0 avoid problems due to API changes in diff --git a/src/genomicarrays/GenomicArrayDataset.py b/src/genomicarrays/GenomicArrayDataset.py index 0488979..b6a7850 100644 --- a/src/genomicarrays/GenomicArrayDataset.py +++ b/src/genomicarrays/GenomicArrayDataset.py @@ -8,10 +8,16 @@ .. code-block:: python - from genomicarray import GenomicArrayDataset + from genomicarray import ( + GenomicArrayDataset, + ) - garr = GenomicArrayDataset(dataset_path="/path/to/genomicarray/dir") - result1 = garr[0:10, 0] + garr = GenomicArrayDataset( + dataset_path="/path/to/genomicarray/dir" + ) + result1 = garr[ + 0:10, 0 + ] print(result1) """ diff --git a/src/genomicarrays/GenomicArrayDatasetSlice.py b/src/genomicarrays/GenomicArrayDatasetSlice.py index 67788c6..0c284ea 100644 --- a/src/genomicarrays/GenomicArrayDatasetSlice.py +++ b/src/genomicarrays/GenomicArrayDatasetSlice.py @@ -8,11 +8,20 @@ .. code-block:: python - from genomicarray import GenomicArrayDataset + from genomicarray import ( + GenomicArrayDataset, + ) - garr = GenomicArrayDataset(dataset_path="/path/to/genomicarray/dir") - feature_indices = slice(0, 10) - result1 = garr[feature_indices, 0] + garr = GenomicArrayDataset( + dataset_path="/path/to/genomicarray/dir" + ) + feature_indices = ( + slice(0, 10) + ) + result1 = garr[ + feature_indices, + 0, + ] print(result1) """ diff --git a/src/genomicarrays/build_genomicarray.py b/src/genomicarrays/build_genomicarray.py index 43d03e0..be931ac 100644 --- a/src/genomicarrays/build_genomicarray.py +++ b/src/genomicarrays/build_genomicarray.py @@ -174,9 +174,7 @@ def build_genomicarray( missing = required_cols - set(input_intervals.columns) raise ValueError(f"Missing required columns: {missing}") else: - raise TypeError( - "'input_intervals' is not an expected type (either 'str' or 'Dataframe')." - ) + raise TypeError("'input_intervals' is not an expected type (either 'str' or 'Dataframe').") # append start index for each interval input_intervals["widths"] = input_intervals["ends"] - input_intervals["starts"] @@ -190,16 +188,13 @@ def build_genomicarray( counter = [1] * len(input_intervals) total_length = len(input_intervals) counter[0] = 0 - input_intervals["genarr_feature_start_index"] = ( - pd.Series(counter).cumsum().astype(int) - ) + input_intervals["genarr_feature_start_index"] = pd.Series(counter).cumsum().astype(int) ends = input_intervals["genarr_feature_start_index"].shift(-1) ends.iloc[-1] = total_length input_intervals["genarr_feature_end_index"] = ends.astype(int) if not feature_annotation_options.skip: - if "sequence" not in input_intervals.columns: gen_fa = Fasta(genome_fasta, as_raw=True) sequences = [] @@ -209,19 +204,13 @@ def build_genomicarray( input_intervals["sequences"] = sequences - _col_types = utf.infer_column_types( - input_intervals, feature_annotation_options.column_types - ) + _col_types = utf.infer_column_types(input_intervals, feature_annotation_options.column_types) if "genarr_feature_index" not in input_intervals.columns: input_intervals["genarr_feature_index"] = range(0, len(input_intervals)) - _feature_output_uri = ( - f"{output_path}/{feature_annotation_options.tiledb_store_name}" - ) - utf.create_tiledb_frame_from_dataframe( - _feature_output_uri, input_intervals, column_types=_col_types - ) + _feature_output_uri = f"{output_path}/{feature_annotation_options.tiledb_store_name}" + utf.create_tiledb_frame_from_dataframe(_feature_output_uri, input_intervals, column_types=_col_types) if optimize_tiledb: uta.optimize_tiledb_array(_feature_output_uri) @@ -251,16 +240,10 @@ def build_genomicarray( raise TypeError("'sample_metadata' is not an expected type.") if not sample_metadata_options.skip: - _col_types = utf.infer_column_types( - sample_metadata, sample_metadata_options.column_types - ) + _col_types = utf.infer_column_types(sample_metadata, sample_metadata_options.column_types) - _sample_output_uri = ( - f"{output_path}/{sample_metadata_options.tiledb_store_name}" - ) - utf.create_tiledb_frame_from_dataframe( - _sample_output_uri, sample_metadata, column_types=_col_types - ) + _sample_output_uri = f"{output_path}/{sample_metadata_options.tiledb_store_name}" + utf.create_tiledb_frame_from_dataframe(_sample_output_uri, sample_metadata, column_types=_col_types) if optimize_tiledb: uta.optimize_tiledb_array(_sample_output_uri) @@ -311,9 +294,7 @@ def build_genomicarray( ) -def _write_intervals_to_tiledb( - outpath, intervals, bwpath, bwidx, agg_func, total_length -): +def _write_intervals_to_tiledb(outpath, intervals, bwpath, bwidx, agg_func, total_length): """Wrapper to extract the data for the given intervals from the bigwig file and write the output to the tiledb file.""" data = ubw.wrapper_extract_bw_values( @@ -330,6 +311,4 @@ def _write_intervals_to_tiledb( def _wrapper_extract_bwinfo(args): """Wrapper for multiprocessing multiple files and intervals.""" counts_uri, input_intervals, bwpath, idx, agg_func, total_length = args - return _write_intervals_to_tiledb( - counts_uri, input_intervals, bwpath, idx, agg_func, total_length - ) + return _write_intervals_to_tiledb(counts_uri, input_intervals, bwpath, idx, agg_func, total_length) diff --git a/src/genomicarrays/dataloader.py b/src/genomicarrays/dataloader.py index 2676740..8cee704 100644 --- a/src/genomicarrays/dataloader.py +++ b/src/genomicarrays/dataloader.py @@ -7,7 +7,9 @@ .. code-block:: python - from genomicarrays.dataloader import TorchDataset + from genomicarrays.dataloader import ( + TorchDataset, + ) ds = TorchDataset( dataset_path="/path/to/genarr/dir"