Skip to content

Commit

Permalink
More small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ibacher committed Apr 8, 2024
1 parent 77ed36e commit 9acdd18
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ FROM rstudio/plumber:latest

ENV TZ "Africa/Nairobi"

RUN apt-get -y update && apt-get -y install \
RUN apt-get -y update -qq && apt-get -y --no-install-recommends install \
tini \
libmariadb-dev \
libmysqlclient21 \
openjdk-8-jdk-headless \
cron \
curl \
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /etc/cron.*/*

RUN install2.r --error --skipinstalled \
tidyverse \
Expand All @@ -24,23 +25,25 @@ RUN install2.r --error --skipinstalled \

RUN Rscript -e "remotes::install_version('h2o', '3.42.0.2')"

COPY docker-resources/crontab /etc/cron.d/iit-crontab
COPY IIT-Prediction/model/V7 /app/model
COPY SQL/iit_prod_data_extract.sql /app/iit_prod_data_extract.sql
COPY docker-resources/run_predictions.sh /app/run_predictions.sh
RUN chmod 0744 /app/run_predictions.sh
COPY docker-resources/run_daily_stored_procedures.sh /app/run_daily_stored_procedures.sh
RUN chmod 0744 /app/run_daily_stored_procedures.sh
COPY docker-resources/dailyStoredProcedures.R /app/dailyStoredProcedures.R
COPY docker-resources/docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod 0744 /docker-entrypoint.sh
COPY docker-resources/plumber.R /app/plumber.R

COPY docker-resources/crontab /etc/cron.d/iit-crontab
RUN chmod 0644 /etc/cron.d/iit-crontab
RUN crontab /etc/cron.d/iit-crontab
RUN crontab -u root /etc/cron.d/iit-crontab
RUN touch /var/log/cron.log

COPY docker-resources/dailyStoredProcedures.R /app/dailyStoredProcedures.R
COPY docker-resources/plumber.R /app/plumber.R

EXPOSE 8000

ENTRYPOINT ["tini", "--", "./docker-entrypoint.sh"]
ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]

CMD ["/app/plumber.R"]
2 changes: 2 additions & 0 deletions docker-resources/dailyStoredProcedures.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ DBI::dbExecute(
my_pool,
"CALL predictions.add_observed_appointments_to_ml_predictions_v1_0();"
)

poolClose(my_pool)
4 changes: 4 additions & 0 deletions docker-resources/plumber.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ my_pool <- dbPool(
dbname = dbConfig$defaultDb
)

on.exit(poolClose(my_pool))

# Custom router modifications
#* @plumber
function(pr) {
Expand Down Expand Up @@ -136,6 +138,7 @@ function(
prediction_results_adults <- predictors %>%
filter(Age >= 18) %>%
bind_cols(as.data.frame(results_adults)) %>%
left_join(results_adults, by = join_by(person_id, encounter_id, location_id)) %>%
# reduce data frame and rename the result
select(person_id, encounter_id, location_id, rtc_date, predicted_prob_disengage = Disengaged) %>%
# calculate the patient's risk category
Expand All @@ -153,6 +156,7 @@ function(
prediction_results_minors <- predictors %>%
filter(Age < 18) %>%
bind_cols(as.data.frame(results_minors)) %>%
left_join(results_minors, by = join_by(person_id, encounter_id, location_id)) %>%
# reduce data frame and rename the result
select(person_id, encounter_id, location_id, rtc_date, predicted_prob_disengage = Disengaged) %>%
# calculate the patient's risk category
Expand Down

0 comments on commit 9acdd18

Please sign in to comment.