Skip to content

Commit

Permalink
Packaging and distribution updates (#24)
Browse files Browse the repository at this point in the history
* adjust package info to prep for ci/cd changes and docs

* add yaml for rtd

* fix conf.py

* test rst change

* adjust workflows for tests

* adjust workflows for tests

* adjust build test and release workflows

* rm obsolete ttests

* add concurrency grp to tests to avoid dupes

* add concurrency grp to tests to avoid dupes

* test concurrent rule

* test concurrent rule

* Delete tests/io/test_resstock.py

* Delete tests/io/test_tmy3.py
  • Loading branch information
pluflou authored Sep 24, 2024
1 parent f68aeeb commit 295cdd6
Show file tree
Hide file tree
Showing 39 changed files with 201 additions and 377 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Deploy Main
on:
release:
types: [published]

env:
PYTHON_VERSION: "3.12"

jobs:
deploy-pypi:
runs-on: ubuntu-latest
environment: deployment
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Twine and Build
run: sudo pip install twine build

- name: Create the distribution
run: |
git fetch --prune --unshallow --tags
sudo python3 -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
26 changes: 26 additions & 0 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test Build

on:
pull_request:
branches: [main]
jobs:
build-pypi:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.10", "3.11", "3.12" ]
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Twine and Build
run: sudo pip install twine build

- name: Create the distribution
run: |
git fetch --prune --unshallow --tags
sudo python3 -m build
130 changes: 50 additions & 80 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,87 +1,57 @@
name: Tests
on: [push]
jobs:
run-tests:
runs-on: ubuntu-latest
environment: test
steps:
- name: Checkout Repository
uses: actions/checkout@v3

# Necessary action when needing to use AWS credentials.
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-1
on:
push:
pull_request:
branches:
- main

- name: Install Python
uses: actions/setup-python@v3
with:
python-version: '3.10'
jobs:
pre_job:
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
concurrent_skipping: 'same_content_newer'
paths_ignore: '["**/README.md", "**/docs/**"]'
do_not_skip: '["pull_request"]'

- name: Install Dependencies
run: |
sudo $pythonLocation/bin/python3 -m pip install -r requirements.txt
sudo $pythonLocation/bin/python3 -m pip install awscli coverage
sudo $pythonLocation/bin/python3 -m pip install setuptools --upgrade
$pythonLocation/bin/python3 -m pip list
run-tests:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
runs-on: ubuntu-latest
environment: test
concurrency:
group: unit_tests
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 1
fetch-tags: true

- name: Run Unit Tests
run: sudo $pythonLocation/bin/python3 -m coverage run -m unittest
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

# build-pypi:
# runs-on: ubuntu-latest
# needs: run-tests
# steps:
# - name: Checkout Repository
# uses: actions/checkout@v3
#
# - name: Install Python
# uses: actions/setup-python@v3
#
# - name: Install Twine
# run: sudo pip install twine
#
# - name: Create the distribution
# run: |
# git fetch --prune --unshallow --tags
# sudo python setup.py sdist bdist_wheel
# build-conda:
# runs-on: ubuntu-latest
# needs: run-tests
# sets default shell to remove need for source to run the conda shell
# defaults:
# run:
# shell: bash -l {0}
# environment: test-deployment
# steps:
# - name: Checkout Repository
# uses: actions/checkout@v3
- 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
# Much better than manual installation, original version Miniconda2-4.7.10-Linux-x86_64.sh is broken
# - name: Install Miniconda
# uses: conda-incubator/setup-miniconda@v2
# with:
# auto-activate-base: true
# activate-environment: ""
# miniconda-version: "latest"
#
# - name: Install the Conda Dependencies
# run: |
# conda config --set always_yes yes --set auto_update_conda false
# conda update conda
# conda install conda-build
# run install twice due to client-size to ensure all files downloaded
# echo yes before login to prevent anaconda bug breaking automation
# 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: condabuild
# run: |
# conda install anaconda-client
# conda config --set anaconda_upload no
# git fetch --prune --unshallow --tags
# VERSION_FROM_GIT_TAG=$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)test conda build . -c anaconda -c pvlib -c slacgismo -c conda-forge --numpy 1.22.0
# echo '::set-output name=gitversion::$(git tag --list "v*[0-9]" --sort=version:refname | tail -1 | cut -c 2-)'
- name: Run Unit Tests
env:
pytest_github_report: true
pytest_verbosity: 2
run: pytest -v --cov=src --cov-report=xml --cov-report=term-missing --color=yes sg2t/tests/
32 changes: 32 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"
# You can also specify other tool versions:
# nodejs: "19"
# rust: "1.64"
# golang: "1.19"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
# python:
# install:
# - requirements: docs/requirements.txt
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ prune .circleci
prune .github
prune .jupyter
prune binder
# exclude a bunch of common hidden files, you probably want to add your own here
# exclude a bunch of common hidden files
exclude .mailmap
exclude .gitignore
exclude .gitattributes
Expand Down
13 changes: 2 additions & 11 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,19 @@
copyright = '2022, Sara Miskovich'
author = 'Sara Miskovich'

# The full version, including alpha/beta/rc tags
from sg2t import __version__
release = __version__

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.inheritance_diagram',
'sphinx.ext.viewcode',
'sphinx.ext.napoleon',
'sphinx.ext.doctest',
'sphinx.ext.mathjax',
'sphinx_automodapi.automodapi',
'sphinx_automodapi.smart_resolver',
]
'sphinx.ext.autodoc'
]

# Add any paths that contain templates here, relative to this directory.
# templates_path = ['_templates']
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
slac-gismo-grid-tools Documentation
-----------------------------------

This is the documentation for slac-gismo-grid-tools.
This is the documentation for slac-gismo-grid-tools. Please come back later.

.. toctree::
:maxdepth: 2
Expand Down
58 changes: 54 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,57 @@
[build-system]
requires = ["setuptools>=64.0", "setuptools-scm[toml]"]
build-backend = "setuptools.build_meta"

requires = ["setuptools",
"setuptools_scm",
"wheel"]
[project]
name = "slac-gismo-grid-tools"
description = "SLAC GISMo Grid Tools is single core package for grid related data cleaning, manipulation and data science in Python."
readme = "README.md"
license.file = "LICENSE"
authors = [
{ name = "Sara Miskovich", email = "[email protected]" },
{ name = "David Chassin", email = "[email protected]" },
{ name = "Mohamed Nijad "},
]
keywords = ["grid", "load modeling", "electrid loadshapes"]
requires-python = ">=3.6"

#build-backend = 'setuptools.build_meta'
dependencies = [
"numpy",
"pandas",
"jupyter",
"matplotlib",
"marimo"
]

classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: BSD 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]

[tool.setuptools.packages.find]
include = ["sg2t*"]

[project.optional-dependencies]
docs = [
"sphinx",
"sphinx-changelog>=1.2.0",
"sphinx_design",
]

[project.urls]
Homepage = "https://github.com/slacgismo/sg2t"
Documentation = "https://sg2t.readthedocs.io/"
"Bug Tracker" = "https://github.com/slacgismo/sg2t/issues"
Discussions = "https://github.com/slacgismo/sg2t/discussions"
4 changes: 1 addition & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ numpy
pandas
jupyter
matplotlib
pyarrow
boto3
scikit-learn
marimo
Loading

0 comments on commit 295cdd6

Please sign in to comment.