Skip to content

Commit 6bc56da

Browse files
authored
Update dockerfile (#27)
* update libgl1 installation * allow breaking of system packages * check pip version for command line options * use venv * reformat files with Black
1 parent b25d475 commit 6bc56da

File tree

5 files changed

+270
-211
lines changed

5 files changed

+270
-211
lines changed

Dockerfile

+16-7
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,35 @@ ARG CC=gcc-9
1010
ARG CXX=g++-9
1111

1212
RUN apt-get update && \
13-
apt-get install -y autoconf automake libtool pkg-config libgl1-mesa-glx && \
13+
apt-get install -y autoconf automake libtool pkg-config && \
1414
apt-get install -y gcc-9 g++-9 && \
1515
apt-get install -y cmake git wget && \
1616
apt-get install -y libarmadillo-dev && \
1717
apt-get install -y libcfitsio-dev && \
1818
apt-get install -y libfftw3-dev && \
19+
apt-get install -y libgl1 && \
1920
apt-get install -y libgsl-dev && \
2021
apt-get install -y libsharp-dev && \
2122
apt-get install -y libhealpix-cxx-dev && \
2223
apt-get install -y healpy-data && \
23-
apt-get install -y python3 python3-pip && \
24+
apt-get install -y python3 python3-pip python3-venv && \
2425
apt-get clean
2526

26-
ENV HEALPIX /usr/share/healpy
27+
ENV HEALPIX=/usr/share/healpy
2728

28-
RUN python3 -m pip install jupyter
29+
RUN python3 -m venv /venv
30+
31+
RUN source /venv/bin/activate && \
32+
pip install --upgrade pip
33+
34+
RUN source /venv/bin/activate && \
35+
pip install jupyter
2936

3037
COPY . /home
3138

32-
RUN cd /home && \
33-
python3 -m pip install .
39+
RUN source /venv/bin/activate && \
40+
pip install /home
41+
42+
RUN echo "source /venv/bin/activate" >> ~/.bashrc
3443

35-
RUN echo -e '#!/bin/bash\njupyter notebook --port=8888 --no-browser --ip=0.0.0.0 --allow-root' > /usr/bin/notebook && chmod +x /usr/bin/notebook
44+
RUN echo -e '#!/bin/bash\nsource /venv/bin/activate\njupyter notebook --port=8888 --no-browser --ip=0.0.0.0 --allow-root' > /usr/bin/notebook && chmod +x /usr/bin/notebook

pycs/astro/wl/mass_mapping.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -913,9 +913,9 @@ def _prepare_data(self, InshearData, msg=None, niter=None, Nsigma=None):
913913
mask = (InshearData.Ncov != 0).astype(int) # shape = (nx, ny)
914914
else:
915915
mask = InshearData.mask
916-
InshearData.Ncov[InshearData.Ncov == 0] = (
917-
1e9 # infinite value for no measurement
918-
)
916+
InshearData.Ncov[
917+
InshearData.Ncov == 0
918+
] = 1e9 # infinite value for no measurement
919919
Ncv = InshearData.Ncov / 2.0 # shape = (nx, ny)
920920

921921
# find the minimum noise variance
@@ -929,9 +929,9 @@ def _prepare_data(self, InshearData, msg=None, niter=None, Nsigma=None):
929929
eta = tau
930930
# compute signal coefficient
931931
Esn = eta / Ncv # shape = (nx, ny)
932-
Esn[Esn == np.inf] = (
933-
0 # TODO: useless if we have set Ncv[mask == 0] = 1e9 before
934-
)
932+
Esn[
933+
Esn == np.inf
934+
] = 0 # TODO: useless if we have set Ncv[mask == 0] = 1e9 before
935935

936936
return gamma1, gamma2, nx, ny, eta, Esn, mask, ind, tau, niter, Nsigma
937937

pycs/sparsity/sparse2d/mr_filter.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
from datetime import datetime
1717
from astropy.io import fits
1818
import shlex
19+
20+
1921
##
2022
# Function that calls mr_filter to perform a wavelet filtering on the
2123
# input data.
@@ -29,27 +31,26 @@
2931
#
3032
# %load_ext autoreload
3133
# %autoreload 2
32-
def mr_filter(data, opt=None, path='./', remove_files=True):
33-
34+
def mr_filter(data, opt=None, path="./", remove_files=True):
3435
# Create a unique string using the current date and time.
3536
# print('mr_filter ', opt)
36-
unique_string = datetime.now().strftime('%Y.%m.%d_%H.%M.%S')
37-
result=0
37+
unique_string = datetime.now().strftime("%Y.%m.%d_%H.%M.%S")
38+
result = 0
3839
# Set the ouput file names.
39-
file_name = path + 'mr_temp_' + unique_string
40-
file_fits = file_name + '.fits'
41-
file_out = file_name + '_out.fits'
40+
file_name = path + "mr_temp_" + unique_string
41+
file_fits = file_name + ".fits"
42+
file_out = file_name + "_out.fits"
4243

4344
# Write the input data to a fits file.
4445
fits.writeto(file_fits, data)
4546

46-
cmd = 'mr_filter '
47+
cmd = "mr_filter "
4748

4849
if isinstance(opt, type(None)):
49-
optF=' '
50+
optF = " "
5051
else:
51-
optF=opt
52-
cmd = cmd + optF + ' ' + file_fits + ' ' + file_out
52+
optF = opt
53+
cmd = cmd + optF + " " + file_fits + " " + file_out
5354
# print 'CMD = ', cmd
5455
args = shlex.split(cmd)
5556
# print('args ', args)

pycs/sparsity/sparse2d/mr_gmca.py

+16-17
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from pycs.misc.cosmostat_init import *
2020
from pycs.misc.cosmostat_init import writefits
2121

22+
2223
##
2324
# Function that calls mr_gmca to perform blind source separation on the
2425
# input data.
@@ -32,20 +33,19 @@
3233
#
3334
# %load_ext autoreload
3435
# %autoreload 2
35-
def mr_gmca(data, opt=None, path='./', remove_files=True, verbose=False, FileOut=None):
36-
36+
def mr_gmca(data, opt=None, path="./", remove_files=True, verbose=False, FileOut=None):
3737
# Create a unique string using the current date and time.
3838
# print('mr_filter ', opt)
39-
prog="mr_gmca"
40-
unique_string = datetime.now().strftime('%Y.%m.%d_%H.%M.%S')
41-
result=0
39+
prog = "mr_gmca"
40+
unique_string = datetime.now().strftime("%Y.%m.%d_%H.%M.%S")
41+
result = 0
4242
# Set the ouput file names.
43-
file_name = path + 'mr_temp_' + unique_string
44-
file_fits = file_name + '.fits'
43+
file_name = path + "mr_temp_" + unique_string
44+
file_fits = file_name + ".fits"
4545
if FileOut is not None:
4646
file_out = FileOut
4747
else:
48-
file_out = file_name + '_out'
48+
file_out = file_name + "_out"
4949

5050
# Write the input data to a fits file.
5151
writefits(file_fits, data)
@@ -54,15 +54,15 @@ def mr_gmca(data, opt=None, path='./', remove_files=True, verbose=False, FileOut
5454
cmd = prog
5555

5656
if isinstance(opt, type(None)):
57-
optF=' '
57+
optF = " "
5858
else:
59-
optF= opt
59+
optF = opt
6060
if verbose:
6161
optF = optF + " -v "
6262

63-
cmd = cmd + " " + optF + " " + file_fits + " " + file_out
63+
cmd = cmd + " " + optF + " " + file_fits + " " + file_out
6464
if verbose:
65-
print ('CMD = ', cmd)
65+
print("CMD = ", cmd)
6666

6767
args = shlex.split(cmd)
6868
# print('args ', args)
@@ -72,19 +72,18 @@ def mr_gmca(data, opt=None, path='./', remove_files=True, verbose=False, FileOut
7272
file_out_source = file_out + ".fits"
7373
file_out_mat = path + "xx_EstMixmat.fits"
7474
file_out_invmat = path + "xx_InvMixingMat.fits"
75-
75+
7676
result = readfits(file_out_source)
7777
est_mixmat = readfits(file_out_mat)
78-
est_invmixmat = readfits (file_out_invmat)
78+
est_invmixmat = readfits(file_out_invmat)
7979

80-
8180
# Return the mr_transform results (and the output file names).
8281
if remove_files:
8382
remove(file_fits)
8483
remove(file_out_source)
8584
remove(file_out_mat)
8685
remove(file_out_invmat)
8786

88-
return result,est_mixmat,est_invmixmat
87+
return result, est_mixmat, est_invmixmat
8988
else:
90-
return result,est_mixmat,est_invmixmat
89+
return result, est_mixmat, est_invmixmat

0 commit comments

Comments
 (0)