This function caches cultivar definitions from APSIM Next Generation by reading user-supplied APSIM resource files or raw GitHub URLs pointing explicitly to the Models/Resources directory.

cache_apsim_cultivars(
  apsim_resources_dir,
  crop = NULL,
  dest_dir = NULL,
  overwrite = FALSE
)

Arguments

apsim_resources_dir

Character scalar. A user-supplied path or URL pointing explicitly to the APSIM Next Generation Models/Resources directory (for example, a raw GitHub URL at a specific commit).

crop

Character vector. Crop names for which cultivar definitions should be cached. If NULL, all crops defined in agrillm_options$get("crops") are processed.

dest_dir

Character scalar. Directory in which cached cultivar files will be stored. Defaults to file.path(agrillm_options$get("cache_dir"), "cultivars").

overwrite

Logical. If FALSE (default), existing cached cultivar files are preserved. If TRUE, cached files will be replaced.

Value

Invisibly returns the cache directory used to store cultivar files.

Details

The function does not discover, infer, or download APSIM resources on behalf of the user. Instead, users must explicitly supply a valid APSIM resource location (e.g. a raw GitHub URL or equivalent local path) that they are licensed to access. Cached files are stored locally (by default under the project-level .agrillm/ cache) to support reproducibility.

Cached cultivar lists are intended for use by resolve_cultivar() and related functions. No APSIM artefacts are redistributed with the agrillm package.

This function is deliberately conservative to ensure transparent provenance and licence responsibility. The user is responsible for supplying APSIM resources they are authorised to use and for complying with the APSIM licence.

For reproducibility, users are strongly encouraged to reference APSIM resources using a specific commit hash rather than a moving branch (e.g. refs/heads/master).

See also

Examples

if (FALSE) { # \dontrun{
cache_apsim_cultivars(
  apsim_resources_dir =
    "https://raw.githubusercontent.com/APSIMInitiative/ApsimX/<commit>/Models/Resources",
  crop = c("wheat", "barley")
)
} # }