From 1f54468e10cd87224188b0c11af1b4c358a51d3d Mon Sep 17 00:00:00 2001 From: lumbric Date: Tue, 7 May 2024 18:31:38 +0200 Subject: [PATCH] Add dependencies and cleanup GH actions --- .github/workflows/dev.yml | 63 ------ .github/workflows/tests.yml | 42 ++++ README.md | 17 +- env.yml | 368 ------------------------------------ pyproject.toml | 18 +- syfop/units.py | 4 + 6 files changed, 71 insertions(+), 441 deletions(-) delete mode 100644 .github/workflows/dev.yml create mode 100644 .github/workflows/tests.yml delete mode 100644 env.yml diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml deleted file mode 100644 index d0cb85b..0000000 --- a/.github/workflows/dev.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: Dev build - -on: push - -jobs: - test: - runs-on: ubuntu-latest - - # TODO need to check if this really works with conda that way - # strategy: - # matrix: - # python-versions: ['3.7', '3.8', '3.9', '3.10'] - - steps: - - name: Set up Git repository - uses: actions/checkout@v2 - - # Other Github actions to setup conda, not sure which is the best one: - # https://github.com/marketplace/actions/setup-miniconda - # --> seems to work fine - # https://github.com/matthewrmshin/conda-action - # --> No success, how to activate env? Has only 2 stars... - # https://github.com/marketplace/actions/setup-conda - # --> not tested yet - - name: Cache conda - uses: actions/cache@v2 - env: - # Increase this value to reset cache if env.yml has not changed - CACHE_NUMBER: 3 - with: - path: ~/conda_pkgs_dir - key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('env.yml') }} - - - uses: conda-incubator/setup-miniconda@v2 - with: - # python-version: 3.9 - # mamba-version: "*" - # channels: conda-forge - # TODO might be a good idea, but does not work... - # channel-priority: strict - # use Mambaforge to avoid weird conda setup issue: - # https://github.com/conda-incubator/setup-miniconda/issues/116#issuecomment-1384648777 - miniforge-variant: Mambaforge - miniforge-version: latest - activate-environment: syfop - environment-file: env.yml - # TODO does this cause troubles with finding packages? - # https://github.com/conda-incubator/setup-miniconda/issues/267 - # use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly! - - - name: Lint wiht flake8 and black - shell: bash -l {0} - run: flake8 && black --check . - - - name: Run unit tests (except the ones using Gurobi) - shell: bash -l {0} - run: python -m pytest --cov=. --cov-report=lcov -k "not gurobi and not cplex" tests - - - name: Coveralls - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: coverage.lcov diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..5e84abe --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,42 @@ +name: Tests + +on: push + +jobs: + test: + runs-on: ubuntu-latest + + # strategy: + # matrix: + # python-versions: ['3.7', '3.8', '3.9', '3.10'] + + steps: + - name: Set up Git repository + uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + cache: 'pip' # caching pip dependencies + + - name: Install syfop and dependencies + run: | + sudo apt-get install graphviz graphviz-dev # for pygraphviz + python -m pip install --upgrade pip + python -m pip install -e .[dev,test,extra] + + - name: Lint with flake8 + run: flake8 + + - name: Lint with black + run: black --check . + + - name: Run unit tests (except the ones using Gurobi and CPLEX) + shell: bash -l {0} + run: python -m pytest --cov=. --cov-report=lcov -k "not gurobi and not cplex" tests + + - name: Coveralls test coverage + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: coverage.lcov diff --git a/README.md b/README.md index 7331ece..16f40b9 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![MIT License](https://img.shields.io/github/license/inwe-boku/syfop.svg)](https://choosealicense.com/licenses/mit/) -[![CI](https://github.com/inwe-boku/syfop/actions/workflows/dev.yml/badge.svg)](https://github.com/inwe-boku/syfop/actions) +[![CI](https://github.com/inwe-boku/syfop/actions/workflows/tests.yml/badge.svg)](https://github.com/inwe-boku/syfop/actions/workflows/tests.yml) [![Coverage Status](https://coveralls.io/repos/github/inwe-boku/syfop/badge.svg)](https://coveralls.io/github/inwe-boku/syfop) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![DOI](https://zenodo.org/badge/550867861.svg)](https://zenodo.org/doi/10.5281/zenodo.10869438) @@ -40,16 +40,17 @@ see [demo.ipynb](notebooks/demo.ipynb) How to install -------------- -At the moment there is no package built for syfop. Use conda to setup an environment and then use -`syfop` directly from a cloned Git repository: +At the moment there is no package built for syfop, but it can be installed via pip directly from the +repository: - git clone https://github.com/inwe-boku/syfop/ - conda update -f env.yml - conda activate syfop - pre-commit install + pip install git+https://github.com/inwe-boku/syfop + +The solver HiGHs is installed automatically . Other [solvers](https://linopy.readthedocs.io/en/latest/solvers.html) are supported too, but not installed automatically. +To install development requirements run: -The conda environment contains the solver HiGHs. Other [solvers](https://linopy.readthedocs.io/en/latest/solvers.html) are supported too, but not included in the conda environment. + pip install -e 'syfop[test,dev] @ git+https://github.com/inwe-boku/syfop' + pre-commit install