Skip to content

Commit 0e8aa03

Browse files
authored
Merge branch 'develop' into events-schema-0.1.1
2 parents cd5f8fb + bb821b6 commit 0e8aa03

142 files changed

Lines changed: 2415 additions & 437 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ For more information about this file see also [Keep a Changelog](http://keepacha
2525
- Added `PEcAn.data.land::to_co2e()` for converting SOC change, CH4, and N2O to CO2-equivalent emissions using IPCC Global Warming Potential values.
2626

2727
### Fixed
28+
- Fixed broken pecanproject.github.io, pecan.gitbooks.io, and other outdated documentation links across book_source, tutorials, models, modules, web, and shiny files (#3710).
29+
- Added note to DEV-INTRO.md documenting Traefik workaround for Apple Silicon (ARM64) Macs: use `traefik:v2.11` with `platform: linux/arm64` to fix 404 errors (#3910)
30+
- Fixed `web/08-finished.php`: show database info instead of "Still running" when workflow folder doesn't exist locally (#3501).
2831

2932
### Changed
3033
- Updated Docker architecture documentation to match current docker-compose.yml: removed portainer/minio/thredds, added rstudio/api sections, updated service lists and volumes (#3268).
@@ -39,6 +42,7 @@ For more information about this file see also [Keep a Changelog](http://keepacha
3942
`MCMCpack`, `mvtnorm`, `neonUtilities`, `neonstore`, `PEcAn.benchmark`,
4043
`PEcAn.visualization`, `rjags`, `sirt`, and `sp` from `Imports` to
4144
`Suggests` (@omkarrr2533, #3599).
45+
- Management events specified via `events.json` are now required to specify a crop code for each planting event, so that models can know when to restart with a different PFT (#3828, #3836).
4246

4347

4448

DEV-INTRO.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ cp docker-compose.dev.yml docker-compose.override.yml
6565

6666
You can now use the command `docker compose` to work with the containers setup for development. **The rest of this document assumes you have done this step.**
6767

68+
_Note for Apple Silicon (M1/M2/M3/M4) macOS users:_ The default Traefik image (`traefik:v2.9`) is built only for `linux/amd64` and cannot reliably communicate with the Docker socket when running under emulation on ARM64. This causes all web routes to return 404 errors. To fix this, add the following to your `docker-compose.override.yml` under `services:` and above `pecan:`:
69+
```sh
70+
traefik:
71+
image: traefik:v2.11
72+
platform: linux/arm64
73+
```
74+
6875
### First time setup
6976

7077
The steps in this section only need to be done the first time you start working with the stack in docker. After this is done you can skip these steps. You can find more detail about the docker commands in the [pecan documentation](https://pecanproject.github.io/pecan-documentation/latest/docker-index.html).
@@ -246,7 +253,7 @@ A better way of doing this is developed as part of GSOC, in which case you can l
246253

247254
## PEcAn URLs
248255

249-
You can check the RabbitMQ server used by pecan using <https://rabbitmq.pecan.localhost> on the same server that the docker stack is running on. You can use rstudio either with <http://server/rstudio> or at <http://rstudio.pecan.localhost>. To check the traefik dashboard you can use <http://traefik.pecan.localhost>.
256+
You can check the RabbitMQ server used by pecan using <https://rabbitmq.pecan.localhost> on the same server that the docker stack is running on. You can use rstudio either with `http://server/rstudio` or at <http://rstudio.pecan.localhost>. To check the traefik dashboard you can use <http://traefik.pecan.localhost>.
250257

251258
If the stack is running on a remote machine, you can use ssh and port forwarding to connect to the server. For example `ssh -L 8000:localhost:80` will allow you to use <http://rabbitmq.pecan.localhost:8000/> in your browser to connect to the remote PEcAn server RabbitMQ.
252259

apps/api/R/posteriors.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ searchPosteriors <- function(req, pft_id = NA, host_id = NA,
104104
result$prev_page <- paste0(
105105
req$rook.url_scheme, "://",
106106
req$HTTP_HOST,
107-
"/api/workflows",
107+
"/api/posteriors",
108108
req$PATH_INFO,
109109
substr(req$QUERY_STRING,
110110
0,

apps/api/R/workflows.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,9 @@ getWorkflowFilesAsZip <- function(req, id, filenames, res){
312312

313313
full_files[i] <- filepath
314314
}
315-
zip_file <- zip::zipr("output.zip", full_files)
316-
return(zip_file)
315+
zip_path <- zip::zipr("output.zip", full_files)
316+
bin <- readBin(zip_path, "raw", n = file.info(zip_path)$size)
317+
file.remove(zip_path)
318+
return(bin)
317319
}
318320
}

base/db/R/dbfiles.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ dbfile.move <- function(old.dir, new.dir, file.type, siteid = NULL, register = F
766766
files.indb <- 0
767767

768768
# check for file type and update to make it *.file type
769-
if (file.type != "clim" | file.type != "nc") {
769+
if (file.type != "clim" && file.type != "nc") {
770770
PEcAn.logger::logger.error("File type not supported by move at this time. Currently only supports NC and CLIM files")
771771
error <- 1
772772
}

base/db/R/get.trait.data.pft.R

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,54 @@
11
##' Get trait data from the database for a single PFT
22
##'
3-
##' @details `pft` should be a list containing at least `name` and `outdir`, and optionally `posteriorid` and `constants`. BEWARE: All existing files in `outir` will be deleted!
4-
##' @param pft list of settings for the pft whose traits to retrieve. See details
5-
##' @param modeltype type of model that is used, this is used to distinguish between different pfts with the same name.
3+
##' @md
4+
##' Queries BETYdb for trait observations and prior distributions for a single
5+
##' plant functional type (PFT). Results are saved to files
6+
##' in the PFT output directory (`pft$outdir`), and also registered in the
7+
##' database as posterior records when `write = TRUE`.
8+
##'
9+
##' @details
10+
##' `pft` should be a list containing at least `name` and `outdir`, and
11+
##' optionally `posteriorid` and `constants`.
12+
##'
13+
##' **File-based side effects (saved to `pft$outdir`):**
14+
##' \describe{
15+
##' \item{`trait.data.Rdata`}{Contains a single object `trait.data`: a named
16+
##' list of data frames, one per trait. Each data frame has columns from
17+
##' BETYdb's traits/yields views (e.g., `mean`, `stat`, `n`, `site_id`,
18+
##' `treatment_id`). Names correspond to trait variable names
19+
##' (e.g., `"SLA"`, `"Vcmax"`).}
20+
##' \item{`prior.distns.Rdata`}{Contains a single object `prior.distns`: a
21+
##' data frame with one row per trait and columns `distn`, `parama`,
22+
##' `paramb`, and `n`. Row names are trait variable names. Traits listed
23+
##' in `pft$constants` are excluded.}
24+
##' \item{`trait.data.csv`}{CSV export of `trait.data` (all traits
25+
##' row-bound).}
26+
##' \item{`prior.distns.csv`}{CSV export of `prior.distns`.}
27+
##' \item{`species.csv` or `cultivars.csv`}{PFT membership list used to
28+
##' detect changes between runs.}
29+
##' }
30+
##'
31+
##' **Downstream contract:** The files `trait.data.Rdata` and
32+
##' `prior.distns.Rdata` are expected by \code{run.meta.analysis.pft}, which
33+
##' loads them from `pft$outdir`. This implicit file-based coupling means
34+
##' the two functions must agree on directory path and object names. A future
35+
##' refactoring goal is to pass these objects directly via function arguments
36+
##' instead.
37+
##'
38+
##' @param pft list of settings for the pft whose traits to retrieve. See details.
39+
##' @param modeltype type of model that is used, this is used to distinguish
40+
##' between different pfts with the same name.
641
##' @param dbfiles location where previous results are found
742
##' @param dbcon database connection
8-
##' @param forceupdate set this to true to force an update, auto will check to see if an update is needed.
43+
##' @param forceupdate set this to true to force an update, auto will check to
44+
##' see if an update is needed.
945
##' @param write (Logical) If `TRUE` updated posteriors will be written to
10-
##' BETYdb. Defaults to FALSE.
46+
##' BETYdb. Defaults to `FALSE`.
1147
##' @param trait.names list of trait names to retrieve
12-
##' @return updated pft with posteriorid
48+
##' @return The `pft` input list, updated with `pft$posteriorid` set to the
49+
##' ID of the (possibly new) posterior record in BETYdb. The posterior ID can
50+
##' be used to locate the output files (`trait.data.Rdata`, `prior.distns.Rdata`,
51+
##' etc.) via BETYdb's `dbfiles` table.
1352
##' @author David LeBauer, Shawn Serbin, Rob Kooper
1453
##' @export
1554
get.trait.data.pft <-
@@ -27,10 +66,6 @@ get.trait.data.pft <-
2766
PEcAn.logger::logger.error(paste0("Couldn't create PFT output directory: ", pft$outdir))
2867
}
2968

30-
## Remove old files. Clean up.
31-
old.files <- list.files(path = pft$outdir, full.names = TRUE, include.dirs = FALSE)
32-
file.remove(old.files)
33-
3469
# find appropriate pft
3570
pftres <- query_pfts(dbcon, pft[["name"]], modeltype)
3671
pfttype <- pftres[["pft_type"]]

base/db/man/get.trait.data.pft.Rd

Lines changed: 38 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

base/remote/R/check_model_run.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ check_model_run <- function(out, stop.on.error = TRUE) {
1010
success <- FALSE
1111
msg <- paste0("Model run aborted with the following error:\n", out)
1212
if (stop.on.error) {
13-
PEcAn.logger::logger.severe(msg)
13+
PEcAn.logger::logger.severe(msg, wrap = FALSE)
1414
} else {
15-
PEcAn.logger::logger.error(msg)
15+
PEcAn.logger::logger.error(msg, wrap = FALSE)
1616
}
1717
} else {
1818
success <- TRUE

base/utils/R/datasets.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#' Standardized variable names and units for PEcAn
33
#'
44
#' A lookup table giving standard names, units and descriptions for variables in PEcAn input/output files.
5-
#' Originally based on the \href{https://nacp.ornl.gov/MsTMIP_variables.shtml}{MsTMIP} standards,
5+
#' Originally based on the \href{https://nacp-prod.ornl.gov/MsTMIP_variables.shtml}{MsTMIP} standards,
66
#' with additions to accomodate a wider range of model inputs and outputs.
77
#' The standard_vars table replaces both `mstmip_vars` and `mstmip_local`,
88
#' both of which are now deprecated.
@@ -13,7 +13,7 @@
1313
#' @format data frame, all columns character
1414
#' \describe{
1515
#' \item{Variable.Name}{Short name suitable for programming with}
16-
#' \item{standard_name}{Name used in the NetCDF \href{http://cfconventions.org/Data/cf-standard-names/current/build/cf-standard-name-table.html}{CF metadata conventions} }
16+
#' \item{standard_name}{Name used in the NetCDF \href{https://cf-convention.github.io/Data/cf-standard-names/current/build/cf-standard-name-table.html}{CF metadata conventions} }
1717
#' \item{Units}{Standard units for this variable. Do not call variables by these names if they are in different units.
1818
#' See `ud_convert` for conversions to and from non-standard units}
1919
#' \item{Long.Name}{Human-readable variable name, suitable for e.g. axis labels}

base/utils/R/read.output.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#' surface runoff (Qs), subsurface runoff (Qsb), and rainfall (Rainf).
1212
#'
1313
#' For more details, see the [MsTMIP
14-
#' variables](http://nacp.ornl.gov/MsTMIP_variables.shtml)
14+
#' variables](https://nacp-prod.ornl.gov/MsTMIP_variables.shtml)
1515
#' documentation.
1616
#'
1717
#' @param runid the ID distinguishing the model run. Can be omitted

0 commit comments

Comments
 (0)