2## @brief Astroconda control functions
4## @section astroconda_hst_example HST Example
5## @include pipeline/hst.sh
7## @section astroconda_jwst_example JWST Example
8## @include pipeline/jwst.sh
10## @section astroconda_data_analysis_example Data Analysis Example
11## @include pipeline/data_analysis.sh
13(( $EC2PINIT_ASTROCONDA_INCLUDED )) &&
return
14EC2PINIT_ASTROCONDA_INCLUDED=1
17## URL to astroconda releases Git repository (or local file system)
18ac_releases_repo=
"https://github.com/astroconda/astroconda-releases"
20## Path where ec2pinit will store the astroconda releases repository
21ac_releases_path=
"$ec2pinit_tempdir/$(basename $ac_releases_repo)"
25## @brief Get astroconda platform string
26## @details The value returned is the platform suffix of a pipeline release
28## @retval platform if supported platform is detected
29## @retval "unknown" if platform is not supported
44## @fn ac_releases_clone()
45## @brief Clone the astroconda-releases repository
46## @details The destination is $ec2pinit_tempdir
49 if [ ! -d
"$ac_releases_path" ]; then
50 io_info "ac_releases_clone: Cloning astroconda releases repository"
51 git clone $ac_releases_repo $ac_releases_path >&2
56## @fn ac_releases_pipeline_exists()
57## @brief Check if a named pipeline exists in astroconda-releases
58## @retval path if pipeline exists
59## @retval "" if pipeline does not exist
64 find $ac_releases_path -maxdepth 1 -type d -name
''$pattern
''
68## @fn ac_releases_pipeline_release_exists()
69## @brief Check if a named release exists in a astroconda-releases pipeline
70## @param pipeline_name Pipeline name
71## @param pipeline_release Pipeline release name
72## @retval path if release exists
73## @retval "" if release does not exist
75 local pipeline_name=
"$1"
76 local pipeline_release=
"$2"
77 result=$(find
"$(ac_releases_pipeline_exists $pipeline_name)" -maxdepth 1 -name
''$pipeline_release
'')
78 if [ -n
"$result" ]; then
84## @fn ac_releases_data_analysis()
85## @brief Get path to data analysis release file
86## @param series Pipeline release name
87## @retval latest_path if series is undefined
88## @retval path if series is found
92 if [ -z
"$series" ]; then
93 # get implicit latest in the release series
94 release=$(find
"$(ac_releases_pipeline_exists $pipeline)" \
96 | sort -V | tail -n 1)
98 # get the latest release for the requested series
99 release=$(find
"$(ac_releases_pipeline_exists $pipeline)" \
100 -wholename
''\*$series/latest-$(
ac_platform).yml
'' \
101 | sort -V | tail -n 1)
103 if [ -n
"$release" ]; then
104 readlink -f
"$release"
109## @fn ac_releases_data_analysis_environ()
110## @brief Generate conda environment name
111## @param series Pipeline release name
112## @retval environment_name if series exists
113## @retval 1 if release cannot be found
117 if [ -z
"$filename" ]; then
120 sed
"s/-/_/g;s/_$(ac_platform).*//g" <<< $(basename $filename)
124## @fn ac_releases_jwst()
125## @brief Get path to JWST pipeline release file(s)
126## @details JWST splits its installation into two files. This function returns
127## two strings separated by new lines.
128## @param series Pipeline release name
129## @retval latest_path if series is undefined
130## @retval paths if series is found
133 local pipeline=
"jwstdp"
134 if [ -z
"$series" ]; then
135 # get implicit latest in the release series
136 release=$(find
"$(ac_releases_pipeline_exists $pipeline)" \
137 -name
''*.txt
'' -and \( -not -name
''*macos*
'' \) \
138 | sort -V | tail -n 2)
140 # get the latest release for the requested series
141 release=$(find
"$(ac_releases_pipeline_exists $pipeline)" \
142 -wholename
''\*$series
163 | sort -V | tail -n 1)
165 # get the latest release for the requested series
166 release=$(find
"$(ac_releases_pipeline_exists $pipeline)" \
168 -wholename
''\*/$series
'' \
169 | sort -V | tail -n 1)
171 printf
"JWSTDP_%s" $(basename $release)
175## @fn ac_releases_hst()
176## @brief Get path to HST pipeline release file
177## @details HST provides a platform dependent YAML configuration
178## @param series Pipeline release name
179## @retval latest_path if series is undefined
180## @retval path if series is found
183 local pipeline=
"caldp" # no one will ever use hstdp
184 if [ -z
"$series" ]; then
185 # get implicit latest in the release series
186 release=$(find
"$(ac_releases_pipeline_exists $pipeline)" \
188 | sort -V | tail -n 1)
190 # get the latest release for the requested series
191 release=$(find -L
"$(ac_releases_pipeline_exists $pipeline)" \
192 -wholename
''\*$series/latest-$(
ac_platform).yml
'' \
193 | sort -V | tail -n 1)
195 if [ -n
"$release" ]; then
196 readlink -f
"$release"
201## @fn ac_releases_hst_environ()
202## @brief Generate conda environment name
203## @param series Pipeline release name
204## @retval environment_name if series exists
205## @retval 1 if release cannot be found
209 if [ -z
"$filename" ]; then
212 sed
"s/_$(ac_platform).*//" <<< $(basename $filename)
216## @fn ac_releases_install_hst()
217## @brief Install the HST pipeline
218## @param version pipeline release version
221 if [ -z
"$version" ]; then
222 io_error "ac_releases_install_hst: release version required"
227 io_info "ac_releases_install_hst: Creating $release_name environment"
228 conda env create -n $release_name --file $release_file
232## @fn ac_releases_install_jwst()
233## @brief Install the JWST pipeline
234## @param version pipeline release version
237 if [ -z
"$version" ]; then
238 io_error "ac_releases_install_jwst: release version required" >&2
243 io_info "ac_releases_install_jwst: Creating $release_name environment"
244 conda create -n $release_name --file ${release_file[0]}
245 io_info "ac_releases_install_jwst: Activating $release_name environment"
246 conda activate $release_name
247 io_info "ac_releases_install_jwst: Installing dependencies: ${release_file[1]}"
248 python -m pip install -r ${release_file[1]}
253## @fn ac_releases_install_data_analysis()
254## @brief Install the data analysis pipeline
255## @param version pipeline release version
258 if [ -z
"$version" ]; then
259 io_error "ac_releases_install_data_analysis: release version required"
264 io_info "ac_releases_install_data_analysis: Creating $release_name environment"
265 conda env create -n $release_name --file $release_file
io_info(...)
Print a message.
io_error(...)
Print an error message.
ac_releases_install_data_analysis(version)
Install the data analysis pipeline.
ac_releases_pipeline_release_exists(pipeline_name, pipeline_release)
Check if a named release exists in a astroconda-releases pipeline.
ac_releases_install_hst(version)
Install the HST pipeline.
ac_releases_jwst_environ(series)
Generate conda environment name.
ac_releases_pipeline_exists()
Check if a named pipeline exists in astroconda-releases.
ac_releases_hst(series)
Get path to HST pipeline release file.
ac_releases_data_analysis_environ(series)
Generate conda environment name.
ac_platform()
URL to astroconda releases Git repository (or local file system)
ac_releases_jwst(series)
Get path to JWST pipeline release file(s)
ac_releases_hst_environ(series)
Generate conda environment name.
ac_releases_clone()
Clone the astroconda-releases repository.
ac_releases_data_analysis(series)
Get path to data analysis release file.
ac_releases_install_jwst(version)
Install the JWST pipeline.
sys_platform()
Get system platform (Linux, Darwin, etc)