Skip to content
Merged
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
45 changes: 45 additions & 0 deletions .github/actions/setup-python/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Setup Python Environment
description: Setup Python, reinstall pip, and install dependencies
inputs:
python-version:
required: true

runs:
using: "composite"
steps:
- name: Cache pip dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ hashFiles('requirements/release.txt') }}-${{ hashFiles('requirements/dev.txt') }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

- name: Reinstall pip
shell: bash
run: |
PY_VER=$(python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
PY_MAJOR=$(echo $PY_VER | cut -d. -f1)
PY_MINOR=$(echo $PY_VER | cut -d. -f2)

if [ "$PY_MAJOR" -eq 3 ] && [ "$PY_MINOR" -le 8 ]; then
URL="https://bootstrap.pypa.io/pip/${PY_VER}/get-pip.py"
else
URL="https://bootstrap.pypa.io/get-pip.py"
fi

curl -sS "$URL" -o /tmp/get-pip.py
python /tmp/get-pip.py --force-reinstall

pip --version
pip3 --version

- name: Install dependencies
shell: bash
run: |
python3 -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install --upgrade -r requirements.txt; fi
pip3 install --upgrade -r requirements/dev.txt
76 changes: 29 additions & 47 deletions .github/workflows/push-pr_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,66 +9,60 @@ jobs:
if: github.event_name == 'pull_request'

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Checkout the whole history, in case the target is way far behind

- name: Check if target branch has been merged
run: |
if git merge-base --is-ancestor ${{ github.event.pull_request.base.sha }} ${{ github.sha }}; then
echo "Target branch has been merged into the source branch."
else
echo "Target branch has not been merged into the source branch. Please merge in target first."
exit 1
fi

- name: Check that CHANGELOG has been updated
run: |
# If this step fails, this means you haven't updated the CHANGELOG.md file with notes on your contribution.
git diff --name-only $(git merge-base origin/main HEAD) | grep '^CHANGELOG.md$' && echo "Thanks for helping keep our CHANGELOG up-to-date!"
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q '^CHANGELOG.md$'; then
echo "Thanks for helping keep our CHANGELOG up-to-date!"
else
echo "Please update the CHANGELOG.md file with notes on your contribution."
exit 1
fi

Lint:
runs-on: ubuntu-latest
env:
MAX_LINE_LENGTH: 88
MAX_COMPLEXITY: 18
MAX_LINE_LENGTH: 127
MAX_COMPLEXITY: 15

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- uses: actions/checkout@v4

- name: Check cache
uses: actions/cache@v2
- uses: ./.github/actions/setup-python
with:
path: ~/.cache/pip
key: ${{ hashFiles('requirements/release.txt') }}-${{ hashFiles('requirements/dev.txt') }}

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install --upgrade -r requirements.txt; fi
pip3 install --upgrade -r requirements/dev.txt
python-version: '3.x'

- name: Lint with flake8
if: always()
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --max-complexity=$MAX_COMPLEXITY --statistics --max-line-length=$MAX_LINE_LENGTH

- name: Lint with isort
if: always()
run: |
python3 -m isort --check --line-length $MAX_LINE_LENGTH spellbook
# Skipping test_conduit due to temporary fix for missing conduit python package.
python3 -m isort --check --line-length $MAX_LINE_LENGTH --skip tests/data_formatting/conduit/test_conduit.py tests
python3 -m isort --check --line-length $MAX_LINE_LENGTH *.py
isort --check --line-length $MAX_LINE_LENGTH spellbook tests *.py

- name: Lint with Black
if: always()
run: |
python3 -m black --check --line-length $MAX_LINE_LENGTH --target-version py36 spellbook
python3 -m black --check --line-length $MAX_LINE_LENGTH --target-version py36 tests
python3 -m black --check --line-length $MAX_LINE_LENGTH --target-version py36 *.py
black --check --line-length $MAX_LINE_LENGTH --target-version py311 spellbook tests *.py

- name: Lint with PyLint
if: always()
run: |
python3 -m pylint spellbook --rcfile=setup.cfg --exit-zero
python3 -m pylint tests --rcfile=setup.cfg --exit-zero
pylint spellbook tests --rcfile=setup.cfg --exit-zero

Local-test-suite:
runs-on: ubuntu-latest
Expand All @@ -78,23 +72,11 @@ jobs:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v4

- name: Check cache
uses: actions/cache@v2
- uses: ./.github/actions/setup-python
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/release.txt') }}-${{ hashFiles('requirements/dev.txt') }}

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip3 install -r requirements/dev.txt
python-version: ${{ matrix.python-version }}

- name: Install merlin-spellbook to run unit tests
run: |
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ All notable changes to Merlin Spellbook will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.10.0]

### Added
- Added normal and truncnorm distributions
- COPYRIGHT file for ownership details
- New check for copyright headers in the Makefile

### Changed
- Updated GitHub actions
- Now uses a version of actions/cache that's not deprecated
- Utilizes a shared action for jobs to reduce duplicate code
- Copyright headers in all files
- These now point to the LICENSE and COPYRIGHT files
- LICENSE: Legal permissions (e.g., MIT terms)
- COPYRIGHT: Ownership, institutional metadata
- Make commands that change version/copyright year have been modified

## [0.9.0]

### Added
Expand Down
9 changes: 9 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Luc Peterson <[email protected]>
Peter Robinson <[email protected]>
Jessica Semler <[email protected]>
Benjamin Bay
Joe Koning <[email protected]>
Jeremy White <[email protected]>
Aidan Keogh
Ryan Lee <[email protected]>
Brian Gunnarson <[email protected]>
10 changes: 10 additions & 0 deletions COPYRIGHT
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Copyright (c) 2019–2025 Lawrence Livermore National Laboratory

Produced at the Lawrence Livermore National Laboratory

LLNL-CODE-797170

All rights reserved.

See the CONTRIBUTORS file for a full list of authors and contributors.
See the LICENSE file for license details.
4 changes: 3 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
MIT License

Copyright (c) 2022 Lawrence Livermore National Laboratory
See the COPYRIGHT file for ownership and authorship information.

For details, see https://github.com/LLNL/merlin-spellbook.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
42 changes: 31 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ VER?=1.0.0
VSTRING=[0-9]\+\.[0-9]\+\.[0-9]\+
PYTHON?=python3
PY_TARGET_VER?=py311 # At the time this is added (2/19/25) black only supports up to py311
FROM?=Unreleased

PROJ=spellbook
TEST=tests
Expand All @@ -25,17 +26,22 @@ tests: unit-tests command-line-tests
release:
python3 -m build .

# Use like this: make VER=?.?.? verison
# Increment the Spellbook version. USE ONLY ON DEVELOP BEFORE MERGING TO MASTER.
# Usage: make version VER=1.13.0 FROM=1.13.0-beta
# (defaults to FROM=Unreleased if not set)
version:
# do spellbook/__init__.py
sed -i 's/__version__ = "$(VSTRING)"/__version__ = "$(VER)"/g' $(PROJ)/__init__.py
# do CHANGELOG.md
sed -i 's/## \[Unreleased\]/## [$(VER)]/g' CHANGELOG.md
# do all file headers (works on linux)
find $(PROJ)/ -type f -print0 | xargs -0 sed -i 's/Version: $(VSTRING)/Version: $(VER)/g'
find *.py -type f -print0 | xargs -0 sed -i 's/Version: $(VSTRING)/Version: $(VER)/g'
find $(TEST)/ -type f -print0 | xargs -0 sed -i 's/Version: $(VSTRING)/Version: $(VER)/g'
find Makefile -type f -print0 | xargs -0 sed -i 's/Version: $(VSTRING)/Version: $(VER)/g'
@echo "Updating Spellbook version from [$(FROM)] to [$(VER)]..."
sed -i 's/__version__ = "\(.*\)"/__version__ = "$(VER)"/' spellbook/__init__.py
@if grep -q "## \[$(FROM)\]" CHANGELOG.md; then \
sed -i 's/## \[$(FROM)\]/## [$(VER)]/' CHANGELOG.md; \
else \
echo "⚠️ No matching '## [$(FROM)]' found in CHANGELOG.md"; \
fi

# Increment copyright year = Usage: make year YEAR=2026
year:
@echo "Updating COPYRIGHT file to year $(YEAR)..."
sed -i -E 's/(Copyright \(c\) 2019–)[0-9]{4}( Lawrence Livermore National Laboratory)/\1$(YEAR)\2/' COPYRIGHT

clean:
-find $(PROJ) -name "*.py[cod]" -exec rm -f {} \;
Expand Down Expand Up @@ -79,4 +85,18 @@ check-pylint:
$(PYTHON) -m pylint $(TEST) --rcfile=setup.cfg; \


check-style: check-flake8 check-black check-isort check-pylint
check-copyright:
@echo "🔍 Checking for required copyright header..."
@missing_files=$$(find $(PROJ) $(TEST) \
-name '*.py' -print | \
xargs grep -L "Copyright (c) Lawrence Livermore National Security, LLC and other" || true); \
if [ -n "$$missing_files" ]; then \
echo "❌ The following files are missing the required copyright header:"; \
echo "$$missing_files"; \
exit 1; \
else \
echo "✅ All files contain the required header."; \
fi


check-style: check-copyright check-flake8 check-black check-isort check-pylint
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
line_length=88
line_length=127
known_first_party=merlin
known_third_party=psutil,conduit,matplotlib,pandas,numpy
lines_after_imports=2


[flake8]
ignore = E203, E266, E501, W503
max-line-length = 88
max-complexity = 18
max-line-length = 127
max-complexity = 15
select = B,C,E,F,W,T4

[mypy]
Expand Down
41 changes: 8 additions & 33 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,10 @@
###############################################################################
# Copyright (c) 2022, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory
# Written by the Merlin dev team, listed in the CONTRIBUTORS file.
# <[email protected]>
#
# LLNL-CODE-797170
# All rights reserved.
# This file is part of Merlin-Spellbook, Version: 0.9.0.
#
# For details, see https://github.com/LLNL/merlin-spellbook.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
###############################################################################
##############################################################################
# Copyright (c) Lawrence Livermore National Security, LLC and other
# Merlin-Spellbook Project developers. See top-level LICENSE and COPYRIGHT
# files for dates and other details. No copyright assignment is required to
# contribute to Merlin-Spellbook.
##############################################################################


import os

Expand Down Expand Up @@ -58,10 +36,7 @@ def _pip_requirement(req):
def _reqs(*f):
return [
_pip_requirement(r)
for r in (
_strip_comments(line)
for line in open(os.path.join(os.getcwd(), "requirements", *f)).readlines()
)
for r in (_strip_comments(line) for line in open(os.path.join(os.getcwd(), "requirements", *f)).readlines())
if r
]

Expand Down
9 changes: 8 additions & 1 deletion spellbook/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
__version__ = "0.9.0"
##############################################################################
# Copyright (c) Lawrence Livermore National Security, LLC and other
# Merlin-Spellbook Project developers. See top-level LICENSE and COPYRIGHT
# files for dates and other details. No copyright assignment is required to
# contribute to Merlin-Spellbook.
##############################################################################

__version__ = "0.10.0"

VERSION = __version__
7 changes: 7 additions & 0 deletions spellbook/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
##############################################################################
# Copyright (c) Lawrence Livermore National Security, LLC and other
# Merlin-Spellbook Project developers. See top-level LICENSE and COPYRIGHT
# files for dates and other details. No copyright assignment is required to
# contribute to Merlin-Spellbook.
##############################################################################

import sys

from spellbook.main import main
Expand Down
7 changes: 7 additions & 0 deletions spellbook/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
##############################################################################
# Copyright (c) Lawrence Livermore National Security, LLC and other
# Merlin-Spellbook Project developers. See top-level LICENSE and COPYRIGHT
# files for dates and other details. No copyright assignment is required to
# contribute to Merlin-Spellbook.
##############################################################################

from abc import ABC, abstractmethod


Expand Down
Loading