noaa-onms / cinms

Channel Islands National Marine Sanctuary
https://noaa-onms.github.io/cinms
MIT License
3 stars 1 forks source link

SST not updating -- Github Action failing #79

Closed bbest closed 3 years ago

bbest commented 3 years ago
label: sst anomaly time series
Quitting from lines 59-63 (kelp-forest_key-climate-ocean.Rmd) 
Error in if (SST_data$sst_anomaly[i] <= 0) { : 
  missing value where TRUE/FALSE needed
Calls: <Anonymous> ... withCallingHandlers -> withVisible -> eval -> eval -> <Anonymous>
In addition: There were 50 or more warnings (use warnings() to see the first 50)
bbest commented 3 years ago

I was able to run on my machine the scripts listed in update-oceano.yml:

But kelp-forest_key-climate-ocean.Rmd is throwing the same error after committing and trying again. Any ideas @superjai?

bbest commented 3 years ago

image

superjai commented 3 years ago

hey @bbest - issue fixed. Here's the successful github action.

There were multiple problems to be fixed.

  1. In nms4r::calculate_SST_anomaly, there was a problem with the following line:
  right_dates <- SST_data[SST_data$date >= "2003-01-01" & SST_data$date <= "2017-12-31", ]

For some reason, within the docker container SST_data$date was being interpreted as a factor and not as a date. In contrast, when run locally, SST_data$date is interpreted as a date. Here's the evidence of that from one of the many GitHub Action failure logs:

1: In Ops.factor(SST_data$date, "2003-01-01") :
  ‘>=’ not meaningful for factors

The solution was easy enough, which was to force SST_data$date to date format as follows:

  right_dates <- SST_data[as.Date(SST_data$date) >= "2003-01-01" & as.Date(SST_data$date) <= "2017-12-31", ]
  1. For many of the key-climate-ocean.rmd modal files in the cinms repo, functions were not being accessed using the double colon operator (causing everything to fail). When not present, I updated function calls with the double colon operator.
  2. One of the modal files that was attempted to be rendered in the docker container was rocky-map.Rmd. This can't work as this rmd file calls the function nms4r::map_nms_sites. This function is one of those that requires access to the google drive with the shared NMS data. So that obviously can't work from GitHub Actions. I omitted it from the list of rmd files to be rendered in nms4r::render_all_rmd (when interactive is set to true in the arguments).