Skip to content

Commit

Permalink
Merge branch 'benchmarking' into fitsioloader-plus-new-benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
SolarDrew committed Jun 21, 2024
2 parents 308906f + f0fc4a5 commit f30d509
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/sunpy/package-template",
"commit": "6d6729b22066ef890e70c37438da70cac33e03b4",
"commit": "c79fc5bff74958e24c9a925a330b8d3aa138f4ce",
"checkout": null,
"context": {
"cookiecutter": {
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: python -m pip install .[tests] pytest-codspeed fitsio
- run: python -m pip install .[tests] pytest-codspeed 'numpy<2' fitsio
- run: |
parfive https://g-a36282.cd214.a567.data.globus.org/user_tools_tutorial_data/BKPLX_stokesI.tar
mkdir -p $HOME/dkist_data/BKPLX
tar -xv -f BKPLX_stokesI.tar --directory $HOME/dkist_data/BKPLX
- name: Run benchmarks
uses: CodspeedHQ/action@v2
with:
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/sub_package_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ jobs:
branch: cruft/update
commit-message: "Automatic package template update"
title: Updates from the package template
- add-paths: .cruft.json
body: reject these changes for this repo.
branch: cruft/reject
commit-message: "Reject this package template update"
title: Reject new updates from package template

steps:
- uses: actions/checkout@v4
Expand All @@ -42,7 +37,7 @@ jobs:
python-version: "3.11"

- name: Install Cruft
run: python -m pip install cruft
run: python -m pip install git+https://github.com/Cadair/cruft@patch-p1

- name: Check if update is available
continue-on-error: false
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ instance/
docs/_build/
# automodapi
docs/api
docs/sg_execution_times.rst

# PyBuilder
.pybuilder/
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
# This should be before any formatting hooks like isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.3.5"
rev: "v0.4.8"
hooks:
- id: ruff
args: ["--fix"]
Expand All @@ -26,10 +26,10 @@ repos:
- id: mixed-line-ending
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|.asdf|.json|.hdr)$"
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
args: [ "--write-changes", "-D", "-", "-D", ".codespell-dict.txt"]
ci:
autofix_prs: false
autoupdate_schedule: "weekly"
autoupdate_schedule: "quarterly"
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ Bug Fixes
Trivial/Internal Changes
------------------------

- Migate to the asdf 2.8+ ``Converter`` interface, this bumps various
- Migrate to the asdf 2.8+ ``Converter`` interface, this bumps various
dependencies but should have no effect on reading or writing asdf files. (`#152 <https://github.com/DKISTDC/dkist/pull/152>`_)


Expand Down
6 changes: 6 additions & 0 deletions dkist/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,9 @@ def visp_dataset_no_headers(tmp_path_factory):
with open(vispdir / "test_visp_no_headers.asdf", mode="wb") as afo:
afo.write(gfo.read())
return load_dataset(vispdir / "test_visp_no_headers.asdf")


@pytest.fixture(scope="session")
def real_visp(tmp_path_factory):
vispdir = Path.home() / "dkist_data" / "BKPLX"
return load_dataset(vispdir)
8 changes: 4 additions & 4 deletions dkist/net/attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,10 @@ def __init__(self, bottom_left, *, top_right=None, width: _u.deg = None,
bottom_left = bottom_left.transform_to(_Helioprojective(observer="earth"))
top_right = top_right.transform_to(_Helioprojective(observer="earth"))

self.hpc_bounding_box_arcsec = ((bottom_left.Tx.to_value(_u.arcsec),
bottom_left.Ty.to_value(_u.arcsec)),
(top_right.Tx.to_value(_u.arcsec),
top_right.Ty.to_value(_u.arcsec)))
self.hpc_bounding_box_arcsec = ((float(bottom_left.Tx.to_value(_u.arcsec)),
float(bottom_left.Ty.to_value(_u.arcsec))),
(float(top_right.Tx.to_value(_u.arcsec)),
float(top_right.Ty.to_value(_u.arcsec))))

self.search_type = search

Expand Down
6 changes: 3 additions & 3 deletions dkist/tests/test_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ def plot_and_save_fig(ds=visp_dataset_no_headers, axes=axes):


@pytest.mark.benchmark
def test_dataset_compute_data(benchmark, small_visp_dataset):

benchmark(small_visp_dataset.data.compute)
def test_dataset_compute_data(benchmark, real_visp):
ds = real_visp[0, :5]
benchmark(ds.data.compute)
2 changes: 1 addition & 1 deletion dkist/utils/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __missing__(self, key):


def _key_clean(key):
key = re.sub("[%s]" % re.escape(string.punctuation), "_", key)
key = re.sub(f"[{re.escape(string.punctuation)}]", "_", key)
key = key.replace(" ", "_")
key = "".join(char for char in key
if char.isidentifier() or char.isnumeric())
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ tests = [
"pytest-doctestplus",
"pytest-cov",
"pytest-remotedata",
"pytest-cov",
"pytest-mock",
"pytest-mpl",
"pytest-httpserver",
"pytest-filter-subpackage",
"pytest-benchmark",
"pytest-xdist",
"hypothesis",
"tox",
"pydot",
Expand Down Expand Up @@ -85,6 +85,7 @@ zip-safe = false
include-package-data = true

[tool.setuptools.packages.find]
exclude = ["dkist._dev*"]

[tool.setuptools_scm]
write_to = "dkist/_version.py"
Expand Down
22 changes: 14 additions & 8 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,23 @@ norecursedirs =
.history
dkist/extern
doctest_plus = enabled
doctest_optionflags = NORMALIZE_WHITESPACE FLOAT_CMP ELLIPSIS
doctest_optionflags =
NORMALIZE_WHITESPACE
FLOAT_CMP
ELLIPSIS
text_file_format = rst
addopts = --doctest-rst -p no:unraisableexception -p no:threadexception
markers =
online: marks this test function as needing online connectivity.
figure: marks this test function as using hash-based Matplotlib figure verification. This mark is not meant to be directly applied, but is instead automatically applied when a test function uses the @sunpy.tests.helpers.figure_test decorator.
benchmark: marks this test as a benchmark
# Disable internet access for tests not marked remote_data
remote_data_strict = True
asdf_schema_root = dkist/io/asdf/resources/
asdf_schema_tests_enabled = true
markers =
online: marks this test function as needing online connectivity.
figure: marks this test function as using hash-based Matplotlib figure verification. This mark is not meant to be directly applied, but is instead automatically applied when a test function uses the @sunpy.tests.helpers.figure_test decorator.
benchmark: marks this test as a benchmark
addopts =
--doctest-rst
-p no:unraisableexception
-p no:threadexception
filterwarnings =
# Turn all warnings into errors so they do not pass silently.
error
Expand Down Expand Up @@ -52,7 +58,7 @@ filterwarnings =
# debugging.
ignore:the imp module is deprecated in favour of importlib:DeprecationWarning:ipykernel.iostream
# Ignore warnings about asdf versions
ignore:File.*asdf.extension.BuiltinExtension.*:asdf.exceptions.AsdfWarning
ignore:File.*asdf.extension.BuiltinExtension.*
# pytest / asdf interaction
ignore:The .* argument to AsdfSchemaFile is deprecated
# gwcs main has the wrong version number: https://github.com/spacetelescope/gwcs/issues/399
Expand All @@ -71,7 +77,7 @@ filterwarnings =
ignore:The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
ignore:Subclassing validator classes is not intended to be part of their public API
# Ignore warning so gwcs 0.18.3 can load
ignore:Converter handles multiple tags for this extension:asdf.exceptions.AsdfWarning
ignore:Converter handles multiple tags for this extension
# https://github.com/pandas-dev/pandas/issues/54466
ignore:\nPyarrow will become a required dependency of pandas in the next major release of pandas:DeprecationWarning
# This seems to be coming out of pandas
Expand Down
45 changes: 27 additions & 18 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ envlist =
py{310,311,312}
py312-devdeps
py310-oldestdeps
py312-benchmarks
build_docs{,-notebooks}
codestyle
benchmarks

[testenv]
pypi_filter = https://raw.githubusercontent.com/sunpy/sunpy/main/.test_package_pins.txt
Expand All @@ -34,8 +34,6 @@ set_env =
MPLBACKEND = agg
COLUMNS = 180
devdeps: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/astropy/simple https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
# Define the base test command here to allow us to add more flags for each tox factor
PYTEST_COMMAND = pytest -vvv -r fEs --pyargs dkist --cov-report=xml --cov=dkist --cov-config={toxinidir}/.coveragerc {toxinidir}/docs --benchmark-skip
deps =
# For packages which publish nightly wheels this will pull the latest nightly
devdeps: astropy>=0.0.dev0
Expand All @@ -59,15 +57,22 @@ commands_pre =
pip install fitsio
pip freeze --all --no-input
commands =
# To run different commands for different factors exclude the factor from the default command like this
# !online: {env:PYTEST_COMMAND} {posargs}
# Then specify a specific one like this
# online: {env:PYTEST_COMMAND} --remote-data=any {posargs}
{env:PYTEST_COMMAND} \
# To amend the pytest command for different factors you can add a line
# which starts with a factor like `online: --remote-data=any \`
# If you have no factors which require different commands this is all you need:
pytest \
-vvv \
-r fEs \
--pyargs dkist \
--cov-report=xml \
--cov=dkist \
--cov-config={toxinidir}/.coveragerc \
{toxinidir}/docs \
online: --remote-data=any \
# It's not possible to test the new schemas with the oldest dependencies
# as the new schemas require new dependent schemas
oldestdeps: -o asdf_schema_tests_enabled=false
!benchmarks: --benchmark-skip \
benchmarks: -m benchmark \
benchmarks: --benchmark-autosave \
oldestdeps: -o asdf_schema_tests_enabled=false \
{posargs}

[testenv:codestyle]
Expand All @@ -89,11 +94,15 @@ extras =
commands =
pip freeze --all --no-input
# Disable parallel here due to https://github.com/astropy/astropy/issues/14916
!notebooks: sphinx-build -j 1 --color -W --keep-going -b html -d _build/.doctrees . _build/html -D nb_execution_mode=off {posargs}
notebooks: sphinx-build -j 1 --color -W --keep-going -b html -d _build/.doctrees . _build/html {posargs}
sphinx-build \
-j 1 \
--color \
-W \
--keep-going \
-b html \
-d _build/.doctrees \
. \
_build/html \
!notebooks: -D nb_execution_mode=off \
{posargs}
python -c 'import pathlib; print("Documentation available under file://\{0\}".format(pathlib.Path(r"{toxinidir}") / "docs" / "_build" / "index.html"))'

[testenv:benchmarks]
description = Run benchmarks on PR and compare against main to ensure there are no performance regressions
allowlist_externals=git
commands = {env:PYTEST_COMMAND} -m benchmark --benchmark-autosave

0 comments on commit f30d509

Please sign in to comment.