Skip to content

Commit

Permalink
require python<3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
moustakas committed Dec 11, 2024
2 parents 308383f + 48e25f5 commit ba861bd
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 52 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
python-version: ['3.10', '3.11']
python-version: ['3.10', '3.11', '3.12']
env:
DESIUTIL_VERSION: 3.4.3

Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
python-version: ['3.10', '3.11']
python-version: ['3.10', '3.11', '3.12']
env:
DESIUTIL_VERSION: 3.4.3

Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ['3.11']
python-version: ['3.12']

steps:
- name: Checkout code
Expand All @@ -103,7 +103,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ['3.11']
python-version: ['3.12']

steps:
- name: Checkout code
Expand Down
17 changes: 10 additions & 7 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ Welcome to the Documentation for FastSpecFit
Overview
--------

``FastSpecFit`` is a stellar continuum and emission-line modeling code for `DESI
<https://desi.lbl.gov>`_ which is optimized for speed and simplicity; it uses
physically motivated stellar population synthesis and emission-line templates to
jointly model the three-camera optical spectrophotometry from DESI and the
ultraviolet through infrared broadband photometry (``fastspec``). Alternatively,
it can be used to model just the broadband photometry (``fastphot``), although
in either case DESI redshifts are required.
``FastSpecFit`` is a stellar continuum and emission-line modeling code which is
optimized for speed and simplicity; it uses physically motivated stellar
population synthesis and emission-line templates to jointly model UV/optical
spectrophotometry and ultraviolet through infrared broadband photometry
(``fastspec``). Alternatively, it can be used to model just the broadband
photometry (``fastphot``).

``FastSpecFit`` currently only supports `DESI <https://desi.lbl.gov>`_
spectrophotometric data, although contributions to develop the software for
other instruments and surveys are more than welcome.

Contents
--------
Expand Down
103 changes: 103 additions & 0 deletions docker/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
FROM ubuntu:24.04

RUN mkdir -p /src
WORKDIR /src

RUN apt-get -y clean && apt -y update && apt install -y apt-utils && apt -y upgrade && echo 1

RUN DEBIAN_FRONTEND=noninteractive \
apt install -y --no-install-recommends \
build-essential \
gfortran \
wget \
git \
pkg-config \
libbz2-dev \
libgsl-dev \
libssl-dev \
libcfitsio-dev \
libcfitsio-bin \
# libhdf5 needed by h5py
libhdf5-dev \
# needed by mpich \
python3.12 \
python3.12-dev \
python3-pip \
# python3-mpi4py \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# python = python3
RUN ln -s "$(which python3)" /usr/bin/python

ARG mpich=4.1.1
ARG mpich_prefix=mpich-$mpich

ENV FFLAGS="-fallow-argument-mismatch" \
FCFLAGS="-fallow-argument-mismatch"

RUN wget --no-check-certificate -nv https://www.mpich.org/static/downloads/$mpich/$mpich_prefix.tar.gz \
&& tar xvzf $mpich_prefix.tar.gz \
&& cd $mpich_prefix \
&& ./configure \
&& make -j 4 \
&& make install \
&& make clean \
&& cd .. \
&& rm -rf $mpich_prefix

RUN /sbin/ldconfig

RUN for x in \
wheel \
setuptools \
pytest \
numpy \
scipy \
astropy \
healpy \
fitsio \
numba \
intel-cmplr-lib-rt \
mpi4py \
seaborn \
matplotlib \
ipython \
ipykernel \
h5py \
; do pip3 install --break-system-packages $x; done \
&& rm -Rf /root/.cache/pip \
&& echo 1

ENV DESIUTIL_VERSION 3.4.3
ENV DESIMODEL_VERSION 0.19.2
ENV DESITARGET_VERSION 2.8.0
ENV DESISPEC_VERSION 0.68.1
ENV SPECLITE_VERSION v0.20
ENV FASTSPECFIT_VERSION 3.1.0

RUN pip3 install --break-system-packages git+https://github.com/desihub/desiutil.git@${DESIUTIL_VERSION}#egg=desiutil
RUN pip3 install --break-system-packages git+https://github.com/desihub/desimodel.git@${DESIMODEL_VERSION}#egg=desimodel
RUN pip3 install --break-system-packages git+https://github.com/desihub/desitarget.git@${DESITARGET_VERSION}#egg=desitarget
RUN pip3 install --break-system-packages git+https://github.com/desihub/desispec.git@${DESISPEC_VERSION}#egg=desispec
RUN pip3 install --break-system-packages git+https://github.com/desihub/speclite.git@${SPECLITE_VERSION}#egg=speclite
RUN pip3 install --break-system-packages git+https://github.com/desihub/fastspecfit.git@${FASTSPECFIT_VERSION}#egg=fastspecfit && echo 1

RUN mkdir /homedir && chmod 777 /homedir
ENV HOME /homedir

#ENV NUMBA_CACHE_DIR=/homedir/numba_cache
#RUN chmod 777 /homedir/numba_cache

# set prompt and default shell
SHELL ["/bin/bash", "-c"]
ENTRYPOINT ["/bin/bash", "-c"]
CMD ["/bin/bash"]

#RUN echo "export PS1='[container] \\u@\\h:\\w$ '" >> $HOME/.bashrc \
# # Create config files in $HOME
# && python -c "import astropy" \
# && python -c "import matplotlib.font_manager as fm; f = fm.FontManager()" \
# && ipython -c "print('hello')" \
# && echo 1

LABEL Maintainer="John Moustakas [email protected]"
51 changes: 29 additions & 22 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM ubuntu:22.04
FROM ubuntu:24.04.1

RUN mkdir -p /src
WORKDIR /src

RUN apt-get -y clean && apt -y update && apt install -y apt-utils && apt -y upgrade && echo 2
RUN apt-get -y clean && apt -y update && apt install -y apt-utils && apt -y upgrade && echo 1

RUN DEBIAN_FRONTEND=noninteractive \
apt install -y --no-install-recommends \
Expand All @@ -19,7 +19,7 @@ RUN DEBIAN_FRONTEND=noninteractive \
libcfitsio-bin \
# libhdf5 needed by h5py
libhdf5-dev \
# mpich \
# needed by mpich \
python3-dev \
python3-pip \
# python3-mpi4py \
Expand All @@ -28,7 +28,7 @@ RUN DEBIAN_FRONTEND=noninteractive \
# python = python3
RUN ln -s "$(which python3)" /usr/bin/python

ARG mpich=4.0.2
ARG mpich=4.1.1
ARG mpich_prefix=mpich-$mpich

ENV FFLAGS="-fallow-argument-mismatch" \
Expand Down Expand Up @@ -56,6 +56,7 @@ RUN for x in \
healpy \
fitsio \
numba \
intel-cmplr-lib-rt \
mpi4py \
seaborn \
matplotlib \
Expand All @@ -64,28 +65,34 @@ RUN for x in \
h5py \
; do pip3 install $x; done \
&& rm -Rf /root/.cache/pip \
&& echo 2
&& echo 1

ENV DESIUTIL_VERSION 3.2.6
ENV DESIMODEL_VERSION 0.18.0
ENV DESITARGET_VERSION 2.6.0
ENV DESISPEC_VERSION 0.57.0
ENV SPECLITE_VERSION v0.16
ENV FASTSPECFIT_VERSION 2.1.1
RUN python -m pip install --index-url https://software.repos.intel.com/python/pypi \
--extra-index-url https://pypi.org/simple mkl_fft

ENV DESIUTIL_VERSION 3.4.3
ENV DESIMODEL_VERSION 0.19.2
ENV DESITARGET_VERSION 2.8.0
ENV DESISPEC_VERSION 0.68.1
ENV SPECLITE_VERSION v0.20
ENV FASTSPECFIT_VERSION main

RUN pip3 install git+https://github.com/desihub/desiutil.git@${DESIUTIL_VERSION}#egg=desiutil
RUN pip3 install git+https://github.com/desihub/desimodel.git@${DESIMODEL_VERSION}#egg=desimodel
RUN pip3 install git+https://github.com/desihub/desitarget.git@${DESITARGET_VERSION}#egg=desitarget
RUN pip3 install git+https://github.com/desihub/desispec.git@${DESISPEC_VERSION}#egg=desispec
RUN pip3 install git+https://github.com/desihub/speclite.git@${SPECLITE_VERSION}#egg=speclite
RUN pip3 install git+https://github.com/desihub/fastspecfit.git@${FASTSPECFIT_VERSION}#egg=fastspecfit && echo 1.1
RUN pip3 install git+https://github.com/desihub/fastspecfit.git@${FASTSPECFIT_VERSION}#egg=fastspecfit && echo 1

ENV PYTHONPATH /src/fastspecfit/py
ENV PATH /src/fastspecfit/bin:/opt/conda/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

RUN mkdir /homedir && chmod 777 /homedir
ENV HOME /homedir

ENV NUMBA_CACHE_DIR=/homedir/numba_cache
RUN chmod 777 /homedir/numba_cache

# set prompt and default shell
SHELL ["/bin/bash", "-c"]
ENTRYPOINT ["/bin/bash", "-c"]
Expand All @@ -96,15 +103,15 @@ RUN echo "export PS1='[container] \\u@\\h:\\w$ '" >> $HOME/.bashrc \
&& python -c "import astropy" \
&& python -c "import matplotlib.font_manager as fm; f = fm.FontManager()" \
&& ipython -c "print('hello')" \
# Download astropy site locations and USNO sky model
&& python -c "from astropy.coordinates import EarthLocation; EarthLocation._get_site_registry(force_download=True)" \
&& python -c "from astropy.coordinates import EarthLocation, SkyCoord, AltAz; from astropy.time import Time; print(EarthLocation.of_site('ctio')); print(SkyCoord(180.,-45.,unit='deg').transform_to(AltAz(obstime=Time(56806.0, format='mjd'), location=EarthLocation.of_site('ctio'))))" \
# Download astropy IERS leap-second list
&& python -c "from astropy.time import Time; Time.now()" \
# Make astropy cache files readable!?!!
&& chmod -R a+rwX $HOME/.astropy \
# Make ipython config files readable!?!!
&& chmod -R a+rwX $HOME/.ipython \
&& echo 2
## Download astropy site locations and USNO sky model
#&& python -c "from astropy.coordinates import EarthLocation; EarthLocation._get_site_registry(force_download=True)" \
#&& python -c "from astropy.coordinates import EarthLocation, SkyCoord, AltAz; from astropy.time import Time; print(EarthLocation.of_site('ctio')); print(SkyCoord(180.,-45.,unit='deg').transform_to(AltAz(obstime=Time(56806.0, format='mjd'), location=EarthLocation.of_site('ctio'))))" \
## Download astropy IERS leap-second list
#&& python -c "from astropy.time import Time; Time.now()" \
## Make astropy cache files readable!?!!
#&& chmod -R a+rwX $HOME/.astropy \
## Make ipython config files readable!?!!
#&& chmod -R a+rwX $HOME/.ipython \
&& echo 1

LABEL Maintainer="John Moustakas [email protected]"
41 changes: 34 additions & 7 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,47 @@
Build a Docker container for fastspecfit.
=========================================

Using podman-hpc at NERSC
-------------------------

podman-hpc pull ubuntu:22.04

First, build the container:
```
podman-hpc build -t desihub/fastspecfit:latest .
```

podman-hpc migrate desihub/fastspecfit:latest


podman-hpc login docker.io
podman-hpc push docker.io/desihub/fastspecfit:latest
podman-hpc pull docker.io/desihub/fastspecfit:latest

podman-hpc run --rm -it localhost/desihub/fastspecfit:latest /bin/bash



Legacy Instructions
-------------------

Build a cross-platform docker container as documented [here](https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide), [here](https://blog.jaimyn.dev/how-to-build-multi-architecture-docker-images-on-an-m1-mac/), and [here](https://docs.nersc.gov/development/shifter/how-to-use/).

First (but just once), create the builder instance:
The very first time, create a builder instance with
```
docker buildx create --name FastSpecFit-build --node FastSpecFit --use
```
and then subsequently simply load that instance with
```
docker buildx create --name mybuilder --use
docker buildx use FastSpecFit-build
```

Then, subsequently, to create a new (or the latest) version or tag:
Then, subsequently, to create a new (or the latest) version or tag, do:
```
export DOCKER_BUILDKIT=0
export COMPOSE_DOCKER_CLI_BUILD=0
docker buildx use mybuilder
docker buildx build --platform linux/amd64,linux/arm64/v8 --push -t desihub/fastspecfit:2.1.1 .
docker buildx build --platform linux/amd64,linux/arm64/v8 --push -t desihub/fastspecfit:3.1.2 .
docker buildx build --platform linux/amd64,linux/arm64/v8 --push -t desihub/fastspecfit:latest .
```

Expand All @@ -25,8 +52,8 @@ docker run -it desihub/fastspecfit:latest
```
or
```
docker pull desihub/fastspecfit:2.1.1
docker run -it desihub/fastspecfit:2.1.1
docker pull desihub/fastspecfit:3.1.2
docker run -it desihub/fastspecfit:3.1.2
```

Or at NERSC:
Expand Down
6 changes: 3 additions & 3 deletions py/fastspecfit/data/emlines.ecsv
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ name restwave patch isbalmer ishelium isbroad isstrong nicename plotgroup
nii_6584 6585.273 t False False False True H$\alpha$+[NII]-$\lambda\lambda$6548,84 halpha_nii_6548_48
sii_6716 6718.294 u False False False True [SII]-$\lambda\lambda$6716,31 sii_6716_31
sii_6731 6732.674 u False False False True [SII]-$\lambda\lambda$6716,31 sii_6716_31
ariii_7135 7137.77 v False False False False [ArIII]-$\lambda$7135 oii_7320_30
oii_7320 7321.94 v False False False False [OII]-$\lambda\lambda$7320,30 oii_7320_30
oii_7330 7332.21 v False False False False [OII]-$\lambda\lambda$7320,30 oii_7320_30
ariii_7135 7137.77 v False False False False [ArIII]-$\lambda$7135+[OII]-$\lambda\lambda$7320,30 ariii_7135_oii_7320_30
oii_7320 7321.94 v False False False False [ArIII]-$\lambda$7135+[OII]-$\lambda\lambda$7320,30 ariii_7135_oii_7320_30
oii_7330 7332.21 v False False False False [ArIII]-$\lambda$7135+[OII]-$\lambda\lambda$7320,30 ariii_7135_oii_7320_30
siii_9069 9071.1 w False False False False [SIII]-$\lambda$9069 siii_9069
siii_9532 9533.2 w False False False False [SIII]-$\lambda$9532 siii_9532
4 changes: 2 additions & 2 deletions py/fastspecfit/test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ def test_stats():
xgood, mask = sigmaclip(xx)
assert(np.all(mask))

q1, q2 = quantile(xx, [0.1, 0.9])
q1, q2 = quantile(xx, np.asarray([0.1, 0.9]))
assert(np.isclose(q1, 3.4) & np.isclose(q2, 30.6))

with pytest.raises(ValueError):
quantile(xx, [10., 90.])
quantile(xx, np.asarray([10., 90.]))

assert(np.isclose(median(xx), 17.))
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ classifiers = [
"Topic :: System :: Software Distribution",
]
dependencies = [
"numpy<2.0",
"astropy>=5.0",
"numpy",
"astropy",
"scipy",
"healpy",
"numba",
"seaborn",
"matplotlib",
"fitsio",
"speclite>=0.20",
"speclite",
]
requires-python = ">=3.9"
requires-python = "<3.13"

[project.optional-dependencies]
test = [
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
numpy<2.0
astropy>=5.0
numpy
astropy
scipy
healpy
numba
seaborn
matplotlib
fitsio
speclite>=0.20
speclite
git+https://github.com/desihub/[email protected]
git+https://github.com/desihub/[email protected]
git+https://github.com/desihub/[email protected]

0 comments on commit ba861bd

Please sign in to comment.