|
| 1 | +--- |
| 2 | +jupytext: |
| 3 | + formats: md:myst |
| 4 | + text_representation: |
| 5 | + extension: .md |
| 6 | + format_name: myst |
| 7 | + format_version: 0.13 |
| 8 | + jupytext_version: 1.13.6 |
| 9 | +kernelspec: |
| 10 | + display_name: venv-pins-python |
| 11 | + language: python |
| 12 | + name: venv-pins-python |
| 13 | +--- |
| 14 | + |
| 15 | +# Welcome |
| 16 | + |
| 17 | +The pins package publishes data, models, and other R objects, making it easy to share them across projects and with your colleagues. |
| 18 | +You can pin objects to a variety of pin *boards*, including folders (to share on a networked drive or with services like DropBox), RStudio Connect, Amazon S3, Azure storage and ~Microsoft 365 (OneDrive and SharePoint)~. |
| 19 | +Pins can be automatically versioned, making it straightforward to track changes, re-run analyses on historical data, and undo mistakes. |
| 20 | + |
| 21 | +## 🚧 Installation |
| 22 | + |
| 23 | +To try out the development version of pins you'll need to install from GitHub: |
| 24 | + |
| 25 | +```shell |
| 26 | +python -m pip install git+https://github.com/machow/pins-python |
| 27 | +``` |
| 28 | + |
| 29 | +## Usage |
| 30 | + |
| 31 | +To use the pins package, you must first create a pin board. |
| 32 | +A good place to start is `board_folder()`, which stores pins in a directory you specify. |
| 33 | +Here I'll use a special version of `board_folder()` called `board_temp()` which creates a temporary board that's automatically deleted when your R session ends. |
| 34 | +This is great for examples, but obviously you shouldn't use it for real work! |
| 35 | + |
| 36 | +```{code-cell} ipython3 |
| 37 | +from pins import board_temp |
| 38 | +from pins.data import mtcars |
| 39 | +
|
| 40 | +board = board_temp() |
| 41 | +board |
| 42 | +``` |
| 43 | + |
| 44 | +You can "pin" (save) data to a board with `pin_write()`. |
| 45 | +It takes three arguments: the board to pin to, an object, and a name: |
| 46 | + |
| 47 | +```{code-cell} ipython3 |
| 48 | +board.pin_write(mtcars.head(), "mtcars", type="csv") |
| 49 | +``` |
| 50 | + |
| 51 | +~As you can see, the data saved as an `.rds` by default~, but depending on what you're saving and who else you want to read it, you might use the `type` argument to instead save it as a `csv`, ~`json`, or `arrow`~ file. |
| 52 | + |
| 53 | +You can later retrieve the pinned data with `pin_read()`: |
| 54 | + |
| 55 | +```{code-cell} ipython3 |
| 56 | +board.pin_read("mtcars") |
| 57 | +``` |
| 58 | + |
| 59 | +A board on your computer is good place to start, but the real power of pins comes when you use a board that's shared with multiple people. |
| 60 | +To get started, you can use `board_folder()` with a directory on a shared drive or in dropbox, or if you use [RStudio Connect](https://www.rstudio.com/products/connect/) you can use `board_rsconnect()`: |
| 61 | + |
| 62 | +🚧 TODO: add informational messages shown in display below |
| 63 | + |
| 64 | ++++ |
| 65 | + |
| 66 | +```python |
| 67 | +board <- board_rsconnect() |
| 68 | +#> Connecting to RSC 1.9.0.1 at <https://connect.rstudioservices.com> |
| 69 | +board.pin_write(tidy_sales_data, "sales-summary", type = "rds") |
| 70 | +#> Writing to pin 'hadley/sales-summary' |
| 71 | +``` |
| 72 | + |
| 73 | ++++ |
| 74 | + |
| 75 | +Then, someone else (or an automated Rmd report) can read and use your pin: |
| 76 | + |
| 77 | ++++ |
| 78 | + |
| 79 | +```python |
| 80 | +board = board_rsconnect() |
| 81 | +board.pin_read("hadley/sales-summary") |
| 82 | +``` |
| 83 | + |
| 84 | ++++ |
| 85 | + |
| 86 | +You can easily control who gets to access the data using the RStudio Connect permissions pane. |
| 87 | + |
| 88 | +The pins package also includes boards that allow you to share data on services like Amazon's S3 (`board_s3()`), Azure's blob storage (`board_azure()`), and Microsoft SharePoint (`board_ms365()`). |
| 89 | +Learn more in [getting started](getting_started.Rmd). |
0 commit comments