Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add contribution docs #69

Merged
merged 8 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

34 changes: 34 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Bug
description: Report a bug or an unexpected behavior
labels: [bug]

body:
- type: markdown
attributes:
value: Thank you for contributing to EcoLogits! 💪

- type: textarea
id: description
attributes:
label: Description
description: |
Please explain what you're seeing and what you would expect to see.

Please provide as much detail as possible to make understanding and solving your problem as quick as possible. 🙏
validations:
required: true

- type: textarea
id: example
attributes:
label: Example Code
description: >
If applicable, please add a self-contained,
[minimal, reproducible, example](https://stackoverflow.com/help/minimal-reproducible-example)
demonstrating the bug.

placeholder: |
import ecologits

...
render: Python
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: 🤔 Ask a Question
url: 'https://github.com/genai-impact/ecologits/discussions/new?category=q-a'
about: Ask a question about how to use EcoLogits using GitHub discussions
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Feature request
description: Suggest a new feature for EcoLogits
labels: [feature request]

body:
- type: markdown
attributes:
value: Thank you for contributing to EcoLogits! 💪

- type: textarea
id: description
attributes:
label: Description
description: |
Please give as much detail as possible about the feature you would like to suggest. 🙏

You might like to add:
* A demo of how code might look when using the feature
* Your use case(s) for the feature
* Why the feature should be added to EcoLogits (as opposed to another library or just implemented in your code)
validations:
required: true
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Feature request
about: Suggest an idea for this project
name: Generic issue template
about: Suggest a feature or report a bug.
title: ''
labels: ''
assignees: ''
Expand All @@ -9,7 +9,7 @@ assignees: ''

## Description

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
A clear and concise description of what the problem is.


## Solution
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@

.PHONY: install
install:
poetry install --all-extras --with dev,docs

.PHONY: test
test:
poetry run pytest

.PHONY: test-record
test-record:
poetry run pytest --record-mode=once

.PHONY: pre-commit
pre-commit:
pre-commit run --all-files

.PHONY: docs
docs:
poetry run mkdocs build
49 changes: 3 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,51 +49,8 @@ See package documentation on [EcoLogits](https://ecologits.ai/)

## 💪 Contributing

### Requirements
To get started with setting up a development environment and making a contribution to EcoLogits, see [Contributing to EcoLogits](https://ecologits.ai/latest/contributing/).

Have [poetry](https://python-poetry.org/docs/#installation) installed on your system.


<details>
<summary>
Easy install using a virtualenv:
</summary>

Create a venv:

```shell
python3 -m venv .venv
source .venv/bin/activate
```

Install poetry:

```shell
pip install poetry
```

</details>


### Install project

```shell
poetry install --all-extras --with dev,docs
```


### Run tests

```shell
poetry run pytest
```


### Run pre-commit hooks locally

[Install pre-commit](https://pre-commit.com/)

```shell
pre-commit run --all-files
```
## ⚖️ License

This project is licensed under the terms of the [Mozilla Public License Version 2.0 (MPL-2.0)](https://www.mozilla.org/en-US/MPL/2.0/).
8 changes: 8 additions & 0 deletions docs/assets/badges/contributor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "EcoLogits",
"message": "contributor",
"logoSvg": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"500\" zoomAndPan=\"magnify\" viewBox=\"0 0 375 374.999991\" height=\"500\" preserveAspectRatio=\"xMidYMid meet\" version=\"1.0\"><path fill=\"#00bf63\" d=\"M 326.804688 346.207031 C 340.140625 315.519531 359.949219 255.769531 340.488281 191.972656 C 308.566406 87.300781 183.3125 12.246094 32.578125 21.96875 C 12.5625 149.667969 61.890625 269.296875 154.832031 322.671875 C 217.4375 358.625 282.296875 354.4375 313.011719 350.148438 C 281.5625 326.3125 246.261719 295.6875 210.96875 256.914062 C 156.5 197.070312 120.140625 137.6875 96.078125 90.304688 C 130.648438 138.527344 172.191406 190.617188 221.824219 243.839844 C 257.636719 282.246094 293.011719 316.25 326.804688 346.207031 Z M 326.804688 346.207031 \" fill-opacity=\"1\" fill-rule=\"nonzero\"/></svg>",
"logoWidth": 10,
"labelColor": "#0B3B36",
"color": "#E0D0F5"
}
8 changes: 8 additions & 0 deletions docs/assets/badges/enabled.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "EcoLogits",
"message": "enabled",
"logoSvg": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"500\" zoomAndPan=\"magnify\" viewBox=\"0 0 375 374.999991\" height=\"500\" preserveAspectRatio=\"xMidYMid meet\" version=\"1.0\"><path fill=\"#00bf63\" d=\"M 326.804688 346.207031 C 340.140625 315.519531 359.949219 255.769531 340.488281 191.972656 C 308.566406 87.300781 183.3125 12.246094 32.578125 21.96875 C 12.5625 149.667969 61.890625 269.296875 154.832031 322.671875 C 217.4375 358.625 282.296875 354.4375 313.011719 350.148438 C 281.5625 326.3125 246.261719 295.6875 210.96875 256.914062 C 156.5 197.070312 120.140625 137.6875 96.078125 90.304688 C 130.648438 138.527344 172.191406 190.617188 221.824219 243.839844 C 257.636719 282.246094 293.011719 316.25 326.804688 346.207031 Z M 326.804688 346.207031 \" fill-opacity=\"1\" fill-rule=\"nonzero\"/></svg>",
"logoWidth": 10,
"labelColor": "#0B3B36",
"color": "#EDF4F3"
}
8 changes: 8 additions & 0 deletions docs/assets/badges/sponsor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "EcoLogits",
"message": "sponsor",
"logoSvg": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"500\" zoomAndPan=\"magnify\" viewBox=\"0 0 375 374.999991\" height=\"500\" preserveAspectRatio=\"xMidYMid meet\" version=\"1.0\"><path fill=\"#00bf63\" d=\"M 326.804688 346.207031 C 340.140625 315.519531 359.949219 255.769531 340.488281 191.972656 C 308.566406 87.300781 183.3125 12.246094 32.578125 21.96875 C 12.5625 149.667969 61.890625 269.296875 154.832031 322.671875 C 217.4375 358.625 282.296875 354.4375 313.011719 350.148438 C 281.5625 326.3125 246.261719 295.6875 210.96875 256.914062 C 156.5 197.070312 120.140625 137.6875 96.078125 90.304688 C 130.648438 138.527344 172.191406 190.617188 221.824219 243.839844 C 257.636719 282.246094 293.011719 316.25 326.804688 346.207031 Z M 326.804688 346.207031 \" fill-opacity=\"1\" fill-rule=\"nonzero\"/></svg>",
"logoWidth": 10,
"labelColor": "#0B3B36",
"color": "#00BF63"
}
118 changes: 116 additions & 2 deletions docs/contributing.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,118 @@
# Contribution

!!! warning
Help us improve EcoLogits by contributing! :tada:

This page is under construction.
## Issues

Questions, feature requests and bug reports are all welcome as [discussions or issues](https://github.com/genai-impact/ecologits/issues/new/choose).

When submitting a feature request or bug report, please provide as much detail as possible. For bug reports, please include relevant information about your environment, including the version of EcoLogits and other Python dependencies used in your project.

## Pull Requests

Getting started and creating a Pull Request is a straightforward process. Since EcoLogits is regularly updated, you can expect to see your contributions incorporated into the project within a matter of days or weeks.

For non-trivial changes, please create an issue to discuss your proposal before submitting pull request. This ensures we can review and refine your idea before implementation.

### Prerequisites

You'll need to meet the following requirements:

- **Python version above 3.9**
- **git**
- **make**
- **[poetry](https://python-poetry.org/docs/#installation)**
- **[pre-commit](https://pre-commit.com/#install)**

### Installation and setup

Fork the repository on GitHub and clone your fork locally.

```shell
# Clone your fork and cd into the repo directory
git clone [email protected]:<your username>/ecologits.git
cd ecologits

# Install ecologits development dependencies with poetry
make install
```

### Check out a new branch and make your changes

Create a new branch for your changes.

```shell
# Checkout a new branch and make your changes
git checkout -b my-new-feature-branch
# Make your changes and implements tests...
```

### Run tests

Run tests locally to make sure everything is working as expected.

```shell
make test
```

If you have added a new provider you will need to record your tests with VCR.py through [pytest-recording](https://github.com/kiwicom/pytest-recording).

```shell
make test-record
```

Once your tests are recorded, please check that the newly created cassette files (located in `tests/cassettes/...`) do not contain any sensible information like API tokens. If so you will need to update the configuration accordingly in `conftest.py` and run again the command to record tests.

### Build documentation

If you've made any changes to the documentation (including changes to function signatures, class definitions, or docstrings that will appear in the API documentation), make sure it builds successfully.

```shell
# Build documentation
make docs
# If you have changed the documentation, make sure it builds successfully.
```

You can also serve the documentation locally.

```shell
# Serve the documentation at localhost:8000
poetry run mkdocs serve
```

### Code formatting and pre-commit

Before pushing your work, run the pre-commit hook that will check and lint your code.

```shell
# Run all checks before commit
make pre-commit
```

### Commit and push your changes

Commit your changes, push your branch to GitHub, and create a pull request.

Please follow the pull request template and fill in as much information as possible. Link to any relevant issues and include a description of your changes.

When your pull request is ready for review, add a comment with the message "please review" and we'll take a look as soon as we can.

## Documentation style

Documentation is written in Markdown and built using [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/). API documentation is build from docstrings using [mkdocstrings](https://mkdocstrings.github.io/).

### Code documentation

When contributing to EcoLogits, please make sure that all code is well documented. The following should be documented using properly formatted docstrings.

We use [Google-style docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings) formatted according to [PEP 257](https://peps.python.org/pep-0257/) guidelines. (See [Example Google Style Python Docstrings](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) for further examples.)

### Documentation style

Documentation should be written in a clear, concise, and approachable tone, making it easy for readers to understand and follow along. Aim for brevity while still providing complete information.

Code examples are highly encouraged, but should be kept short, simple and self-contained. Ensure that each example is complete, runnable, and can be easily executed by readers.

## Acknowledgment

We'd like to acknowledge that this contribution guide is heavily inspired by the excellent [guide from Pydantic](https://docs.pydantic.dev/latest/contributing/). Thanks the inspiration! :heart:
Loading