diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ac1ed3..4954172 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +# toasty 0.19.1 (2024-07-21) + +- Update for Numpy 2.0 compatibility (#102, @pkgw). Previous releases will + work in most cases, but are not 100% compatible. +- If guessing parallelism in a Slurm HPC execution environment, try to respect + the job's resource allocation (#101, @pkgw). Often, on an HPC cluster the + number of CPU cores on the host machine will be a bad indicator of the + parallelism level that you should target, because you may only be allocated a + small fraction of them. + + # toasty 0.19.0 (2023-12-14) - Implement a `--tiling-method` argument for `toasty view` (#97, @pkgw). This diff --git a/ci/azure-build-and-test.yml b/ci/azure-build-and-test.yml index fde849f..cb8de6e 100644 --- a/ci/azure-build-and-test.yml +++ b/ci/azure-build-and-test.yml @@ -16,12 +16,12 @@ parameters: PYTHON_SERIES: "3.9" - name: macos_310 - vmImage: macos-11 + vmImage: macos-12 vars: PYTHON_SERIES: "3.10" - name: macos_39 - vmImage: macos-11 + vmImage: macos-12 vars: PYTHON_SERIES: "3.9" diff --git a/ci/zenodo.json5 b/ci/zenodo.json5 index 950e233..ffa0f87 100644 --- a/ci/zenodo.json5 +++ b/ci/zenodo.json5 @@ -42,13 +42,13 @@ ], "language": "eng", "license": "MIT", - "publication_date": "2023-12-14", - "title": "toasty 0.19.0", + "publication_date": "2024-07-21", + "title": "toasty 0.19.1", "upload_type": "software", - "version": "0.19.0" + "version": "0.19.1" }, "conceptdoi": "10.5281/zenodo.7055476", - "record_id": "10383112", - "doi": "10.5281/zenodo.10383112", - "bucket_link": "https://zenodo.org/api/files/0f1838fd-9749-4f07-a18c-79180e5ffd9f" + "record_id": "12790601", + "doi": "10.5281/zenodo.12790601", + "bucket_link": "https://zenodo.org/api/files/0dce2679-0986-4ff3-b5c3-552445129113" } diff --git a/docs/conf.py b/docs/conf.py index 24306b5..7348851 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -4,7 +4,7 @@ author = "Chris Beaumont and the AAS WorldWide Telescope Team" copyright = "2014-2020, " + author -release = "0.19.0" # cranko project-version +release = "0.19.1" # cranko project-version version = ".".join(release.split(".")[:2]) extensions = [ diff --git a/pyproject.toml b/pyproject.toml index dd523fb..c74d140 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,14 +1,6 @@ [build-system] -requires = [ - 'cython', - 'oldest-supported-numpy', - 'setuptools', - 'wheel', -] +requires = ['cython', 'numpy', 'setuptools', 'wheel'] build-backend = 'setuptools.build_meta' [tool.cranko] -annotated_files = [ - "docs/conf.py", - "toasty/cli.py", -] +annotated_files = ["docs/conf.py", "toasty/cli.py"] diff --git a/setup.py b/setup.py index 54a9ff9..dbfdd1b 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ def get_long_desc(): setup_args = dict( name="toasty", # cranko project-name - version="0.19.0", # cranko project-version + version="0.19.1", # cranko project-version description="Generate image tile pyramids from existing image data", long_description=get_long_desc(), long_description_content_type="text/markdown", @@ -94,7 +94,11 @@ def get_long_desc(): "build_ext": build_ext, }, ext_modules=[ - Extension("toasty._libtoasty", ["toasty/_libtoasty.pyx"]), + Extension( + "toasty._libtoasty", + ["toasty/_libtoasty.pyx"], + define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")], + ), ], include_dirs=[ np.get_include(), diff --git a/toasty/_libtoasty.pyx b/toasty/_libtoasty.pyx index 70e4dad..762a0aa 100644 --- a/toasty/_libtoasty.pyx +++ b/toasty/_libtoasty.pyx @@ -1,9 +1,11 @@ from libc.math cimport sin, cos, atan2, hypot -import numpy as np cimport cython cimport numpy as np +import numpy as np + +np.import_array() DTYPE = np.float64 ctypedef np.float64_t DTYPE_t diff --git a/toasty/cli.py b/toasty/cli.py index 640a453..8ae4820 100644 --- a/toasty/cli.py +++ b/toasty/cli.py @@ -249,11 +249,11 @@ def show_impl(settings): print(doi) elif settings.show_command == "version": # This string constant will be rewritten by Cranko during releases: - version = "0.19.0" # cranko project-version + version = "0.19.1" # cranko project-version print(version) elif settings.show_command == "version-doi": # This string constant will be rewritten by Cranko during releases: - doi = "10.5281/zenodo.10383112" + doi = "10.5281/zenodo.12790601" if not doi.startswith("10."): warn("this DOI is a fake value used for development builds") print(doi) diff --git a/toasty/par_util.py b/toasty/par_util.py index b8a1481..f411681 100644 --- a/toasty/par_util.py +++ b/toasty/par_util.py @@ -1,16 +1,15 @@ # -*- mode: python; coding: utf-8 -*- -# Copyright 2020 the AAS WorldWide Telescope project +# Copyright 2020-2024 the WorldWide Telescope project # Licensed under the MIT License. """Utilities for parallel processing """ -from __future__ import absolute_import, division, print_function -__all__ = ''' +__all__ = """ SHOW_INFORMATIONAL_MESSAGES resolve_parallelism -'''.split() +""".split() import multiprocessing as mp import os @@ -18,6 +17,7 @@ SHOW_INFORMATIONAL_MESSAGES = True + def resolve_parallelism(parallel): """Decide what level of parallelism to use. @@ -32,17 +32,39 @@ def resolve_parallelism(parallel): """ if parallel is None: - if mp.get_start_method() == 'fork': - parallel = os.cpu_count() + if mp.get_start_method() == "fork": + parallel = None + + # If we seem to be an HPC job, try to guess the number of CPUs based + # on the job allocation of CPUs/cores, which might be much lower + # than the number of CPUs on the system. Slurm sets many variables + # related to this stuff; I *think* the one we're using here is the + # most appropriate? + + slurm_alloc = os.environ.get("SLURM_NPROCS") + if slurm_alloc: + try: + parallel = int(slurm_alloc) + except ValueError: + pass + + # If we're still not sure, go with the system CPU count + + if parallel is None: + parallel = os.cpu_count() + if SHOW_INFORMATIONAL_MESSAGES and parallel > 1: - print(f'info: parallelizing processing over {parallel} CPUs') + print(f"info: parallelizing processing over {parallel} CPUs") else: parallel = 1 - if parallel > 1 and mp.get_start_method() != 'fork': - print('''warning: parallel processing was requested but is not possible - because this operating system is not using `fork`-based multiprocessing - On macOS a bug prevents forking: https://bugs.python.org/issue33725''', file=sys.stderr) + if parallel > 1 and mp.get_start_method() != "fork": + print( + """warning: parallel processing was requested but is not possible + because this operating system is not using `fork`-based multiprocessing. + On macOS a bug prevents forking: https://bugs.python.org/issue33725""", + file=sys.stderr, + ) parallel = 1 if parallel > 1: diff --git a/toasty/samplers.py b/toasty/samplers.py index b68e633..e5c7492 100644 --- a/toasty/samplers.py +++ b/toasty/samplers.py @@ -152,7 +152,8 @@ def healpix_fits_file_sampler( # needed. data = data[data.dtype.names[0]] if data.dtype.byteorder not in "=|": - data = data.byteswap().newbyteorder() + data = data.byteswap() + data = data.view(data.dtype.newbyteorder()) nest = hdr.get("ORDERING") == "NESTED" coord = hdr.get("COORDSYS", "C")