-
Notifications
You must be signed in to change notification settings - Fork 2
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
use iac config for scaledown cron #347
Changes from all commits
e7a74ae
6b95837
ecbde32
71b5692
9705282
3d9ef85
01206c5
6e25e22
29cf9b6
66c4f5c
89c42d0
1f7ddd4
a0499f1
e9e8884
ef2d247
ce42130
193c791
af13a57
55af90e
b5f14cf
ea0bbfe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
# pull official base image | ||
FROM python:3.8-buster AS builder | ||
FROM python:3.8-slim-buster AS builder | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. smaller base image |
||
|
||
# set working directory | ||
WORKDIR /src | ||
|
||
# install app dependencies | ||
COPY requirements.txt ./ | ||
RUN pip3 install -r requirements.txt | ||
|
||
RUN pip3 install --no-cache-dir -r requirements.txt | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. smaller layer overall, compressed image for python container in ECR goes from ~630mb --> 100mb |
||
|
||
# --------------------------------------------------- | ||
# PRODUCTION BUILD | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,6 @@ PyYAML==5.4 | |
requests==2.24.0 | ||
responses==0.12.0 | ||
sinfo==0.3.1 | ||
umap-learn==0.4.6 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not needed on python image There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just saw this dependency in an unrelated context and was confused by it. I suppose it's a vestigial remnant. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah there are probably other that may not be needed either but doesn't seem so important since image size will be ~100MB now |
||
watchdog==0.10.3 | ||
backoff==1.10.0 | ||
socket_io_emitter==0.1.5.1 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import os | ||
|
||
ACCOUNT_ID = { | ||
'BIOMAGE': '242905224710', | ||
'HMS': '160782110667', | ||
} | ||
|
||
domain_specific = { | ||
'HMS': {'production': {'timeout': 40 * 60}}, | ||
'BIOMAGE': {}, | ||
'BIOMAGE_PRIVATE': {} | ||
} | ||
|
||
|
||
def get_domain_specific(): | ||
aws_account_id = os.getenv('AWS_ACCOUNT_ID') | ||
|
||
if aws_account_id == ACCOUNT_ID['HMS']: | ||
return domain_specific['HMS'] | ||
elif aws_account_id == ACCOUNT_ID['BIOMAGE']: | ||
return domain_specific['BIOMAGE'] | ||
else: | ||
return domain_specific['BIOMAGE_PRIVATE'] | ||
Comment on lines
+1
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. modeled after |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,14 +34,6 @@ RUN Rscript restore_renv.R | |
# deactivate so that above .libPaths used | ||
RUN R -q -e "renv::deactivate()" | ||
|
||
# install miniconda and python umap-learn for RunUMAP | ||
# clean conda | ||
ENV RETICULATE_MINICONDA_PATH=/src/r-miniconda | ||
RUN R -q -e "reticulate::install_miniconda()" && \ | ||
R -q -e "reticulate::conda_install(packages = 'umap-learn=0.5.3', python_version='3.10')" && \ | ||
CONDA_PATH=$(R -q -s -e "cat(reticulate::conda_binary())") && \ | ||
$CONDA_PATH clean --force-pkgs-dirs -y | ||
|
||
# use renv::snapshot() while R dependency updates are quick to build | ||
COPY ./renv.lock . | ||
RUN Rscript restore_renv.R | ||
|
@@ -63,7 +55,6 @@ RUN Rscript check_package_licenses.R | |
# --------------------------------------------------- | ||
FROM rocker/r-ver:4.2.2 AS common | ||
WORKDIR /src/worker | ||
ENV RETICULATE_MINICONDA_PATH=/src/r-miniconda | ||
|
||
# get source code and R packages | ||
COPY --from=builder /src /src | ||
|
@@ -73,14 +64,16 @@ ENV RENV_LIB=/src/lib | |
RUN echo ".libPaths(c('$RENV_LIB', .libPaths()))" >> $(R RHOME)/etc/Rprofile.site | ||
|
||
# install runtime system deps | ||
# python3-dev prevents 'reticulate can only bind to copies of Python built with --enable-shared' | ||
# cleanup setup files | ||
RUN echo "python3-pip" >> sysdeps_run.txt && \ | ||
RUN echo "python3-pip python3-venv python3-dev" >> sysdeps_run.txt && \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not declare these in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried it in the pipeline PR and it does not work (a pip install fails due to not finding pip), for some reason I don't understand. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll take a look in the pipeline and see if I can get it set up as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not tested but builds for me: hms-dbmi-cellenics/pipeline#340 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I'll test the pipeline PR. Regarding build time dependencies, are they removed downstream, after building the R packages? That relates to my initial question, why do we need python3-pip installed twice? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes the |
||
cat sysdeps_run.txt | xargs ./install_debian_packages.sh && \ | ||
rm -rf * | ||
|
||
# link system libstdc++ to conda installed version | ||
RUN rm /usr/lib/x86_64-linux-gnu/libstdc++.so.6 && \ | ||
ln -s /src/r-miniconda/envs/r-reticulate/lib/libstdc++.so.6 /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | ||
Comment on lines
-81
to
-83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't think any equivalent of this is necessary anymore as libstdc++.so.6 isn't in the environment folder. can't remember exactly what error under what set of conditions this fixed but |
||
# install umap-learn for RunUMAP | ||
ENV WORKON_HOME=/src/.virtualenvs | ||
RUN R -q -e "reticulate::virtualenv_create('r-reticulate')" && \ | ||
R -q -e "reticulate::virtualenv_install('r-reticulate', 'umap-learn==0.5.3', pip_options='--no-cache-dir')" | ||
Comment on lines
+73
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. motivation is reducing image size (before: ~1010 MB, after: 884MB) which speeds up worker pod being ready. also a bit simpler Together with python image size reduction (~530MB) worker ready time is down from ~2:30 --> 1:50 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. finally removing conda! I tried something similar months ago but got stuck. We can port this to the pipeline as well |
||
|
||
# --------------------------------------------------- | ||
# PRODUCTION BUILD | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enabling cron for production in HMS