add aggregated boxes metadata to monitor
parent
5ea78e9505
commit
de5028d823
@ -1,28 +1,23 @@
|
|||||||
FROM r-base
|
FROM r-base
|
||||||
|
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y libssl-dev libcurl3-dev cron
|
apt-get install -y libssl-dev libcurl3-dev cron libgdal-dev libgeos-dev libproj-dev libudunits2-dev liblwgeom-dev
|
||||||
|
|
||||||
# install dependencies
|
# install dependencies
|
||||||
RUN Rscript -e 'install.packages("httr")'
|
RUN Rscript -e 'install.packages("sf")'
|
||||||
RUN Rscript -e 'install.packages("dplyr")'
|
|
||||||
RUN Rscript -e 'install.packages("magrittr")'
|
RUN Rscript -e 'install.packages("magrittr")'
|
||||||
#RUN Rscript -e 'install.packages("readr")'
|
|
||||||
|
|
||||||
# install opensensemap package
|
|
||||||
RUN Rscript -e 'install.packages("devtools")'
|
RUN Rscript -e 'install.packages("devtools")'
|
||||||
RUN Rscript -e 'devtools::install_github("noerw/opensensmapR")'
|
RUN Rscript -e 'devtools::install_github("noerw/opensensmapR")'
|
||||||
|
|
||||||
COPY docker-entry.sh /docker-entry.sh
|
|
||||||
RUN chmod 0755 /docker-entry.sh
|
|
||||||
|
|
||||||
# install crontab
|
# install crontab
|
||||||
COPY crontab /crontab
|
COPY crontab /crontab
|
||||||
RUN /usr/bin/crontab /crontab
|
RUN /usr/bin/crontab /crontab
|
||||||
|
|
||||||
|
RUN apt-get clean && apt-get autoremove -y
|
||||||
|
|
||||||
# install script
|
# install script
|
||||||
COPY osem-monitor.R /script/osem-monitor.R
|
COPY get-counts.R /script/get-counts.R
|
||||||
WORKDIR /script/data
|
COPY get-boxes.R /script/get-boxes.R
|
||||||
|
|
||||||
CMD ["/docker-entry.sh"]
|
WORKDIR /script/data
|
||||||
|
CMD ["cron", "-f"]
|
||||||
|
@ -1 +1,8 @@
|
|||||||
*/10 * * * * cd /script/data && /usr/bin/Rscript --save --restore ../osem-monitor.R > rscript.log
|
#!/bin/sh
|
||||||
|
|
||||||
|
# once every 15 mins
|
||||||
|
*/15 * * * * cd /script/data && /usr/bin/Rscript --save --restore ../get-counts.R > get-counts.log 2>&1
|
||||||
|
|
||||||
|
# mondays, 12:02
|
||||||
|
#(may not run simultanously, to avoid override of .RData save)
|
||||||
|
2 12 * * 1 cd /script/data && /usr/bin/Rscript --save --restore ../get-boxes.R > get-boxes.log
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# start cron
|
|
||||||
cron -f -l 0
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
|||||||
|
library(magrittr)
|
||||||
|
library(opensensmapr)
|
||||||
|
library(sf)
|
||||||
|
|
||||||
|
if (is.null(as.list(environment())$osem_boxes_ts))
|
||||||
|
osem_boxes_ts = data.frame()
|
||||||
|
|
||||||
|
b = osem_boxes()
|
||||||
|
|
||||||
|
# only keep aggregated data
|
||||||
|
b_agg = data.frame(time = Sys.time(), boxcount = nrow(b))
|
||||||
|
b_agg$model = b$model %>% table() %>% as.list() %>% list()
|
||||||
|
b_agg$exposure = b$exposure %>% table() %>% as.list() %>% list()
|
||||||
|
b_agg$geometry = b %>% osem_as_sf() %>% st_geometry() %>% list()
|
||||||
|
b_agg$phenomena = b %>% osem_phenomena() %>% list()
|
||||||
|
|
||||||
|
# combine with existing time series
|
||||||
|
osem_boxes_ts = rbind(b_agg, osem_boxes_ts)
|
||||||
|
|
||||||
|
# cleanup
|
||||||
|
rm(b)
|
||||||
|
rm(b_agg)
|
Loading…
Reference in New Issue