This is a collection of sample code and directions for creating plugins and providers for Snowfakery. I have a blog post that explain how to create Snowfakery plugins in more detail.
- Python 3 (generally recent-ish version).
- Snowfakery 1.9 or later.
- Faker module for python (
pip3 install Faker).- A Faker sample community provider like Microservice:
pip3 install faker-microservice
- A Faker sample community provider like Microservice:
- A recipe to work from (see recipes folder).
- Create a directory in your project to hold your plugins.
- Create a file named
__init__.pyin that directory to make a package. - Create directory for your new provider with the pattern
faker_[my_service_name], in my casefaker_nonprofit. - In the directory create a file named
__init__.pythis defines the faker provider module. - Create your provider in that file (see example for details):
import faker.providersto make sure you have required classes.- Define a series of dictionaries for providers creating text.
- Create a class that extends the base:
class Provider(faker.providers.BaseProvider): - Define a method that returns the desired values:
def nonprofit_name(self):
- Create
test.pyin yourpluginsdirectory. - Add tests to make sure it works cause it helps keep life easy (see example):
$ python -m plugins.test
- Open the basic recipe you want to use for testing (start with something simple you already know how to use).
- Add a new line at the top to load the new plugin:
- plugin: plugins.faker_nonprofit - Add/Update a field to use the new provider.