From 0a28bb038bb82c2c4ae07433c04ce0f0f79d59bf Mon Sep 17 00:00:00 2001 From: ndilalla Date: Mon, 12 Aug 2024 17:24:11 -0700 Subject: [PATCH 01/17] Using np.asarray() to support numpy 2.0 --- astromodels/functions/function.py | 12 ++++++------ astromodels/functions/functions_1D/extinction.py | 2 +- astromodels/functions/template_model.py | 4 ++-- astromodels/xspec/factory.py | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/astromodels/functions/function.py b/astromodels/functions/function.py index d58757a1..3ab23b3e 100644 --- a/astromodels/functions/function.py +++ b/astromodels/functions/function.py @@ -1479,7 +1479,7 @@ def __call__(self, x): # Transform the input to an array of floats. If x is a single number, this will be an array of size 1 - new_input = np.array(x, dtype=float, ndmin=1, copy=False) + new_input = np.asarray(x, dtype=float) # Compute the function @@ -1705,8 +1705,8 @@ def __call__(self, x, y, *args, **kwargs): # Transform the input to an array of floats - new_x = np.array(x, dtype=float, ndmin=1, copy=False) - new_y = np.array(y, dtype=float, ndmin=1, copy=False) + new_x = np.asarray(x, dtype=float) + new_y = np.asarray(y, dtype=float) # Compute the function @@ -1876,9 +1876,9 @@ def __call__(self, x, y, z): # This is either a single number or a list # Transform the input to an array of floats - new_x = np.array(x, dtype=float, ndmin=1, copy=False) - new_y = np.array(y, dtype=float, ndmin=1, copy=False) - new_z = np.array(z, dtype=float, ndmin=1, copy=False) + new_x = np.asarray(x, dtype=float) + new_y = np.asarray(y, dtype=float) + new_z = np.asarray(z, dtype=float) # Compute the function diff --git a/astromodels/functions/functions_1D/extinction.py b/astromodels/functions/functions_1D/extinction.py index 3c55d5c6..0be335fd 100644 --- a/astromodels/functions/functions_1D/extinction.py +++ b/astromodels/functions/functions_1D/extinction.py @@ -89,7 +89,7 @@ def evaluate(self, x, e_bmv, rv, redshift): if isinstance(x, astropy_units.Quantity): - _x = np.array(x.to("keV").value, ndmin=1, copy=False, dtype=float) + _x = np.asarray(x.to("keV").value, dtype=float) _unit = astropy_units.cm**2 _y_unit = astropy_units.dimensionless_unscaled diff --git a/astromodels/functions/template_model.py b/astromodels/functions/template_model.py index 5861da0f..e351e384 100644 --- a/astromodels/functions/template_model.py +++ b/astromodels/functions/template_model.py @@ -760,8 +760,8 @@ def _interpolate(self, energies, scale, parameters_values): # a dimensionless quantity (actually we take the .value property) because otherwise # the logarithm below will fail. - energies = np.array( - energies.to("keV").value, ndmin=1, copy=False, dtype=float + energies = np.asarray( + energies.to("keV").value, dtype=float ) # Same for the scale diff --git a/astromodels/xspec/factory.py b/astromodels/xspec/factory.py index edef7d3e..405be7f0 100644 --- a/astromodels/xspec/factory.py +++ b/astromodels/xspec/factory.py @@ -486,7 +486,7 @@ def evaluate(self, x, $PARAMETERS_NAMES$): if isinstance(x, u.Quantity): - x = np.array(x.to('keV').value, ndmin=1, copy=False, dtype=float) + x = np.asarray(x.to('keV').value, dtype=float) quantity = True From e3a13ba5a1472371abe7335aa6e917dde28ef0e9 Mon Sep 17 00:00:00 2001 From: ndilalla Date: Mon, 12 Aug 2024 18:01:05 -0700 Subject: [PATCH 02/17] Reverting to np.array() with copy=None --- astromodels/functions/function.py | 12 ++++++------ astromodels/functions/functions_1D/extinction.py | 2 +- astromodels/functions/template_model.py | 4 ++-- astromodels/xspec/factory.py | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/astromodels/functions/function.py b/astromodels/functions/function.py index 3ab23b3e..bbe57ad9 100644 --- a/astromodels/functions/function.py +++ b/astromodels/functions/function.py @@ -1479,7 +1479,7 @@ def __call__(self, x): # Transform the input to an array of floats. If x is a single number, this will be an array of size 1 - new_input = np.asarray(x, dtype=float) + new_input = np.array(x, dtype=float, ndmin=1, copy=None) # Compute the function @@ -1705,8 +1705,8 @@ def __call__(self, x, y, *args, **kwargs): # Transform the input to an array of floats - new_x = np.asarray(x, dtype=float) - new_y = np.asarray(y, dtype=float) + new_x = np.array(x, dtype=float, ndmin=1, copy=None) + new_y = np.array(y, dtype=float, ndmin=1, copy=None) # Compute the function @@ -1876,9 +1876,9 @@ def __call__(self, x, y, z): # This is either a single number or a list # Transform the input to an array of floats - new_x = np.asarray(x, dtype=float) - new_y = np.asarray(y, dtype=float) - new_z = np.asarray(z, dtype=float) + new_x = np.array(x, dtype=float, ndmin=1, copy=None) + new_y = np.array(y, dtype=float, ndmin=1, copy=None) + new_z = np.array(z, dtype=float, ndmin=1, copy=None) # Compute the function diff --git a/astromodels/functions/functions_1D/extinction.py b/astromodels/functions/functions_1D/extinction.py index 0be335fd..f75d535e 100644 --- a/astromodels/functions/functions_1D/extinction.py +++ b/astromodels/functions/functions_1D/extinction.py @@ -89,7 +89,7 @@ def evaluate(self, x, e_bmv, rv, redshift): if isinstance(x, astropy_units.Quantity): - _x = np.asarray(x.to("keV").value, dtype=float) + _x = np.array(x.to("keV").value, ndmin=1, copy=None, dtype=float) _unit = astropy_units.cm**2 _y_unit = astropy_units.dimensionless_unscaled diff --git a/astromodels/functions/template_model.py b/astromodels/functions/template_model.py index e351e384..d8b55917 100644 --- a/astromodels/functions/template_model.py +++ b/astromodels/functions/template_model.py @@ -760,8 +760,8 @@ def _interpolate(self, energies, scale, parameters_values): # a dimensionless quantity (actually we take the .value property) because otherwise # the logarithm below will fail. - energies = np.asarray( - energies.to("keV").value, dtype=float + energies = np.array( + energies.to("keV").value, ndmin=1, copy=None, dtype=float ) # Same for the scale diff --git a/astromodels/xspec/factory.py b/astromodels/xspec/factory.py index 405be7f0..401e6808 100644 --- a/astromodels/xspec/factory.py +++ b/astromodels/xspec/factory.py @@ -486,7 +486,7 @@ def evaluate(self, x, $PARAMETERS_NAMES$): if isinstance(x, u.Quantity): - x = np.asarray(x.to('keV').value, dtype=float) + x = np.array(x.to('keV').value, ndmin=1, copy=None, dtype=float) quantity = True From d2c9c242cb79db547ccbaac1f3465f2ffe1c78aa Mon Sep 17 00:00:00 2001 From: ndilalla Date: Tue, 13 Aug 2024 12:26:34 -0700 Subject: [PATCH 03/17] Adding copy_if_needed argument. --- astromodels/functions/function.py | 13 +++++++------ astromodels/functions/functions_1D/extinction.py | 3 ++- astromodels/functions/template_model.py | 3 ++- astromodels/utils/file_utils.py | 8 +++++++- astromodels/xspec/factory.py | 3 ++- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/astromodels/functions/function.py b/astromodels/functions/function.py index bbe57ad9..d9b4b6f4 100644 --- a/astromodels/functions/function.py +++ b/astromodels/functions/function.py @@ -24,6 +24,7 @@ from astromodels.utils.logging import setup_logger from astromodels.utils.pretty_list import dict_to_list from astromodels.utils.table import dict_to_table +from astromodels.utils.file_utils import copy_if_needed from yaml.reader import ReaderError log = setup_logger(__name__) @@ -1479,7 +1480,7 @@ def __call__(self, x): # Transform the input to an array of floats. If x is a single number, this will be an array of size 1 - new_input = np.array(x, dtype=float, ndmin=1, copy=None) + new_input = np.array(x, dtype=float, ndmin=1, copy=copy_if_needed) # Compute the function @@ -1705,8 +1706,8 @@ def __call__(self, x, y, *args, **kwargs): # Transform the input to an array of floats - new_x = np.array(x, dtype=float, ndmin=1, copy=None) - new_y = np.array(y, dtype=float, ndmin=1, copy=None) + new_x = np.array(x, dtype=float, ndmin=1, copy=copy_if_needed) + new_y = np.array(y, dtype=float, ndmin=1, copy=copy_if_needed) # Compute the function @@ -1876,9 +1877,9 @@ def __call__(self, x, y, z): # This is either a single number or a list # Transform the input to an array of floats - new_x = np.array(x, dtype=float, ndmin=1, copy=None) - new_y = np.array(y, dtype=float, ndmin=1, copy=None) - new_z = np.array(z, dtype=float, ndmin=1, copy=None) + new_x = np.array(x, dtype=float, ndmin=1, copy=copy_if_needed) + new_y = np.array(y, dtype=float, ndmin=1, copy=copy_if_needed) + new_z = np.array(z, dtype=float, ndmin=1, copy=copy_if_needed) # Compute the function diff --git a/astromodels/functions/functions_1D/extinction.py b/astromodels/functions/functions_1D/extinction.py index f75d535e..c5fac1d4 100644 --- a/astromodels/functions/functions_1D/extinction.py +++ b/astromodels/functions/functions_1D/extinction.py @@ -9,6 +9,7 @@ from astromodels.functions.function import Function1D, FunctionMeta from astromodels.utils.logging import setup_logger +from astromodels.utils.file_utils import copy_if_needed log = setup_logger(__name__) @@ -89,7 +90,7 @@ def evaluate(self, x, e_bmv, rv, redshift): if isinstance(x, astropy_units.Quantity): - _x = np.array(x.to("keV").value, ndmin=1, copy=None, dtype=float) + _x = np.array(x.to("keV").value, ndmin=1, copy=copy_if_needed, dtype=float) _unit = astropy_units.cm**2 _y_unit = astropy_units.dimensionless_unscaled diff --git a/astromodels/functions/template_model.py b/astromodels/functions/template_model.py index d8b55917..a42ef75f 100644 --- a/astromodels/functions/template_model.py +++ b/astromodels/functions/template_model.py @@ -21,6 +21,7 @@ from astromodels.functions.function import Function1D, FunctionMeta from astromodels.utils import get_user_data_path from astromodels.utils.logging import setup_logger +from astromodels.utils.file_utils import copy_if_needed log = setup_logger(__name__) @@ -761,7 +762,7 @@ def _interpolate(self, energies, scale, parameters_values): # the logarithm below will fail. energies = np.array( - energies.to("keV").value, ndmin=1, copy=None, dtype=float + energies.to("keV").value, ndmin=1, copy=copy_if_needed, dtype=float ) # Same for the scale diff --git a/astromodels/utils/file_utils.py b/astromodels/utils/file_utils.py index 5c16a394..b70415fe 100644 --- a/astromodels/utils/file_utils.py +++ b/astromodels/utils/file_utils.py @@ -3,11 +3,17 @@ import os from pathlib import Path - +import numpy as np import pkg_resources _custom_config_path = os.environ.get("ASTROMODELS_CONFIG") +copy_if_needed: Optional[bool] + +if np.lib.NumpyVersion(np.__version__) >= "2.0.0": + copy_if_needed = None +else: + copy_if_needed = False def _get_data_file_path(data_file: str) -> Path: """ diff --git a/astromodels/xspec/factory.py b/astromodels/xspec/factory.py index 401e6808..0adddfb1 100644 --- a/astromodels/xspec/factory.py +++ b/astromodels/xspec/factory.py @@ -431,6 +431,7 @@ def get_models(model_dat_path): from astromodels.functions.function import FunctionMeta, Function1D import numpy as np import astropy.units as u +from astromodels.utils.file_utils import copy_if_needed from astromodels.xspec import _xspec import six @@ -486,7 +487,7 @@ def evaluate(self, x, $PARAMETERS_NAMES$): if isinstance(x, u.Quantity): - x = np.array(x.to('keV').value, ndmin=1, copy=None, dtype=float) + x = np.array(x.to('keV').value, ndmin=1, copy=copy_if_needed, dtype=float) quantity = True From 831f979d7879a2ffb0c30569fe26798c385df6b2 Mon Sep 17 00:00:00 2001 From: ndilalla Date: Tue, 13 Aug 2024 12:33:13 -0700 Subject: [PATCH 04/17] Minor. --- astromodels/utils/file_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/astromodels/utils/file_utils.py b/astromodels/utils/file_utils.py index b70415fe..33cb13de 100644 --- a/astromodels/utils/file_utils.py +++ b/astromodels/utils/file_utils.py @@ -3,6 +3,7 @@ import os from pathlib import Path +from typing import Optional import numpy as np import pkg_resources From 734fa78bb8e5d48026fe883e80b2d76f8eb50d84 Mon Sep 17 00:00:00 2001 From: ndilalla Date: Tue, 13 Aug 2024 12:39:06 -0700 Subject: [PATCH 05/17] Minor. --- astromodels/utils/file_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/astromodels/utils/file_utils.py b/astromodels/utils/file_utils.py index 33cb13de..f4dfda58 100644 --- a/astromodels/utils/file_utils.py +++ b/astromodels/utils/file_utils.py @@ -16,6 +16,7 @@ else: copy_if_needed = False + def _get_data_file_path(data_file: str) -> Path: """ Returns the absolute path to the required data files. From 936cf7781fb0d25f9a43d57a0bc704b81e2512d8 Mon Sep 17 00:00:00 2001 From: ndilalla Date: Mon, 9 Sep 2024 14:29:24 -0400 Subject: [PATCH 06/17] Trying to remove architecture. --- .github/workflows/deploy.yml | 6 +++--- .github/workflows/docs.yml | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6f1cc34f..09ef669c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -98,7 +98,7 @@ jobs: with: activate-environment: "test_env" auto-activate-base: false - architecture: "x64" + #architecture: "x64" miniforge-variant: Mambaforge #miniforge-version: latest python-version: ${{ matrix.python-version }} @@ -174,7 +174,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, macos-12] python-version: [3.9] steps: @@ -195,7 +195,7 @@ jobs: with: activate-environment: "test_env" auto-activate-base: false - architecture: "x64" + #architecture: "x64" miniforge-variant: Mambaforge #miniforge-version: latest python-version: ${{ matrix.python-version }} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index e375bf1a..ea72b77b 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -48,7 +48,8 @@ jobs: - name: Execute the notebooks #shell: bash -l {0} run: | - + # Make sure we fail in case of error + set -e # Download an example file wget https://www.astropy.org/astropy-data/photometry/spitzer_example_image.fits From 7c7904a48053248462abe7e56bdca031511f2233 Mon Sep 17 00:00:00 2001 From: ndilalla Date: Mon, 9 Sep 2024 14:41:44 -0400 Subject: [PATCH 07/17] Trying to remove architecture. --- .github/workflows/test_and_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_and_build.yml b/.github/workflows/test_and_build.yml index 0e17e96c..d6ecbcca 100644 --- a/.github/workflows/test_and_build.yml +++ b/.github/workflows/test_and_build.yml @@ -119,7 +119,7 @@ jobs: with: activate-environment: "test_env" auto-activate-base: false - architecture: "x64" + #architecture: "x64" #mamba-version: "*" miniforge-version: latest python-version: ${{ matrix.python-version }} From 47e782ccf92e5cb37580d02232da81cc080dac1a Mon Sep 17 00:00:00 2001 From: ndilalla Date: Tue, 10 Sep 2024 09:41:46 -0400 Subject: [PATCH 08/17] First import. --- ci/environment_noxspec.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 ci/environment_noxspec.yml diff --git a/ci/environment_noxspec.yml b/ci/environment_noxspec.yml new file mode 100644 index 00000000..16b332f5 --- /dev/null +++ b/ci/environment_noxspec.yml @@ -0,0 +1,27 @@ +name: test_env + +channels: + - conda-forge + - defaults + +dependencies: + - python + - numpy + - pyyaml>=5.1 + - astropy + - scipy + - numdifftools + - hdf5 + - pytables + - pandas>=0.23 + - dill + - wcslib + - future + - numba + - h5py + - interpolation>=2.2.3 + - libgfortran + - omegaconf + - colorama + - rich + - joblib From 62b74d38dd178548582acae525c1d420480de232 Mon Sep 17 00:00:00 2001 From: ndilalla Date: Tue, 10 Sep 2024 09:42:18 -0400 Subject: [PATCH 09/17] Removing xspec-modelsonly installation for macos-latest. --- .github/workflows/deploy.yml | 32 +++++++++++++++++----------- .github/workflows/test_and_build.yml | 6 +++++- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 09ef669c..89a0fc89 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -75,7 +75,10 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, macos-12] python-version: [3.9] - + include: + - environment: ci/environment.yml + - environment: ci/environment_noxspec.yml + os: macos-latest steps: - name: Checkout uses: actions/checkout@v4 @@ -103,7 +106,7 @@ jobs: #miniforge-version: latest python-version: ${{ matrix.python-version }} auto-update-conda: true - environment-file: ci/environment.yml + environment-file: ${{ matrix.environment }} use-only-tar-bz2: true channel-priority: true channels: conda-forge, xspecmodels, threeml @@ -176,20 +179,23 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, macos-12] python-version: [3.9] - + include: + - environment: ci/environment.yml + - environment: ci/environment_noxspec.yml + os: macos-latest steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Cache conda - uses: actions/cache@v4 - env: - # Increase this value to reset cache if etc/example-environment.yml has not changed - CACHE_NUMBER: 0 - with: - path: ~/conda_pkgs_dir - key: conda-${{ matrix.os }}-python-${{ matrix.python-version }}-${{ hashFiles('ci/environment.yml') }} + #- name: Cache conda + # uses: actions/cache@v4 + # env: + # # Increase this value to reset cache if etc/example-environment.yml has not changed + # CACHE_NUMBER: 0 + # with: + # path: ~/conda_pkgs_dir + # key: conda-${{ matrix.os }}-python-${{ matrix.python-version }}-${{ hashFiles('ci/environment.yml') }} - name: Add conda ${{ matrix.python-version }} to system path uses: conda-incubator/setup-miniconda@v3 with: @@ -200,7 +206,7 @@ jobs: #miniforge-version: latest python-version: ${{ matrix.python-version }} auto-update-conda: true - environment-file: ci/environment.yml + environment-file: ${{ matrix.environment }} use-only-tar-bz2: true channel-priority: true channels: conda-forge, xspecmodels, threeml @@ -254,7 +260,7 @@ jobs: LABEL="--label dev" fi - +.github/workflows/test_and_build.yml if [[ ${{matrix.os}} == ubuntu-latest ]]; then diff --git a/.github/workflows/test_and_build.yml b/.github/workflows/test_and_build.yml index d6ecbcca..796d3ea4 100644 --- a/.github/workflows/test_and_build.yml +++ b/.github/workflows/test_and_build.yml @@ -102,6 +102,10 @@ jobs: matrix: os: ["ubuntu-latest", "macos-latest", "macos-12"] python-version: [3.9] + include: + - environment: ci/environment.yml + - environment: ci/environment_noxspec.yml + os: macos-latest runs-on: ${{ matrix.os }} steps: - name: Checkout @@ -124,7 +128,7 @@ jobs: miniforge-version: latest python-version: ${{ matrix.python-version }} auto-update-conda: true - environment-file: ci/environment.yml + environment-file: ${{ matrix.environment }} use-only-tar-bz2: true channel-priority: strict channels: conda-forge, xspecmodels From 17968b00b7a5fde41500f56cc58c525a384b254a Mon Sep 17 00:00:00 2001 From: ndilalla Date: Tue, 10 Sep 2024 09:43:30 -0400 Subject: [PATCH 10/17] Removing xspec-modelsonly installation for macos-latest. --- .github/workflows/deploy.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 89a0fc89..f2f49d8e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -260,7 +260,6 @@ jobs: LABEL="--label dev" fi -.github/workflows/test_and_build.yml if [[ ${{matrix.os}} == ubuntu-latest ]]; then From 8f0ae00f22e38226198d18ba6f460dff05d7f845 Mon Sep 17 00:00:00 2001 From: ndilalla Date: Tue, 10 Sep 2024 10:08:19 -0400 Subject: [PATCH 11/17] Second attempt to remove xspec-modelsonly for macos-latest. --- .github/workflows/test_and_build.yml | 10 ++++++++++ conda-dist/recipe/meta.yaml | 22 +++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test_and_build.yml b/.github/workflows/test_and_build.yml index 796d3ea4..854eafca 100644 --- a/.github/workflows/test_and_build.yml +++ b/.github/workflows/test_and_build.yml @@ -172,6 +172,16 @@ jobs: - name: Test conda install shell: bash -l {0} + run: python -m pytest -vv --cov=astromodels --cov-report=xml + if: ${{matrix.os}} == "macos-latest" + env: + OMP_NUM_THREADS: 1 + MKL_NUM_THREADS: 1 + NUMEXPR_NUM_THREADS: 1 + MPLBACKEND: "Agg" + - name: Test conda install + shell: bash -l {0} + if: ${{matrix.os}} != "macos-latest" run: | echo "======> importing XSPEC..." diff --git a/conda-dist/recipe/meta.yaml b/conda-dist/recipe/meta.yaml index bf055a51..9e072ca5 100644 --- a/conda-dist/recipe/meta.yaml +++ b/conda-dist/recipe/meta.yaml @@ -13,10 +13,10 @@ requirements: - {{ compiler('c') }} # [linux] - {{ compiler('cxx') }} # [linux] - {{ compiler('fortran') }} # [linux] - - xspec-modelsonly - - cfitsio - - ccfits - - wcslib + - xspec-modelsonly #[not arm64] + - cfitsio # [not arm64] + - ccfits # [not arm64] + - wcslib # [not arm64] host: - python @@ -25,10 +25,10 @@ requirements: - numpy - pyyaml>=5.1 - pandas>=0.23 - - cfitsio - - ccfits - - wcslib - - xspec-modelsonly + - cfitsio # [not arm64] + - ccfits # [not arm64] + - wcslib # [not arm64] + - xspec-modelsonly # [not arm64] - future - numba>=0.54 - h5py @@ -46,9 +46,9 @@ requirements: - pytables - pandas>=0.23 - dill - - cfitsio - - ccfits - - wcslib + - cfitsio # [not arm64] + - ccfits # [not arm64] + - wcslib # [not arm64] - future - numba>=0.54 - h5py From 5b4a5689336559d284bbd8cfbcbc5d87625262df Mon Sep 17 00:00:00 2001 From: ndilalla Date: Tue, 10 Sep 2024 10:28:27 -0400 Subject: [PATCH 12/17] Trying again. --- .github/workflows/test_and_build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_and_build.yml b/.github/workflows/test_and_build.yml index 854eafca..ceebdf89 100644 --- a/.github/workflows/test_and_build.yml +++ b/.github/workflows/test_and_build.yml @@ -171,17 +171,17 @@ jobs: flake8 - name: Test conda install + if: matrix.os == 'macos-latest' shell: bash -l {0} run: python -m pytest -vv --cov=astromodels --cov-report=xml - if: ${{matrix.os}} == "macos-latest" env: OMP_NUM_THREADS: 1 MKL_NUM_THREADS: 1 NUMEXPR_NUM_THREADS: 1 MPLBACKEND: "Agg" - name: Test conda install + if: matrix.os != 'macos-latest' shell: bash -l {0} - if: ${{matrix.os}} != "macos-latest" run: | echo "======> importing XSPEC..." From 138a525ed90161333a8d74bc0c375efcfe92ed75 Mon Sep 17 00:00:00 2001 From: ndilalla Date: Tue, 10 Sep 2024 11:15:06 -0400 Subject: [PATCH 13/17] Actions updated. --- .github/workflows/deploy.yml | 34 +++++----------------------- .github/workflows/test_and_build.yml | 33 ++++----------------------- 2 files changed, 11 insertions(+), 56 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f2f49d8e..2eb63b66 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -84,26 +84,12 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - # - name: Set up Python - # uses: actions/setup-python@v5 - # with: - # python-version: ${{ matrix.python-version }} - # - name: Cache conda - # uses: actions/cache@v4 - # env: - # # Increase this value to reset cache if etc/example-environment.yml has not changed - # CACHE_NUMBER: 0 - # with: - # path: ~/conda_pkgs_dir - # key: conda-${{ matrix.os }}-python-${{ matrix.python-version }}-${{ hashFiles('ci/environment.yml') }} - name: Add conda ${{ matrix.python-version }} to system path uses: conda-incubator/setup-miniconda@v3 with: activate-environment: "test_env" auto-activate-base: false - #architecture: "x64" miniforge-variant: Mambaforge - #miniforge-version: latest python-version: ${{ matrix.python-version }} auto-update-conda: true environment-file: ${{ matrix.environment }} @@ -158,13 +144,13 @@ jobs: #conda install --use-local astromodels conda install -c ${CONDA}/envs/test_env/conda-bld/ astromodels - - name: Test conda build + - name: Test import xspec + if: matrix.os != 'macos-latest' shell: bash -l {0} - run: | - cd astromodels/tests - echo "======> importing XSPEC..." - python -c "import astromodels.xspec" - python -m pytest -vv --cov=astromodels --cov-report=xml + run: python -c "import astromodels.xspec" + - name: Test astromodels + shell: bash -l {0} + run: python -m pytest -vv --cov=astromodels --cov-report=xml env: OMP_NUM_THREADS: 1 MKL_NUM_THREADS: 1 @@ -188,14 +174,6 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - #- name: Cache conda - # uses: actions/cache@v4 - # env: - # # Increase this value to reset cache if etc/example-environment.yml has not changed - # CACHE_NUMBER: 0 - # with: - # path: ~/conda_pkgs_dir - # key: conda-${{ matrix.os }}-python-${{ matrix.python-version }}-${{ hashFiles('ci/environment.yml') }} - name: Add conda ${{ matrix.python-version }} to system path uses: conda-incubator/setup-miniconda@v3 with: diff --git a/.github/workflows/test_and_build.yml b/.github/workflows/test_and_build.yml index ceebdf89..9020170c 100644 --- a/.github/workflows/test_and_build.yml +++ b/.github/workflows/test_and_build.yml @@ -110,21 +110,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - # - name: Cache conda - # uses: actions/cache@v4 - # env: - # # Increase this value to reset cache if etc/example-environment.yml has not changed - # CACHE_NUMBER: 0 - # with: - # path: ~/conda_pkgs_dir - # key: conda-${{ matrix.os }}-python-${{ matrix.python-version }}-${{ hashFiles('ci/environment.yml') }} - name: Add conda ${{ matrix.python-version }} to system path uses: conda-incubator/setup-miniconda@v3 with: activate-environment: "test_env" auto-activate-base: false - #architecture: "x64" - #mamba-version: "*" miniforge-version: latest python-version: ${{ matrix.python-version }} auto-update-conda: true @@ -132,8 +122,6 @@ jobs: use-only-tar-bz2: true channel-priority: strict channels: conda-forge, xspecmodels - - - name: Init Env shell: bash -l {0} run: | @@ -170,24 +158,13 @@ jobs: # stop the build if there are Python syntax errors or undefined names flake8 - - name: Test conda install - if: matrix.os == 'macos-latest' + - name: Test import xspec + if: matrix.os != 'macos-latest' shell: bash -l {0} - run: python -m pytest -vv --cov=astromodels --cov-report=xml - env: - OMP_NUM_THREADS: 1 - MKL_NUM_THREADS: 1 - NUMEXPR_NUM_THREADS: 1 - MPLBACKEND: "Agg" - - name: Test conda install - if: matrix.os != 'macos-latest' + run: python -c "import astromodels.xspec" + - name: Test astromodels shell: bash -l {0} - run: | - - echo "======> importing XSPEC..." - python -c "import astromodels.xspec" - python -m pytest -vv --cov=astromodels --cov-report=xml - + run: python -m pytest -vv --cov=astromodels --cov-report=xml env: OMP_NUM_THREADS: 1 MKL_NUM_THREADS: 1 From 5ab76e94a08efeb9249113c1b270af86a872546c Mon Sep 17 00:00:00 2001 From: ndilalla Date: Tue, 10 Sep 2024 11:32:40 -0400 Subject: [PATCH 14/17] Minor fix. --- .github/workflows/deploy.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2eb63b66..023cfd2b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -147,7 +147,9 @@ jobs: - name: Test import xspec if: matrix.os != 'macos-latest' shell: bash -l {0} - run: python -c "import astromodels.xspec" + run: | + cd astromodels/tests + python -c "import astromodels.xspec" - name: Test astromodels shell: bash -l {0} run: python -m pytest -vv --cov=astromodels --cov-report=xml From 948ec0eb4f8521f151d4b4b216534b79f7b16e9e Mon Sep 17 00:00:00 2001 From: ndilalla Date: Tue, 10 Sep 2024 16:15:07 -0400 Subject: [PATCH 15/17] Upload fixed. --- .github/workflows/deploy.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 023cfd2b..90e12cd6 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -245,6 +245,11 @@ jobs: anaconda -v --show-traceback -t $UPLOAD_TOKEN upload -u threeml ${CONDA}/envs/test_env/conda-bld/linux-64/*.tar.bz2 --force $LABEL + elif [[ ${{matrix.os}} == macos-latest ]]; + then + + anaconda -v --show-traceback -t $UPLOAD_TOKEN upload -u threeml ${CONDA}/envs/test_env/conda-bld/osx-arm64/*.tar.bz2 --force $LABEL + else anaconda -v --show-traceback -t $UPLOAD_TOKEN upload -u threeml ${CONDA}/envs/test_env/conda-bld/osx-64/*.tar.bz2 --force $LABEL From 6325d78b0341350324cb4ba4c3dd4cb6a685ccad Mon Sep 17 00:00:00 2001 From: ndilalla Date: Fri, 31 Jan 2025 15:45:59 -0800 Subject: [PATCH 16/17] Replacing macos-12 and mambaforge. --- .github/workflows/deploy.yml | 8 ++++---- .github/workflows/test_and_build.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 90e12cd6..4ac4e14c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -73,7 +73,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, macos-12] + os: [ubuntu-latest, macos-latest, macos-13] python-version: [3.9] include: - environment: ci/environment.yml @@ -89,7 +89,7 @@ jobs: with: activate-environment: "test_env" auto-activate-base: false - miniforge-variant: Mambaforge + miniforge-variant: Miniforge3 python-version: ${{ matrix.python-version }} auto-update-conda: true environment-file: ${{ matrix.environment }} @@ -165,7 +165,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest, macos-12] + os: [ubuntu-latest, macos-latest, macos-13] python-version: [3.9] include: - environment: ci/environment.yml @@ -182,7 +182,7 @@ jobs: activate-environment: "test_env" auto-activate-base: false #architecture: "x64" - miniforge-variant: Mambaforge + miniforge-variant: Miniforge3 #miniforge-version: latest python-version: ${{ matrix.python-version }} auto-update-conda: true diff --git a/.github/workflows/test_and_build.yml b/.github/workflows/test_and_build.yml index 9020170c..a32a82b3 100644 --- a/.github/workflows/test_and_build.yml +++ b/.github/workflows/test_and_build.yml @@ -37,7 +37,7 @@ jobs: fail-fast: false matrix: python-version: ["3.9", "3.10", "3.11"] - os: ["ubuntu-latest", "macos-latest", "macos-12"] + os: ["ubuntu-latest", "macos-latest", "macos-13"] runs-on: ${{ matrix.os }} steps: - name: Checkout @@ -100,7 +100,7 @@ jobs: strategy: fail-fast: false matrix: - os: ["ubuntu-latest", "macos-latest", "macos-12"] + os: ["ubuntu-latest", "macos-latest", "macos-13"] python-version: [3.9] include: - environment: ci/environment.yml From feeffd21a0aa0a9d013f36747d24f04e7e99a7fd Mon Sep 17 00:00:00 2001 From: ndilalla Date: Fri, 31 Jan 2025 15:51:47 -0800 Subject: [PATCH 17/17] Minor. --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4ac4e14c..40c46a51 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -107,7 +107,7 @@ jobs: miniconda_os=Linux compilers="gcc_linux-64 gxx_linux-64 gfortran_linux-64" - else # osx + else miniconda_os=MacOSX compilers="clang_osx-64 clangxx_osx-64 gfortran_osx-64"