Skip to content

Commit 596d937

Browse files
authored
docs: Create CONTRIBUTING.md
1 parent 20e3874 commit 596d937

File tree

1 file changed

+147
-0
lines changed

1 file changed

+147
-0
lines changed

docs/.github/CONTRIBUTING.md

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# Contributing to PowNet 2.0
2+
3+
Thank you for your interest in contributing to PowNet 2.0! We are excited to welcome new members to our community.
4+
Whether you're looking to fix a bug, add a new feature, improve documentation, or share your examples; your
5+
contributions are highly valuable to us.
6+
7+
This document provides guidelines to help you get started with contributing to PowNet.
8+
9+
## Code of Conduct
10+
11+
While PowNet 2.0 currently has a small community, we are committed to fostering an open, welcoming,
12+
and respectful environment for everyone. We expect all contributors to be respective and considerate with
13+
other members.
14+
15+
Our formal [code of conduct](https://github.com/Critical-Infrastructure-Systems-Lab/PowNet/blob/master/docs/.github/CODE_OF_CONDUCT.md) is also available.
16+
17+
18+
## Ways to contribute
19+
20+
There are many ways you can contribute to PowNet 2.0. Here are some examples:
21+
22+
* **Reporting bugs**: If you encounter a bug, please open an issue tracker. Provide as much detail as possible,
23+
including steps to reproduce the bug, your environment, the error message, and, if possible, your power system model.
24+
25+
* **Fixing bugs:** If you see an open bug report that you think you can fix, feel free to work on it. It would also help
26+
the community to let others know you plan to tackle it.
27+
28+
* **Suggesting enhancements**: If you have an idea for a new feature or improvement (especially computational aspects),
29+
please feel free to open an issue to discuss it.
30+
31+
* **Add a new feature**: You can contribute new functionalities, such as:
32+
- New unit commitment formulations (working with the optim_model module)
33+
- New solution algorithms (working with the optim_model module)
34+
35+
* **Refactoring code**: PowNet 2.0 was born out of research code, so there is always a potential area to improve the code in terms of
36+
readability, maintainability, and performance. For significant refactoring, please open an issue to discuss your proposed changes and
37+
coordinate with our maintainers to avoid conflicts. Our code is used by many research groups around the world!
38+
39+
* **Improving documentation**: You can help with improving our documentation by revising current documentations, adding new ones, and correcting typos
40+
and grammartical errors.
41+
42+
* **Adding unit tests**: Help us ensure the stability and realiability by reviewing existing unit tests and even write new ones.
43+
44+
* **Adding examples**: We welcome interesting ways to use PowNet!
45+
46+
47+
## Getting started on your first contribution
48+
49+
Here is how to make a contribution:
50+
51+
1. Familiarize yourself with the codebase by understanding its structure and conventions (coding style and variable naming conventions)
52+
2. Find an issue or propose a change. You can look for existing issues, especially those with labels like `good first issue` or `help wanted` in our issue tracker.
53+
If you want to work on something not yet tracked, please open a new issue and provide a clear description or the desired feature.
54+
55+
*Note*: for big changes, please discuss your intended approach with our maintainers before you start coding. This helps ensure that
56+
we are using everyone's time efficiently and the development aligns with the project's direction.
57+
58+
4. Setting up your Python environment
59+
- Fork the PowNet 2.0 repository to your local machine, install dependencies within your virtual environment and start coding!
60+
5. Following establish coding practices, such as
61+
- Adopt the project's coding styles and naming convention (more on this below)
62+
- Use `Black` to automatically format your code
63+
- Lint your code with `Flake8`
64+
6. Commt your changes -- make small, and logical commits
65+
7. Submit a pull request (PR) from your branch to the project's default or designated branch as agreed upon in the issue discussion
66+
67+
## Coding style and conventions
68+
69+
To streamline development and maintain readability, we adhere to the following.
70+
71+
* [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html)
72+
* Existing coding style, naming coventions, and architectural patterns already present in the codebase
73+
* Type hinting is encouraged because we automatically generate code documentation
74+
* Code formatting using [Black](https://github.com/psf/black)
75+
* We use [Flake8](https://flake8.pycqa.org/en/latest/) for linting to catch common errors and style issues
76+
77+
78+
## Running unit tests
79+
80+
PowNet 2.0 uses Python's built-in `unittest` framework to ensure code quality and prevent regressions. These tests are located in the `src/test_pownet` directory.
81+
To run all unit tests, navigate to the root PowNet directory in your terminal and execute:
82+
83+
```bash
84+
python -m unittest discover src/test_pownet
85+
```
86+
87+
`Note`: contributions that add new code should include a corresponding unit test. When existing code is modified, ensure all tests pass before submitting a PR.
88+
89+
90+
## Writing commit messages
91+
92+
For newer commits, we follow the [Conventional Commits](https://www.conventionalcommits.org/) specification for the commit messages. This conventional leads to more
93+
readable commit histories and helps automate changelog generation.
94+
95+
A commit message should be structured as ```(commit type): description```. Common commit types are as follow.
96+
97+
* `fix`: A commit that patches a bug in your codebase
98+
* `feat`: A commit that introduces a new feature to the codebase
99+
* `docs`: Documentation only changes.
100+
* `style`: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc).
101+
* `refactor`: A code change that neither fixes a bug nor adds a feature.
102+
* `perf`: A code change that improves performance.
103+
* `test`: Adding missing tests or correcting existing tests.
104+
* `ci`: Changes to our CI configuration files and scripts (example scopes: GitHub, Read the Docs)
105+
* `build`: Changes that affect the build system or external dependencies (example: update package versions)
106+
* `chore`: Other changes that don't modify `src` or `test` files.
107+
108+
**Note on breaking changes**: A breaking change makes the code backward incompatible. Examples include rename/remove/modify existing functions, classes, or methods.
109+
For these changes, please append a `!` after the commity type like `refactor!: ModelBuilder class`.
110+
111+
112+
## Submitting a Pull Request (PR)
113+
114+
When you're ready to submit your changes:
115+
116+
1. Ensure your pull request targets the correct branch in the upstream PowNet 2.0 repository. This will typically be the `main` or `dev` branch, or a specific feature branch as agreed upon in the issue discussion.
117+
2. Provide a clear title and description:
118+
* Write a clear and descriptive title for your PR that summarizes the changes.
119+
* In the PR description, provide a detailed explanation of what your changes do and why they are needed.
120+
* Link to relevant issues using keywords like `Closes #123` or `Fixes #456`.
121+
3. Before submitting, review your own changes one last time (the "diff"). Check for any typos, debugging code, or unintended changes.
122+
4. After submitting your PR, automated checks (Continuous Integration - CI) will run. These typically include running linters, formatters, and unit tests. The outputs
123+
can be found on GitHub's `Action` tab. If your PR fails a build or test, investigate the cause and push new commits to your branch to fix it.
124+
6. Project maintainers and other contributors may review your code and provide feedback. Be open to discussion and willing to make further changes if requested.
125+
126+
127+
## Code Review Process
128+
129+
Code review is a critical part of our development process. It helps maintain code quality, share knowledge, and improve the overall project.
130+
131+
**For Reviewers:**
132+
133+
* Focus on the technical aspects of the code not the author. Provide constructive criticism aimed at improving the code.
134+
* Clearly explain your reasoning and suggest concrete improvements. Don't just say "this is bad", but explain the problem and offer alternatives.
135+
* Check for correctness, clarity, performance, test coverage, and adherence to coding standards.
136+
* Review PRs in a timely manner.
137+
138+
**For Authors:**
139+
140+
* When your code is critiqued, questioned, or constructively criticized, remember that this is part of the collaborative process. Do not take code review personally.
141+
* We trust that you've done your best with the knowledge you have. Mistakes happen, and code review is a chance to catch them.
142+
* Address all comments and questions from reviewers. If you disagree with a suggestion, explain your reasoning respectfully.
143+
144+
## Questions and Discussions
145+
146+
If you have questions about the codebase, a specific issue, or the contribution process, please share your thoughts or questions on GitHub discussions.
147+

0 commit comments

Comments
 (0)