-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Milestone
Description
We want resource() to be a public accessor function (see #283). That function currently makes a number of checks, including whether the path has an accessible file:
frictionless-r/R/get_resource.R
Lines 33 to 39 in 34a2d01
| if (is.null(resource$path) && is.null(resource$data)) { | |
| cli::cli_abort( | |
| "Resource {.val {resource_name}} must have a {.field path} or | |
| {.field data} property.", | |
| class = "frictionless_error_resource_without_path_data" | |
| ) | |
| } |
We might want to move that check a bit closer to reading the data, not when just accessing the resource.
The use case comes from the etn R package, where we have a datapackage.json file that acts as a template for creating Data Packages. The paths in that file don't refer to paths until data is written. Because of check_path(), accessor functions like schema() or resource() return an error:
library(frictionless)
(p <- read_package("https://raw.githubusercontent.com/inbo/etn/refs/heads/main/inst/assets/datapackage.json"))
#> A Data Package with 5 resources:
#> • animals
#> • tags
#> • detections
#> • deployments
#> • receivers
#> Use `unclass()` to print the Data Package as a list.
get_schema(p, "animals")
#> Error in `purrr::map_chr()` at frictionless-r/R/get_resource.R:60:7:
#> ℹ In index: 1.
#> Caused by error in `check_path()`:
#> ! Can't find file at
#> <https://raw.githubusercontent.com/inbo/etn/refs/heads/main/inst/assets/animals.csv>.Created on 2025-10-07 with reprex v2.1.1
Metadata
Metadata
Assignees
Labels
No labels