Skip to content

Commit

Permalink
Release request commit created with Cranko.
Browse files Browse the repository at this point in the history
+++ cranko-rc-info-v1
[[projects]]
qnames = ["toasty", "pypa"]
bump_spec = "micro bump"

+++
  • Loading branch information
cranko committed Jul 21, 2024
2 parents d3ff252 + 6b5c0c2 commit adba318
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 27 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# rc: minor bump
# rc: micro bump

- 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
allows you to force the choice of a specific method. In particular, sometimes
Expand Down
4 changes: 2 additions & 2 deletions ci/azure-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
12 changes: 2 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"]
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
4 changes: 3 additions & 1 deletion toasty/_libtoasty.pyx
Original file line number Diff line number Diff line change
@@ -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
Expand Down
44 changes: 33 additions & 11 deletions toasty/par_util.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# -*- 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
import sys

SHOW_INFORMATIONAL_MESSAGES = True


def resolve_parallelism(parallel):
"""Decide what level of parallelism to use.
Expand All @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion toasty/samplers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit adba318

Please sign in to comment.