rstudio / pins-r

Pin, Discover and Share Resources
https://pins.rstudio.com
Other
301 stars 62 forks source link

Posit Connect manifests should provide `files` as an object, not an array #815

Open toph-allen opened 6 months ago

toph-allen commented 6 months ago

Manifests for pins deployed to Connect have files fields that are flat arrays.

"files":["data.csv","data.rds","index.html"]

However, Connect's manifests have files in a JSON object, where the keys are the file names and the values are the checksums, like so:

"files": {
  "data.csv": {
    "checksum": "553e83c5e7e7d606ac0657ce3f805512"
  },
  "data.rds": {
    "checksum": "553e83c5e7e7d606ac0657ce3f805512"
  },
  "index.html": {
    "checksum": "553e83c5e7e7d606ac0657ce3f805512"
  }
}

So, for example, rsconnect-python cannot deploy manifests that Pins produces.

In the code: pins:::rsc_bundle_manifest provides the files as a flat array, and references rsconnect::createAppManifest.

https://github.com/rstudio/pins-r/blob/aea52de07d1c90c23062566d81dbc5445236b712/R/board_connect_bundle.R#L21-L23

In rsconnect::createAppManifest:

https://github.com/rstudio/rsconnect/blob/d8c89dd9dd68fef6192fb4eef008ade1d65507ad/R/bundle.R#L150-L160

  # build the list of files to checksum
  files <- list.files(appDir, recursive = TRUE, all.files = TRUE,
                      full.names = FALSE)

  # provide checksums for all files
  filelist <- list()
  for (file in files) {
    filepath <- file.path(appDir, file)
    checksum <- list(checksum = fileMD5(filepath))
    filelist[[file]] <- I(checksum)
  }