|
| 1 | +# pins-python |
| 2 | + |
| 3 | +[](https://mybinder.org/v2/gh/machow/pins-python/HEAD) |
| 4 | + |
| 5 | +The pins package publishes data, models, and other python objects, making it |
| 6 | +easy to share them across projects and with your colleagues. You can pin |
| 7 | +objects to a variety of pin *boards*, including folders (to share on a |
| 8 | +networked drive or with services like DropBox), RStudio Connect, and Amazon |
| 9 | +S3. |
| 10 | +Pins can be automatically versioned, making it straightforward to track changes, |
| 11 | +re-run analyses on historical data, and undo mistakes. |
| 12 | + |
| 13 | +## Installation |
| 14 | + |
| 15 | +```shell |
| 16 | +python -m pip install pins |
| 17 | +``` |
| 18 | + |
| 19 | +## Usage |
| 20 | + |
| 21 | +See the [documentation](https://rstudio.github.io/pins-python) for getting started. |
| 22 | + |
| 23 | +## Development |
| 24 | + |
| 25 | +### Install pins with dev dependencies |
| 26 | + |
| 27 | +```shell |
| 28 | +python -m pip install -e .[dev] |
| 29 | +``` |
| 30 | + |
| 31 | +### Install pre-commit hooks |
| 32 | + |
| 33 | +This project uses [pre-commit](https://pre-commit.com/) to check and format each commit. |
| 34 | + |
| 35 | +You can set it up by running the following code in this repo: |
| 36 | + |
| 37 | +``` |
| 38 | +python -m pip install pre-commit |
| 39 | +pre-commit install |
| 40 | +``` |
| 41 | + |
| 42 | +### Setting version number |
| 43 | + |
| 44 | +This project uses [setuptools_scm](https://github.com/pypa/setuptools_scm) to |
| 45 | +automatically track and change version numbers within the `pins` package. |
| 46 | +It works by checking the last tagged commit. |
| 47 | + |
| 48 | +In order to set the version number, create a tag like the following. |
| 49 | + |
| 50 | +```shell |
| 51 | +git tag v0.0.1 |
| 52 | +``` |
| 53 | + |
| 54 | +In order to see the version number being used for the current commit, run: |
| 55 | + |
| 56 | +``` |
| 57 | +python -m setuptools_scm |
| 58 | +``` |
| 59 | + |
| 60 | +## Test |
| 61 | + |
| 62 | +Tests can be run using pytest: |
| 63 | + |
| 64 | +```shell |
| 65 | +pytest pins |
| 66 | + |
| 67 | +# run all tests except those for Rstudio Connect |
| 68 | +pytest pins -m 'not fs_rsc' |
| 69 | + |
| 70 | +# run only local filesystem backend tests |
| 71 | +pytest pins -m 'fs_file' |
| 72 | +``` |
| 73 | + |
| 74 | +There are two important details to note for testing: |
| 75 | + |
| 76 | +* **Backends**. pins can write to backends like s3, azure, and RStudio Connect, so you |
| 77 | + will need to set credentials to test against them. |
| 78 | +* **Pytest Marks**. You can disable tests over a specific backend through pytest's |
| 79 | + `-m` flag. For example... |
| 80 | + - Skip S3: `pytest pins -m 'not fs_s3'` |
| 81 | + - Test only s3: `pytest pins -m 'fs_s3'` |
| 82 | + - List all marks: `pytest pins --markers` |
| 83 | + |
| 84 | +### Configuring backends |
| 85 | + |
| 86 | +* Copy `.env.dev` to be `.env` |
| 87 | +* Modify `.env` to file in environment variables (e.g. AWS_ACCESS_KEY_ID) |
| 88 | +* Be careful not to put any sensitive information in `.env.dev`! |
| 89 | + |
| 90 | +### Setting up RStudio Connect tests |
| 91 | + |
| 92 | +``` |
| 93 | +# Be sure to set RSC_LICENSE in .env |
| 94 | +make dev |
| 95 | +``` |
0 commit comments