Development
This guide walks you through the workflow for developing new metrics in the SDMetrics library.
Have you defined your metric? Before you begin development, we recommend you read the Defining your metric guide, file an issue and wait for our feedback. This will prevent any throwaway work and help us release the metric faster.
Local Setup
Get your machine for local development.
Fork the SDMetrics repo on GitHub and then clone your fork locally
$ git clone [email protected]:your_username/SDMetrics2. Install your local copy. We recommend using a virtual environment, such as virtualenv or conda.
(env)$ cd SDMetrics/
(env)$ make install-develop3. Create a branch for local development
(env)$ git checkout -b issue-123-adding-your-new-metric4. Now you can develop your metric locally on your branch.
Testing
Please thoroughly test and verify changes before making a pull request
Add new unit tests
Your new metric should include at least one associated test method. It's likely that you have multiple use cases or scenarios. Write a separate test method for each.
Scope
Each test should validate only the code that you wrote. If you are using another library, assume that it works properly when being passed the right values and use the mock package to mock any random behavior. Do not read or write to any file system or database.
Structure
Write your unit tests inside the tests folder, which contains the same hierarchy as sdmetrics. Begin the filename with test_. For example, if your metric code is written inside:
sdmetrics/column_pairs/statistical/your_module.pyThen the corresponding unit tests should be written in:
tests/sdmetrics/column_pairs/statistical/test_your_module.pyUnit tests should use only the unittest and pytest modules. Each test method should start with the test_ prefix and have descriptive names about the scenario covered.
Existing tests
Your changes should also pass the existing tests and style checks in the library.
Check the style of your code using lint:
(env)$ make lintRun the full test suite:
(env)$ make testTip! During development, you can also run a subset of tests for convenience.
(env)$ python -m pytest tests.test_my_metric_timeout
(env)$ python -m pytest -k 'my_metric'Run make test-all to test all supported Python versions.
Get a full coverage report:
(env)$ make coverageMaking a pull request
When you are done developing your metric and testing, you can make a pull request. This lets us know that your code is ready for review.
Make sure you've committed all changes to your branch and pushed it to GitHub
(env)$ git add .
(env)$ git commit -m "<Descriptive details about the new metric>"
(env)$ git push origin issue-123-your-new-metric-nameThen, you can make a pull request through the SDMetrics GitHub site.
Click the button below to make your pull request.
And that's it! A member of the core SDV team will review your changes and leave feedback on the pull request. Your code may require a few changes before it's ready to be merged.
The SDV open source team is a passionate but small group of maintainers. We appreciate your time and patience as we review your contributions! Feel free to reach out to us via your GItHub issue or Slack with any questions or concerns.
Last updated
