From 03d979754f954e668f02b8a4efabb82a7712a8bf Mon Sep 17 00:00:00 2001 From: charalamm Date: Mon, 10 Jun 2024 12:38:25 +0200 Subject: [PATCH] Change ruff and add github action --- .github/workflows/ruff.yml | 21 +++++++++++++++++++++ README.md | 10 ++++++++-- pyefast/efast.py | 1 + pyefast/s3_processing.py | 2 ++ pyproject.toml | 12 +++++++----- run_efast.py | 3 ++- 6 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/ruff.yml diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml new file mode 100644 index 0000000..7e88cbd --- /dev/null +++ b/.github/workflows/ruff.yml @@ -0,0 +1,21 @@ +name: ruff_push +on: [push] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + - run: | + python -m pip install --upgrade pip + pip install ruff + - run: ruff check --output-format=github . + - name: If needed, commit ruff changes to a new pull request + if: failure() + run: | + ruff check --output-format=github --fix . + git config --global user.name github-actions + git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com' + git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY + git commit -am "fixup! Format Python code with ruff push" + git push --force origin HEAD:$GITHUB_REF diff --git a/README.md b/README.md index a3a993d..cf8f9cf 100644 --- a/README.md +++ b/README.md @@ -47,8 +47,8 @@ See run_efast.py for an example using data located in test_data folder. 1. Clone the repository to your local machine. 2. Navigate to the root directory of the repository in your terminal. -3. [OPTIONAL but recommended] Create a virtual environment: `python3. -m venv venv` -3. Install the package: `pip install -e ./` +3. [OPTIONAL but recommended] Create a virtual environment: `python3. -m venv .venv` +3. Install the package: `pip install -e .` 4. Run the example: `python run_efast.py` ### Installation @@ -67,3 +67,9 @@ pyefast.fusion( ... ) ``` + +### Develop +1. Clone the repository to your local machine. +2. Navigate to the root directory of the repository in your terminal. +3. [OPTIONAL but strongly recommended] Create a virtual environment: `python3. -m venv .venv` +3. Install the package in dev mode: `pip install -e .[dev]` diff --git a/pyefast/efast.py b/pyefast/efast.py index 2325c9b..a25efc2 100644 --- a/pyefast/efast.py +++ b/pyefast/efast.py @@ -32,6 +32,7 @@ import rasterio import rasterio.windows import scipy.ndimage + from scipy.interpolate import interp1d from tqdm import tqdm diff --git a/pyefast/s3_processing.py b/pyefast/s3_processing.py index 1027618..3f72546 100644 --- a/pyefast/s3_processing.py +++ b/pyefast/s3_processing.py @@ -27,6 +27,7 @@ import os import re + from datetime import datetime import astropy.convolution as ap @@ -34,6 +35,7 @@ import pandas as pd import rasterio import scipy as sp + from dateutil import rrule from rasterio import shutil as rio_shutil from rasterio.enums import Resampling diff --git a/pyproject.toml b/pyproject.toml index 2e7bdff..028da26 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,14 +25,16 @@ dependencies = [ ] [project.optional-dependencies] -dev = ["ruff"] +dev = [ + "ruff", +] [tool.setuptools.packages.find] include = ["pyefast"] -[tool.ruff] -line-length = 88 -indent-width = 4 - [tool.ruff.lint] select = ["I"] + +[tool.ruff.lint.isort] +# Use a single line between direct and from import. +lines-between-types = 1 diff --git a/run_efast.py b/run_efast.py index 470f4b8..cb1b864 100644 --- a/run_efast.py +++ b/run_efast.py @@ -26,6 +26,7 @@ """ import argparse + from datetime import datetime, timedelta from pathlib import Path @@ -150,5 +151,5 @@ def main( s2_bands=args.s2_bands, step=args.step, mosaic_days=args.mosaic_days, - snap_gpt_path=args.snap_gpt_path + snap_gpt_path=args.snap_gpt_path, )