From f101cfe06d0966bcf6da6cfa4dd9f3b48ec6cb4f Mon Sep 17 00:00:00 2001 From: "Sara A. Miskovich" Date: Thu, 6 Jun 2024 16:54:18 -0700 Subject: [PATCH 1/8] update pyproject.toml and workflows --- .github/workflows/build.yml | 31 ++++++++-------- .github/workflows/test.yml | 72 ++++++++++++++++++------------------- conda_recipe/meta.yaml | 26 ++++++++------ pyproject.toml | 50 ++++++++++++++++++++++++-- qss/__init__.py | 1 + setup.py | 35 ------------------ 6 files changed, 115 insertions(+), 100 deletions(-) delete mode 100644 setup.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5adb464..0404f92 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,20 +12,20 @@ jobs: steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: "3.9" - - name: Install Twine - run: sudo pip install twine + - name: Install Twine and Build + run: sudo pip install twine build - name: Create the distribution run: | git fetch --prune --unshallow --tags - sudo python setup.py sdist bdist_wheel + sudo python3 -m build - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 @@ -39,10 +39,10 @@ jobs: shell: bash -l {0} steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: "3.9" @@ -53,13 +53,13 @@ jobs: activate-environment: "" miniconda-version: "latest" - - name: Install the Mamba Dependencies - run: | + - name: Install the Conda Dependencies + run: | conda config --set always_yes yes --set auto_update_conda false conda update conda - conda install mamba -n base -c conda-forge conda install -n base conda-libmamba-solver - mamba install python=3.9 "conda-build=3.21" colorama pip ruamel ruamel.yaml rich mamba jsonschema -c conda-forge + conda install python=3.9 conda-build colorama pip ruamel ruamel.yaml rich jsonschema -c conda-forge + git fetch --prune --unshallow --tags pip install -e . # run install twice due to client-size to ensure all files downloaded @@ -67,14 +67,13 @@ jobs: # git tags MUST be fetched otherwise output will be blank # bash variables cannot be used in github actions, must use actions specific syntax and methods - name: Build the Anaconda Package - id: mambabuild + id: condabuild run: | - mamba install anaconda-client + conda install anaconda-client conda config --set anaconda_upload no --set solver libmamba echo yes | anaconda login --username ${{ secrets.ANACONDA_CLOUD_USERNAME }} --password ${{ secrets.ANACONDA_CLOUD_PASSWORD }} - git fetch --prune --unshallow --tags - VERSION_FROM_GIT_TAG=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-) conda build . -c conda-forge -c stanfordcvxgrp --numpy 1.16.4 - echo '::set-output name=gitversion::$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)' + VERSION_FROM_GIT_TAG=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-) conda build . -c anaconda -c conda-forge -c stanfordcvxgrp + echo "gitversion=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)" >> $GITHUB_OUTPUT - name: Upload the Anaconda Package id: condaload diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9efaa47..c4001ab 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,53 +1,53 @@ name: Main Test -on: - pull_request: - push: - branches: - - master - tags: - - '*' + +on: [push] jobs: run-tests: runs-on: ubuntu-latest + environment: test + strategy: + fail-fast: false + matrix: + python-version: [ "3.10", "3.11", "3.12" ] steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: ${{ matrix.python-version }} - - name: Install Dependencies - run: | - sudo python -m pip install -r requirements.txt - python -m pip install pytest - python -m pip install -e . + - name: Install Python Dependencies + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh + uv pip install --system --break-system-packages -r requirements.txt + uv pip install --system --break-system-packages pytest pytest-cov pytest-github-report pytest-github-actions-annotate-failures -# Current unit test is not consistent. Occasionally fails despite usually passing. Needs to be fixed. - name: Run Unit Tests - run: | - python -m pytest --import-mode=append tests/ + env: + pytest_github_report: true + pytest_verbosity: 2 + run: pytest -v --cov=src --cov-report=xml --cov-report=term-missing --color=yes tests/ test-build-pypi: - needs: run-tests runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: "3.9" - - name: Install Twine - run: sudo pip install twine + - name: Install Twine and Build + run: sudo pip install twine build - name: Create the distribution run: | git fetch --prune --unshallow --tags - sudo python setup.py sdist bdist_wheel + sudo python3 -m build test-build-conda: needs: run-tests @@ -58,27 +58,27 @@ jobs: shell: bash -l {0} steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: "3.9" - name: Install Miniconda - uses: conda-incubator/setup-miniconda@v2 + uses: conda-incubator/setup-miniconda@v3 with: auto-activate-base: true activate-environment: "" miniconda-version: "latest" - - name: Install the Mamba Dependencies - run: | + - name: Install the Conda Dependencies + run: | conda config --set always_yes yes --set auto_update_conda false conda update conda - conda install mamba -n base -c conda-forge conda install -n base conda-libmamba-solver - mamba install python=3.9 "conda-build=3.21" colorama pip ruamel ruamel.yaml rich mamba jsonschema -c conda-forge + conda install python=3.9 conda-build colorama pip ruamel ruamel.yaml rich jsonschema -c conda-forge + git fetch --prune --unshallow --tags pip install -e . @@ -87,10 +87,10 @@ jobs: # git tags MUST be fetched otherwise output will be blank # bash variables cannot be used in github actions, must use actions specific syntax and methods - name: Build the Anaconda Package - id: mambabuild + id: condabuild run: | - mamba install anaconda-client + conda install anaconda-client + conda clean --all conda config --set anaconda_upload no --set solver libmamba - git fetch --prune --unshallow --tags - VERSION_FROM_GIT_TAG=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-) conda build . -c conda-forge -c stanfordcvxgrp --numpy 1.16.4 - echo '::set-output name=gitversion::$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)' + VERSION_FROM_GIT_TAG=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)test conda build . -c conda-forge -c stanfordcvxgrp + echo "gitversion=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)" >> $GITHUB_OUTPUT diff --git a/conda_recipe/meta.yaml b/conda_recipe/meta.yaml index 7d567b6..a00361d 100644 --- a/conda_recipe/meta.yaml +++ b/conda_recipe/meta.yaml @@ -5,7 +5,7 @@ package: version: {{ environ.get('VERSION_FROM_GIT_TAG') }} source: - git_url: https://github.com/cvxgrp/qss + path: .. # checked out repo instead of main repo branch build: noarch: python @@ -16,27 +16,30 @@ requirements: host: - pip - python >=3.6 - - scipy - - numpy >=1.16 - - qdldl-python - - cvxpy - - matplotlib run: - pip - python - scipy - - numpy >=1.16 + - numpy - qdldl-python - cvxpy - matplotlib +test: + imports: + - qss + commands: + - pip check + requires: + - pip + about: home: https://github.com/cvxgrp/qss - license: BSD - license_family: BSD - license_file: - summary: QSS Quadratic-Seperable Solver + license: Apache + license_family: Apache + license_file: LICENSE + summary: QSS Quadratic-Separable Solver doc_url: dev_url: @@ -44,3 +47,4 @@ extra: recipe-maintainers: - lukevolpatti - Thistleman + - pluflou diff --git a/pyproject.toml b/pyproject.toml index a7a6804..4e3abe9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,49 @@ [build-system] -requires = ["setuptools>=61.0.0", "wheel"] -build-backend = "setuptools.build_meta" \ No newline at end of file +requires = ["setuptools>=64.0", "setuptools-scm[toml]"] +build-backend = "setuptools.build_meta" + +[project] +name = "qss" +description = "QSS: Quadratic-Separable Solver" +readme = "README.md" +license.file = "LICENSE" +authors = [ + { name = "Luke Volpatti", email = "bennetm@stanford.edu" }, +] +maintainers = [ + { name = "Sara Miskovich", email = "smiskov@slac.stanford.edu" }, +] +requires-python = ">=3.6" + +dependencies = [ + "scipy", + "numpy", + "cvxpy", + "qdldl", + "matplotlib" +] + +classifiers = [ + "Development Status :: 4 - Beta", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Intended Audience :: Science/Research", + "Topic :: Scientific/Engineering", +] +dynamic = ["version"] +[tool.setuptools_scm] +write_to = "qss/_version.py" + +[tool.setuptools.packages.find] +include = ["qss*"] + +[project.urls] +Homepage = "https://github.com/cvxgrp/qss" +"Bug Tracker" = "https://github.com/cvxgrp/qss/issues" diff --git a/qss/__init__.py b/qss/__init__.py index 5e8f89f..a1b8326 100644 --- a/qss/__init__.py +++ b/qss/__init__.py @@ -1 +1,2 @@ +from ._version import version as __version__ from qss.qss import QSS diff --git a/setup.py b/setup.py deleted file mode 100644 index a768c04..0000000 --- a/setup.py +++ /dev/null @@ -1,35 +0,0 @@ -from setuptools import setup -import subprocess - -with open("README.md", "r", encoding="utf-8") as fh: - long_description = fh.read() - -# get all the git tags from the cmd line that follow our versioning pattern -git_tags = subprocess.Popen( - ["git", "tag", "--list", "v*[0-9]", "--sort=version:refname"], - stdout=subprocess.PIPE, -) -tags = git_tags.stdout.read() -git_tags.stdout.close() -tags = tags.decode("utf-8").split("\n") -tags.sort() - -# PEP 440 won't accept the v in front, so here we remove it, strip the new line and decode the byte stream -VERSION_FROM_GIT_TAG = tags[-1][1:] - -setup( - name="qss", - version=VERSION_FROM_GIT_TAG, - author="Luke Volpatti", - description="QSS: Quadratic-Separable Solver", - long_description=long_description, - long_description_content_type="text/markdown", - install_requires=["numpy", "scipy", "qdldl", "cvxpy"], - url="https://github.com/lukevolpatti/qss", - project_urls={ - "Bug Tracker": "https://github.com/lukevolpatti/qss/issues", - }, - license="Apache 2.0", - packages=["qss"], - python_requires=">=3.6", -) From 17206bef8753844ef2572ae0b886c7396a3a4d29 Mon Sep 17 00:00:00 2001 From: "Sara A. Miskovich" Date: Thu, 6 Jun 2024 17:01:27 -0700 Subject: [PATCH 2/8] update workflow to run at PR --- .github/workflows/test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c4001ab..42956e2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,10 @@ name: Main Test -on: [push] +on: + push: + pull_request: + branches: [main] + types: [opened, reopened] jobs: run-tests: runs-on: ubuntu-latest From 5bbb48f095548f29b7b55bf197eb5f17af964e7a Mon Sep 17 00:00:00 2001 From: "Sara A. Miskovich" Date: Thu, 6 Jun 2024 17:04:34 -0700 Subject: [PATCH 3/8] add version file to pass tests in ci/cd --- qss/_version.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 qss/_version.py diff --git a/qss/_version.py b/qss/_version.py new file mode 100644 index 0000000..6c13460 --- /dev/null +++ b/qss/_version.py @@ -0,0 +1,16 @@ +# file generated by setuptools_scm +# don't change, don't track in version control +TYPE_CHECKING = False +if TYPE_CHECKING: + from typing import Tuple, Union + VERSION_TUPLE = Tuple[Union[int, str], ...] +else: + VERSION_TUPLE = object + +version: str +__version__: str +__version_tuple__: VERSION_TUPLE +version_tuple: VERSION_TUPLE + +__version__ = version = '0.2.4.dev2+g17206be' +__version_tuple__ = version_tuple = (0, 2, 4, 'dev2', 'g17206be') From 42c44fda32c9c7400287f6d704b2c0becce75f85 Mon Sep 17 00:00:00 2001 From: "Sara A. Miskovich" Date: Thu, 6 Jun 2024 17:15:09 -0700 Subject: [PATCH 4/8] rm condition on conda build test --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 42956e2..f9bcfb4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -54,7 +54,6 @@ jobs: sudo python3 -m build test-build-conda: - needs: run-tests runs-on: ubuntu-latest # sets default shell to remove need for source to run the conda shell defaults: From 466448040c33f2496c67cef28c0bde15df3eddd7 Mon Sep 17 00:00:00 2001 From: "Sara A. Miskovich" Date: Thu, 6 Jun 2024 17:22:34 -0700 Subject: [PATCH 5/8] add test trigger to PR edits --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f9bcfb4..e98edfe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,7 +4,7 @@ on: push: pull_request: branches: [main] - types: [opened, reopened] + types: [opened, edited, reopened] jobs: run-tests: runs-on: ubuntu-latest From 802eb7243b88a2a8dc676962007f6283d5419ee3 Mon Sep 17 00:00:00 2001 From: "Sara A. Miskovich" Date: Fri, 7 Jun 2024 11:26:38 -0700 Subject: [PATCH 6/8] Fix bug in conda build upload --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0404f92..6cb9c22 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,4 +78,4 @@ jobs: - name: Upload the Anaconda Package id: condaload run: | - anaconda upload -u stanfordcvxgrp /usr/share/miniconda3/conda-bld/noarch/qss-${{ steps.mambabuild.outputs.gitversion }}-*.tar.bz2 + anaconda upload -u stanfordcvxgrp /usr/share/miniconda3/conda-bld/noarch/qss-${{ steps.condabuild.outputs.gitversion }}-*.tar.bz2 From c910f3cc41ae1a55110f71970ef0c117e7800820 Mon Sep 17 00:00:00 2001 From: "Sara A. Miskovich" Date: Wed, 4 Sep 2024 16:04:42 -0700 Subject: [PATCH 7/8] removes versioning (wip) --- pyproject.toml | 1 - qss/__init__.py | 1 - qss/_version.py | 16 ---------------- 3 files changed, 18 deletions(-) delete mode 100644 qss/_version.py diff --git a/pyproject.toml b/pyproject.toml index 4e3abe9..a69b697 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,6 @@ classifiers = [ ] dynamic = ["version"] [tool.setuptools_scm] -write_to = "qss/_version.py" [tool.setuptools.packages.find] include = ["qss*"] diff --git a/qss/__init__.py b/qss/__init__.py index a1b8326..5e8f89f 100644 --- a/qss/__init__.py +++ b/qss/__init__.py @@ -1,2 +1 @@ -from ._version import version as __version__ from qss.qss import QSS diff --git a/qss/_version.py b/qss/_version.py deleted file mode 100644 index 6c13460..0000000 --- a/qss/_version.py +++ /dev/null @@ -1,16 +0,0 @@ -# file generated by setuptools_scm -# don't change, don't track in version control -TYPE_CHECKING = False -if TYPE_CHECKING: - from typing import Tuple, Union - VERSION_TUPLE = Tuple[Union[int, str], ...] -else: - VERSION_TUPLE = object - -version: str -__version__: str -__version_tuple__: VERSION_TUPLE -version_tuple: VERSION_TUPLE - -__version__ = version = '0.2.4.dev2+g17206be' -__version_tuple__ = version_tuple = (0, 2, 4, 'dev2', 'g17206be') From 44c0f4dd8aa38802d93af0aa71c0573ae942208d Mon Sep 17 00:00:00 2001 From: "Sara A. Miskovich" Date: Mon, 16 Sep 2024 11:11:17 -0700 Subject: [PATCH 8/8] pins scipy until algo api changes fix --- conda_recipe/meta.yaml | 2 +- pyproject.toml | 2 +- requirements.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conda_recipe/meta.yaml b/conda_recipe/meta.yaml index a00361d..db59174 100644 --- a/conda_recipe/meta.yaml +++ b/conda_recipe/meta.yaml @@ -20,7 +20,7 @@ requirements: run: - pip - python - - scipy + - scipy==1.13.1 - numpy - qdldl-python - cvxpy diff --git a/pyproject.toml b/pyproject.toml index a69b697..56782ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ maintainers = [ requires-python = ">=3.6" dependencies = [ - "scipy", + "scipy==1.13.1", "numpy", "cvxpy", "qdldl", diff --git a/requirements.txt b/requirements.txt index 5eab1bc..543f3de 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ numpy -scipy +scipy==1.13.1 qdldl cvxpy matplotlib