Skip to content

Commit

Permalink
Merge pull request #20 from quanted/dev
Browse files Browse the repository at this point in the history
Updates to paper bib and gh action workflows
  • Loading branch information
deronsmith authored Dec 9, 2024
2 parents f314260 + 08c5a68 commit b2f7cc7
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 113 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

permissions:
Expand Down
103 changes: 41 additions & 62 deletions .github/workflows/package-publish.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
name: Build and Publish Wheel
name: Build and Publish Python Packages

on:
# release:
# types: [published]
push:
push: # Only for testing while publish-to-pypi is commented out
branches:
- main

env:
MACOSX_DEPLOYMENT_TARGET: "10.12"
CIBW_BUILD: "cp310-* cp311-* cp312-*"

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# macos-13 is an intel runner, macos-14 is apple silicon
os: [ubuntu-latest, macos-13, macos-14]
python_version: ["3.10", "3.11", "3.12"]
os: [ubuntu-latest, windows-latest, macos-13, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
python-version: "3.12"
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.22.0
- name: Install setuptools
run: |
python -m pip install --upgrade pip
Expand All @@ -29,46 +33,44 @@ jobs:
rustc --version
python -m pip install build setuptools setuptools-rust
- name: Build wheels
run:
python -m build --outdir py_dist
- name: Store the distribution packages
run: python -m cibuildwheel --output-dir py_dist
- name: Store the compiled packages
uses: actions/upload-artifact@v4
with:
name: esat-wheels-${{ matrix.os }}-py${{matrix.python_version}}
name: esat-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: py_dist/

build_windows_wheel:
name: Build wheels on windows-latest
runs-on: windows-latest
strategy:
matrix:
python_version: [ "3.10", "3.11", "3.12" ]
publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
needs:
- build_wheels
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/esat
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
- name: Install setuptools
run: |
python -m pip install --upgrade pip
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=stable
echo "${HOME}/.cargo/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
python -m pip install build setuptools setuptools-rust
- name: Build wheels
run: python -m build --outdir py_dist
- name: Store the distribution packages
uses: actions/upload-artifact@v4
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: esat-wheels-${{ matrix.os }}-py${{matrix.python_version}}
pattern: esat-wheels-*
merge-multiple: true
path: py_dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: py_dist/
skip-existing: true
repository-url: https://test.pypi.org/legacy/

# publish-to-pypi:
# name: >-
# Publish Python 🐍 distribution 📦 to PyPI
# if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
# needs:
# - build_wheels
# - build_windows_wheel
# - publish-to-testpypi
# runs-on: ubuntu-latest
# environment:
# name: pypi
Expand All @@ -79,11 +81,16 @@ jobs:
# - name: Download all the dists
# uses: actions/download-artifact@v4
# with:
# name: python-package-distributions
# pattern: esat-wheels-*
# merge-multiple: true
# path: py_dist/
# - name: Publish distribution 📦 to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
#
# with:
# packages-dir: py_dist/

# Currently not intending on using automated github-release as the primary trigger for pypi publishing is by creating
# a new github version release. This is done manually by the developer.
# github-release:
# name: >-
# Sign the Python 🐍 distribution 📦 with Sigstore
Expand Down Expand Up @@ -126,31 +133,3 @@ jobs:
# gh release upload
# '${{ github.ref_name }}' py_dist/**
# --repo '${{ github.repository }}'


publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
needs:
- build_wheels
- build_windows_wheel
runs-on: ubuntu-latest

environment:
name: testpypi
url: https://test.pypi.org/p/esat

permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
pattern: esat-wheels-*
merge-multiple: true
path: py_dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: py_dist/
repository-url: https://test.pypi.org/legacy/
101 changes: 66 additions & 35 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,90 @@
name: Build and Publish Wheel
name: Build and Publish Artifacts

on:
push:
branches:
- main
- dev

env:
MACOSX_DEPLOYMENT_TARGET: "10.12"
CIBW_BUILD: "cp310-* cp311-* cp312-*"

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# macos-13 is an intel runner, macos-14 is apple silicon
os: [ubuntu-latest, macos-13, macos-14]
python_version: ["3.10", "3.11", "3.12"]
os: [ ubuntu-latest, windows-latest, macos-13, macos-latest ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
- name: Install setuptools
run: |
python -m pip install --upgrade pip
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=stable
echo "PATH=${PATH}:${HOME}/.cargo/bin" >> "$GITHUB_ENV"
rustc --version
python -m pip install build setuptools setuptools-rust
- name: Build wheels
run:
python -m build --outdir wheelhouse
- uses: actions/upload-artifact@v4
with:
name: esat-wheels-${{ matrix.os }}-py${{matrix.python_version}}
path: ./wheelhouse/*.whl

build_windows_wheel:
name: Build wheels on windows-latest
runs-on: windows-latest
strategy:
matrix:
python_version: [ "3.10", "3.11", "3.12" ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
python-version: "3.12"
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.22.0
- name: Install setuptools
run: |
python -m pip install --upgrade pip
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=stable
echo "${HOME}/.cargo/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "PATH=${PATH}:${HOME}/.cargo/bin" >> "$GITHUB_ENV"
rustc --version
python -m pip install build setuptools setuptools-rust
- name: Build wheels
run: python -m build --outdir wheelhouse
run: python -m cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v4
with:
name: esat-wheels-windows-py${{matrix.python_version}}
name: esat-wheels-${{ matrix.os }}-py${{matrix.python_version}}
path: ./wheelhouse/*.whl

# build_wheels:
# name: Build wheels on ${{ matrix.os }}
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# # macos-13 is an intel runner, macos-14 is apple silicon
# os: [ubuntu-latest, macos-13, macos-14]
# python_version: ["3.10", "3.11", "3.12"]
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-python@v5
# with:
# python-version: ${{ matrix.python_version }}
# - name: Install setuptools
# run: |
# python -m pip install --upgrade pip
# curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=stable
# echo "PATH=${PATH}:${HOME}/.cargo/bin" >> "$GITHUB_ENV"
# rustc --version
# python -m pip install build setuptools setuptools-rust
# - name: Build wheels
# run:
# python -m build --outdir wheelhouse
# - uses: actions/upload-artifact@v4
# with:
# name: esat-wheels-${{ matrix.os }}-py${{matrix.python_version}}
# path: ./wheelhouse/*.whl
#
# build_windows_wheel:
# name: Build wheels on windows-latest
# runs-on: windows-latest
# strategy:
# matrix:
# python_version: [ "3.10", "3.11", "3.12" ]
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-python@v5
# with:
# python-version: ${{ matrix.python_version }}
# - name: Install setuptools
# run: |
# python -m pip install --upgrade pip
# curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=stable
# echo "${HOME}/.cargo/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# python -m pip install build setuptools setuptools-rust
# - name: Build wheels
# run: python -m build --outdir wheelhouse
# - uses: actions/upload-artifact@v4
# with:
# name: esat-wheels-windows-py${{matrix.python_version}}
# path: ./wheelhouse/*.whl
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Environmental Source Apportionment Toolkit (ESAT)
Last Update: 08-15-2024
Last Update: 12-09-2024

## Table of Contents
- [Description](#description)
Expand Down Expand Up @@ -38,24 +38,25 @@ ESAT supports python version 3.10, 3.11, and 3.12. As the python package contain
specific versions, supporting Mac Intel, Mac M1+, Linux, and Windows.

### Documentation
The Python API and CLI documentation can be found at the Github ESAT IO site: [https://quanted.github.io/esat/](https://quanted.github.io/esat/)
The Python API and CLI documentation can be found at the GitHub ESAT IO site: [https://quanted.github.io/esat/](https://quanted.github.io/esat/)

### Installation
The ESAT python package contains all compiled code and required dependencies and can be installed using pip
```bash
pip install esat-VERSION-OS.whl
pip install esat
```
where the <i>VERSION</i> is the code version, such as <i>2024.1.0</i>, and <i>OS</i> is operating system targeted
compiled version, such as <i>cp312-cp312-win_amd64</i>. If an error message appears during installation stating that the
package is not supported check that the correct OS and python version are being installed for that system.
which will install the latest version that supports and is available for your python version and OS.

The latest version of the ESAT python package can be found on the github actions page, for users who are signed into github,
Development versions of ESAT can be found on the GitHub actions page, for logged-in users,
under the 'Build and Publish Wheel' workflow. The latest version of the package will be available as an artifact for
download in the 'Artifacts' section of the completed workflow.
download in the 'Artifacts' section of the completed workflow. There wheel files can be found for specific versions
of python and supported operating systems.

When the package becomes available on pypi, the package will be able to be installed with
If an error message appears during installation stating that the
package is not supported check that the correct OS and python version are being installed for that system. The python
wheels can be installed directly using
```bash
pip install esat
pip install <wheel file name>
```
The esat python package is recommended to be installed in its own dedicated python virtual environment or conda environment.

Expand Down
38 changes: 38 additions & 0 deletions eval/factor_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,41 @@ def combine_factors(self, factors, model_correlation, model_contributions, facto
r_avg_3 = np.mean(r_values_3)
return factors, r_avg, r_values, r_avg_2, r_values_2, r_avg_3, r_values_3

# class FactorCompareV2:
# """
#
# Parameters
# ----------
# base_model : BaseModel
# The base model to compare against.
# models : list
# A list of models to compare against the base model.
# method : str
# Correlation method to use
# """
# def __init__(self, base_model, models, method: str = "all"):
# self.base_model = base_model
# self.models = models
# self.method = method
# self.base_factors = base_model.factors
# self.base_features = base_model.features
#
# self.model_results = {}
#
# self.factor_map = None
#
# def compare(self, verbose: bool = True):
# """
#
# Parameters
# ----------
# verbose
#
# Returns
# -------
#
# """
# base_mean_W = np.mean(self.base_model.W, axis=0)[0]
# base_mass_matrix = (base_mean_W*self.base_model.H)/np.sum(base_mean_W*self.base_model.H)


Loading

0 comments on commit b2f7cc7

Please sign in to comment.