Ryan Abernathey09/09/2019, 6:26 PM
objects. In Pangeo, our I/O stack is something like Google Cloud Storage <- GCSFS <- Zarr -< Xarray. I would like a Prefect task to write data to GCS. The normal way I would do this (without Prefect) is:
Obviously I can do that from within a Prefect task, but it kind of seems like I should be using a
python ds = # ... create xarray Dataset gcfs_w_token = gcsfs.GCSFileSystem(project='pangeo-181919', token=token) gcsmap = gcsfs.GCSMap(path, gcs=gcfs_w_token) ds.to_zarr(gcsmap)
. Can you point me to any examples of custom handlers? (Bonus points if they show how to use secure credentials.) Thanks again for an awesome tool.
Chris White09/09/2019, 6:41 PM
methods that are inverses of each other (and it needs to be cloudpickle-able for running on dask). For example, here is our internal implementation of a GCS result handler: https://github.com/PrefectHQ/prefect/blob/master/src/prefect/engine/result_handlers/gcs_result_handler.py This implementation won’t be nearly as performant as using
, but should convey the idea. This handler also uses “Prefect Secrets” --> when running locally, secrets are pulled from
, and can be set via environment variable (e.g.,
). If you need added security, you could use an encryption package for parsing the secret.
Ryan Abernathey09/09/2019, 6:43 PM
Chris White09/09/2019, 6:43 PM
- the appropriate setting needs to be turned on via env var / config:
keyword as above
Ryan Abernathey09/09/2019, 6:47 PM
Chris White09/09/2019, 6:49 PM