Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for Homebrew installation #43

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 47 additions & 4 deletions .github/run-demos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,53 @@

set -e

# Bash is insane. If you don't do this next bit then it
# decides that you wanted to pass all the arguments from this
# script on to cosmosis-configure. Madness.
function DoSource() { source cosmosis-configure ; } ; DoSource
mkdir -p output

# Check the downloader works
./examples/get-planck-data.sh


# Run some examples
cosmosis examples/planck.ini | tee output/planck.log
grep 'Likelihood = -6288.61' output/planck.log


cosmosis examples/planck_class.ini | tee output/class.log
# This may need updating as we modify the class interface
# The settings are not optimized
# grep 'Likelihood = -5968.93' output/class.log
# This seems to give different results on different systems


cosmosis examples/wmap.ini | tee output/wmap.log

cosmosis examples/pantheon.ini -p emcee.samples=20
cosmosis-postprocess examples/pantheon.ini -o output/pantheon
test -f output/pantheon/cosmological_parameters--omega_m.png

cosmosis examples/des-y1.ini | tee output/des-y1.log
grep 'Likelihood = 5237.37' output/des-y1.log

cosmosis examples/des-y1.ini -p 2pt_shear.file=./shear/cl_to_corr/cl_to_corr.py 2pt_shear.corr_type=xi | tee output/des-y1.log
grep 'Likelihood = 5237.3' output/des-y1.log

cosmosis examples/des-y3.ini -p pk_to_cl_gg.save_kernels=T pk_to_cl.save_kernels=T | tee output/des-y3.log
grep 'Likelihood = 6043.23' output/des-y3.log

cosmosis examples/des-y3-mira-titan.ini | tee output/des-y3-mt.log
grep 'Likelihood = 6048.0' output/des-y3-mt.log

cosmosis examples/des-y3.ini -v halo_model_parameters.logT_AGN=8.2 -p camb.halofit_version=mead2020_feedback | tee output/des-y3.log
grep 'Likelihood = 6049.94' output/des-y3.log

cosmosis examples/euclid-emulator.ini
test -f output/euclid-emulator/matter_power_nl/p_k.txt

cosmosis examples/w_model.ini






# for demo 11 first run
Expand Down
172 changes: 85 additions & 87 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,90 @@ on:


jobs:
brew_test:
name: Brew Test
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install dependencies with brew
shell: bash -l {0}
run: |
brew update
brew list

find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete

# homebrew seems to ignore the --overwrite flag here.
brew install [email protected] [email protected] -v gcc fftw cfitsio gsl openblas mpi4py open-mpi libomp numpy scipy || brew link --overwrite [email protected]
brew --prefix
# add python to the default path for subsequent stages
# echo "/usr/local/opt/python/libexec/bin" >> $GITHUB_PATH

- name: Install CosmoSIS with pip
shell: bash -l {0}
run: |

GCCV=$(brew list gcc --versions | awk '{print $2}' | awk -F . '{print $1}')

# link gfortran to gfortran-12 or equiv
GFORTRAN_PATH=$(which gfortran-${GCCV})
GFORTRAN_DIR=$(dirname "$GFORTRAN_PATH")
ln -s ${GFORTRAN_PATH} ${GFORTRAN_DIR}/gfortran

# might not be needed
export OMPI_FC=gfortran-${GCCV}

echo "Whiches!"
which pip
which python
which python3
echo XXX COMPILING COSMOSIS

# Compile cosmosis at last
FC=gfortran-${GCCV} CC=gcc-${GCCV} CXX=g++-${GCCV} MPIFC=mpif90 pip3 install -v --no-cache-dir --no-binary=cosmosis git+https://github.com/joezuntz/cosmosis@brew-fixes
echo XXX SHOWING
pip3 show cosmosis
pip3 list
pip3 --version
echo XXX LS
ls /usr/local/opt/python/libexec/bin

# dependencies
pip3 install -r requirements.txt

- name: Build standard library
shell: bash -l {0}
run: |
export PATH=$PATH:/usr/local/opt/python/libexec/bin
python3 --version
which -a python3
source cosmosis-configure --brew-gcc
make

- name: Cache WMAP data
id: cache-wmap
uses: actions/cache@v3
env:
cache-name: cache-wmap-data
with:
path: likelihood/wmap9/data/
key: wmap-9-data

- if: ${{ steps.cache-wmap.outputs.cache-hit != 'true' }}
name: Download WMAP data
run: |
./examples/get-wmap-data.sh

- name: Run Demos
shell: bash -l {0}
run: |
source cosmosis-configure --brew-gcc
.github/run-demos.sh



conda_test:
name: Conda Test
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -39,30 +123,6 @@ jobs:
source cosmosis-configure
make

- name: CAMB Planck
shell: bash -l {0}
run: |
# print out the configuration
python -m cosmosis.configure
source cosmosis-configure
export
mkdir output
# Check the downloader works
./examples/get-planck-data.sh
# And that the pipeline runs afterwards
cosmosis examples/planck.ini | tee output/planck.log
grep 'Likelihood = -6288.61' output/planck.log

- name: Class Planck
shell: bash -l {0}
run: |
source cosmosis-configure
cosmosis examples/planck_class.ini | tee output/class.log
# This may need updating as we modify the class interface
# The settings are not optimized
# grep 'Likelihood = -5968.93' output/class.log
# This seems to give different results on different systems

- name: Cache WMAP data
id: cache-wmap
uses: actions/cache@v3
Expand All @@ -77,72 +137,10 @@ jobs:
run: |
./examples/get-wmap-data.sh

- name: WMAP likelihood
shell: bash -l {0}
run: |
source cosmosis-configure
cosmosis examples/wmap.ini | tee output/wmap.log


- name: Pantheon emcee
shell: bash -l {0}
run: |
source cosmosis-configure
cosmosis examples/pantheon.ini -p emcee.samples=20
cosmosis-postprocess examples/pantheon.ini -o output/pantheon
test -f output/pantheon/cosmological_parameters--omega_m.png

- name: DES Y1 likelihood
shell: bash -l {0}
run: |
source cosmosis-configure
cosmosis examples/des-y1.ini | tee output/des-y1.log
grep 'Likelihood = 5237.37' output/des-y1.log

- name: DES Y1 likelihood with cl_to_corr
shell: bash -l {0}
run: |
source cosmosis-configure
cosmosis examples/des-y1.ini -p 2pt_shear.file=./shear/cl_to_corr/cl_to_corr.py 2pt_shear.corr_type=xi | tee output/des-y1.log
grep 'Likelihood = 5237.3' output/des-y1.log

- name: DES Y3 likelihood
shell: bash -l {0}
run: |
source cosmosis-configure
cosmosis examples/des-y3.ini -p pk_to_cl_gg.save_kernels=T pk_to_cl.save_kernels=T | tee output/des-y3.log
grep 'Likelihood = 6043.23' output/des-y3.log

- name: DES Y3 likelihood with Mira Titan
shell: bash -l {0}
run: |
source cosmosis-configure
cosmosis examples/des-y3-mira-titan.ini | tee output/des-y3-mt.log
grep 'Likelihood = 6048.0' output/des-y3-mt.log

- name: DES Y3 likelihood with Mead nonlinear
shell: bash -l {0}
run: |
source cosmosis-configure
cosmosis examples/des-y3.ini -v halo_model_parameters.logT_AGN=8.2 -p camb.halofit_version=mead2020_feedback | tee output/des-y3.log
grep 'Likelihood = 6049.94' output/des-y3.log

- name: Euclid emulator
shell: bash -l {0}
run: |
source cosmosis-configure
cosmosis examples/euclid-emulator.ini
test -f output/euclid-emulator/matter_power_nl/p_k.txt

- name: Log w example
shell: bash -l {0}
run: |
source cosmosis-configure
cosmosis examples/w_model.ini | tee output/w_model.log

- name: Run Demos
shell: bash -l {0}
run: |
source cosmosis-configure
.github/run-demos.sh


Expand Down
3 changes: 2 additions & 1 deletion boltzmann/class/class_v3.2.0/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ OPTFLAG = -O3
# OMPFLAG = -fopenmp
#OMPFLAG = -mp -mp=nonuma -mp=allcores -g
#OMPFLAG = -openmp
OMPFLAG=$(COSMOSIS_OMP_FLAGS) $(COSMOSIS_OMP_LDFLAGS)

# all other compilation flags
# JAZ - added GSL here not because it actually needs GSL but
Expand Down Expand Up @@ -207,7 +208,7 @@ else
endif
# Have to run this install twice because otherwise it doesn't find its own install the first time
# Odd I know. It's because of how we're hacking the installation path.
cd python; export CC=$(CC); export PYTHONPATH=${PYTHONPATH}:$(PYTHONINSTALL); $(PYTHON) autosetup.py install --prefix=$(MDIR)/classy_install; $(PYTHON) autosetup.py install --prefix=$(MDIR)/classy_install
cd python; export CC=$(CC); export OMPFLAG="$(OMPFLAG)" export PYTHONPATH=${PYTHONPATH}:$(PYTHONINSTALL); $(PYTHON) autosetup.py install --prefix=$(MDIR)/classy_install; $(PYTHON) autosetup.py install --prefix=$(MDIR)/classy_install
rm python/autosetup.py

clean: .base
Expand Down
6 changes: 5 additions & 1 deletion boltzmann/class/class_v3.2.0/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@
VERSION = line.split()[-1][2:-1]
break

omp_flag = os.environ.get("OMPFLAG", '-lgomp')
if not omp_flag:
omp_flag = '-lgomp'
{}
# Define cython extension and fix Python version
classy_ext = Extension("classy", [os.path.join(classy_folder, "classy.pyx")],
include_dirs=[nm.get_include(), include_folder, heat_folder, recfast_folder, hyrec_folder],
libraries=liblist,
library_dirs=[root_folder, GCCPATH],
extra_link_args=['-lgomp']
extra_link_args=omp_flag.split()
)
import sys
classy_ext.cython_directives = {'language_level': "3" if sys.version_info.major>=3 else "2"}
Expand Down
8 changes: 8 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This is not a proper requirements file
# It lists extra things that need installing assuming you have already installed cosmosis itself
camb
astropy
fitsio
cython
scikit-learn
fast-pt
2 changes: 1 addition & 1 deletion structure/EuclidEmulator2/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
sources=["src/euclidemu2.pyx","src/cosmo.cxx","src/emulator.cxx"],
include_dirs=[gsl_include,"../src/"],
libraries=["gsl","gslcblas"],
extra_link_args=[f"-L {gsl_lib} -lgslcblas -lgsl"],
extra_link_args=[f"-L{gsl_lib}", "-lgslcblas", "-lgsl"],
language="c++",
extra_compile_args=['-std=c++11',
'-D PRINT_FLAG=0',
Expand Down