Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-48803: Add tools for checking band column descriptions #2

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build and test

on:
push:
branches:
- main
tags:
- "*"
pull_request:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
with:
# Need to clone everything for the git tags.
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"

- name: Install prereqs for setuptools
run: pip install wheel

- name: Install dependencies
run: |
python -m pip install --upgrade pip uv
uv pip install --system -r requirements.txt

- name: Install pytest packages
run: uv pip install --system pytest pytest-xdist pytest-cov

- name: List installed packages
run: uv pip list

- name: Build and install
run: uv pip install --system --no-deps -e .

- name: Run tests
run: |
sdm-tools --help
41 changes: 41 additions & 0 deletions .github/workflows/do_not_merge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "Check commits can be merged"
on:
push:
branches:
- main
pull_request:

jobs:
do-not-merge-checker:
runs-on: ubuntu-latest

steps:
- name: Check that there are no commits that should not be merged
uses: gsactions/commit-message-checker@v2
with:
excludeDescription: "true" # optional: this excludes the description body of a pull request
excludeTitle: "true" # optional: this excludes the title of a pull request
checkAllCommitMessages: "true" # optional: this checks all commits associated with a pull request
accessToken: ${{ secrets.GITHUB_TOKEN }} # github access token is only required if checkAllCommitMessages is true
# Check for message indicating that there is a commit that should
# not be merged.
pattern: ^(?!DO NOT MERGE)
flags: "i"
error: |
"This step failed because there is a commit containing the text
'DO NOT MERGE'. Remove this commit from the branch before merging
or change the commit summary."

- uses: actions/checkout@v4

- name: Check requirements.txt for branches
shell: bash
run: |
FILE="requirements.txt"
MATCH=tickets/DM-
if grep -q $MATCH $FILE
then
echo "Ticket branches found in $FILE:"
grep -n $MATCH $FILE
exit 1
fi
11 changes: 11 additions & 0 deletions .github/workflows/formatting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Check Python formatting

on:
push:
branches:
- main
pull_request:

jobs:
call-workflow:
uses: lsst/rubin_workflows/.github/workflows/formatting.yaml@main
16 changes: 16 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Lint Python code

on:
push:
branches:
- main
pull_request:

jobs:
call-workflow:
uses: lsst/rubin_workflows/.github/workflows/lint.yaml@main
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
11 changes: 11 additions & 0 deletions .github/workflows/mypy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Run mypy

on:
push:
branches:
- main
pull_request:

jobs:
call-workflow:
uses: lsst/rubin_workflows/.github/workflows/mypy.yaml@main
7 changes: 7 additions & 0 deletions .github/workflows/rebase_checker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: Check that 'main' is not merged into the development branch

on: pull_request

jobs:
call-workflow:
uses: lsst/rubin_workflows/.github/workflows/rebase_checker.yaml@main
11 changes: 11 additions & 0 deletions .github/workflows/yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Lint YAML files

on:
push:
branches:
- main
pull_request:

jobs:
call-workflow:
uses: lsst/rubin_workflows/.github/workflows/yamllint.yaml@main
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,6 @@ cython_debug/

# PyPI configuration file
.pypirc

# lsst version file
python/lsst/sdm_tools/version.py
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-yaml
args:
- "--unsafe"
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.4.2
hooks:
- id: black
# It is recommended to specify the latest version of Python
# supported by your project here, or alternatively use
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
language_version: python3.12
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.8
hooks:
- id: ruff
20 changes: 20 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
extends: default

rules:
document-start:
present: false
ignore: |
/tests/
/examples/
line-length:
max: 132
allow-non-breakable-words: true
allow-non-breakable-inline-mappings: true
ignore: |
/.github/workflows/lint.yaml
truthy:
# "on" as a key in workflows confuses things
ignore: |
/.github/workflows/
indentation:
indent-sequences: consistent
140 changes: 140 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
[build-system]
requires = ["setuptools", "lsst-versions >= 1.3.0"]
build-backend = "setuptools.build_meta"

[project]
name = "sdm_tools"
description = "Tools for working with the Science Data Model (SDM) schemas of the Rubin Observatory"
license = {text = "GNU General Public License v3 or later (GPLv3+)"}
readme = "README.md"
authors = [
{name="Rubin Observatory Data Management", email="[email protected]"},
]
classifiers = [
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Scientific/Engineering :: Astronomy"
]
keywords = ["lsst"]
dependencies = [
"lsst-felis",
"click",
"deepdiff",
]
requires-python = ">=3.11.0"
dynamic = ["version"]

[project.urls]
Source = "https://github.com/lsst-dm/sdm_tools"

[project.optional-dependencies]
test = [
"pytest >= 3.2"
]

[tool.setuptools.packages.find]
where = ["python"]

[tool.setuptools]
zip-safe = true
license-files = ["COPYRIGHT", "LICENSE"]

[tool.setuptools.package-data]
"sdm_tools" = ["py.typed"]

[tool.setuptools.dynamic]
version = { attr = "lsst_versions.get_lsst_version" }

[project.scripts]
sdm-tools = "lsst.sdm_tools.cli:cli"

[tool.black]
line-length = 110
target-version = ["py311"]

[tool.isort]
profile = "black"
line_length = 110

[tool.lsst_versions]
write_to = "python/lsst/sdm_tools/version.py"

[tool.ruff]
line-length = 110
target-version = "py311"
exclude = [
"__init__.py",
"lex.py",
"yacc.py",
]

[tool.ruff.lint]
ignore = [
"D100",
"D102",
"D104",
"D105",
"D107",
"D200",
"D203",
"D205",
"D213",
"D400",
"D413",
"N802",
"N803",
"N806",
"N812",
"N815",
"N816",
"N999",
"UP007", # Allow UNION in type annotation
]
select = [
"E", # pycodestyle
"F", # pycodestyle
"N", # pep8-naming
"W", # pycodestyle
"D", # pydocstyle
"UP", # pyupgrade
]

[tool.pydocstyle]
convention = "numpy"
# Our coding style does not require docstrings for magic methods (D105)
# Our docstyle documents __init__ at the class level (D107)
# We allow methods to inherit docstrings and this is not compatible with D102.
# Docstring at the very first line is not required
# D200, D205 and D400 all complain if the first sentence of the docstring does
# not fit on one line. We do not require docstrings in __init__ files (D104).
add-ignore = ["D107", "D105", "D102", "D100", "D200", "D205", "D400", "D104"]

[tool.ruff.lint.pycodestyle]
max-doc-length = 79

[tool.ruff.lint.pydocstyle]
convention = "numpy"

[tool.numpydoc_validation]
checks = [
"all", # All except the rules listed below.
"SA01", # See Also section.
"SA04", # We don't use descriptions with See Also.
"EX01", # Example section.
"SS06", # Summary can go into second line.
"GL01", # Summary text can start on same line as """
"GL08", # Do not require docstring.
"ES01", # No extended summary required.
"SS05", # pydocstyle is better at finding infinitive verb.
"PR04", # Sphinx does not require parameter type.
]
exclude = [
"^test_.*", # Do not test docstrings in test code.
'^__init__$',
'\._[a-zA-Z_]+$', # Private methods.
]
20 changes: 20 additions & 0 deletions python/lsst/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file is part of sdm_tools.
#
# Developed for the LSST Data Management System.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
22 changes: 22 additions & 0 deletions python/lsst/sdm_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This file is part of sdm-tools.
#
# Developed for the LSST Data Management System.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from .version import *
Loading
Loading