This is a Python SDK for interacting with the graphql API published by Galley (references: Galley Homepage; Galley API Explorer). Currently maintained by the engineering team at Thistle but open to PRs from others.
To set up your environment and install the required dependencies for local development, you will may use both Python and a virtual environment tool like virtualenv or pyenv-virtualenv or the supplied Development Container.
First make sure you're using Python 3.9. If you use pyenv, it'll select Python 3.9 automatically based on the .python-version file (and complain if you don't have 3.9 installed). Other installation methods are an exercise for the intrepid reader.
$ git clone git@github.com:Thistle/galley-sdk.git
$ cd galley-sdk
$ virtualenv venv
$ . venv/bin/activate
$ pip install -r requirements.txt
You can install pyenv and pyenv-virtualenv with brew:
brew install pyenv pyenv-virtualenv
To use galley-sdk in pyenv-virtualenv:
$ git clone git@github.com:Thistle/galley-sdk.git
$ cd galley-sdk
$ pyenv install 3.9
$ pyenv virtualenv 3.9 py39
$ pyenv activate py39
$ pip install -r requirements.txt
Note: When using galley-sdk in the future, make sure you run
pyenv activate py39beforehand to be in the correct virtual envrionment.
To use the development container you will need a docker environment installed.
If you are using VS Code you can then just open the project and you will be prompted to open the project in a container.
You will not need to install any local python or virtual environments if you use the development container.
To use galley-sdk within your application, you can install from this repository using pip's version control system support to specify a git ref such as a branch name, commit hash, or tag name. This example assumes you are using Git:
pip install git+git://github.com/Thistle/galley-sdk.git@<git-ref>#egg=galley-sdk
First, you will need to set up credentials. Create a file called .env in the root directory of the project and set these two environment variables with your valid credentials for Galley's API:
GALLEY_API_KEY=<your-organization's-API-key>
GALLEY_URL=<Galley's-staging-or-production-url>
Now you can use the package to make requests to Galley. For example, to retrieve recipe data:
import galley
from galley.queries import get_raw_recipes_data
get_raw_recipes_data(["cmVjaXBlOjE4MTc5OQ=="], "Burlington")
To run all unit tests:
python -m unittest tests/test_*
To run a specific test:
python -m unittest tests.test_queries.TestQueryGalleyRecipes.test_get_recipe_data_successful