π§βπ»π€ Contributing to SlickMLπ§ΒΆ
π IntroductionΒΆ
Hello from SlickMLπ§ Team π and welcome to our contributing guidelines π€ . Here we laid out the details of the development process based on our coding standards, and we hope these guidelines would ease the process for you. Please feel free to apply your revisions if you did not find these guidelines useful.
π©ββοΈ Code of ConductΒΆ
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. By participating and contributing to this project, you agree to uphold our Code of Conduct π .
ππ Getting StartedΒΆ
Please note that before starting any major work, open an issue describing what you are planning to work on. The best way to start is to check the
good-first-issue labelπ· on the issue board. In this way, the SlickML team members and other interested parties can give you feedback on the opened issue
πββοΈ regarding the possible idea
π‘, bug
πͺ², or feature
π§¬. Additionally, it will reduce the chance of duplicated work and it would help us to manage the tasks in a parallel fashion; so your pull request would get merged faster π π . Whether the contributions consists of adding new features, optimizing the code-base, or assisting with the documentation, we welcome new contributors of all experience levels. The SlickMLπ§ community goals are to be helpful and effective π .
π Coding StandardsΒΆ
Long time Pythoneer π Tim Peters succinctly channels the BDFLβs guiding principles for Pythonβs design into 20 aphorisms, only 19 of which have been written down as Zen of Python π§ββοΈ .
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases arenβt special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be oneβ and preferably only one βobvious way to do it.
Although that way may not be obvious at first unless youβre Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, itβs a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea β letβs do more of those!
We try to follow Google Python Style Guide as much as possible.
We try to maximize the use of Data Classes in our source codes and unit-tests.
π π₯· Environment ManagementΒΆ
To begin with, install a Python version >=3.9,<3.13.
A working Fortran Compiler (
gfortran
) is also required. If you do not havegcc
installed, the following commands depending on your operating system will take care of this requirement. Please note that installinggcc
sometimes might take couple minutes β³ π€¦ββοΈ.# Mac Users brew install gcc # Linux Users sudo apt install build-essential gfortran
All developments are done via python-poetry. To begin with, first install
poetry
following the installation documentation depending on your operating system.You can also easily manage your Python environments and easily switch between environments via
poetry
. To set thepoetry
environment using your preferredpython
version (i.e.3.9.18
) which is already installed on your system preferably viapyenv
, simply run πββοΈ :poetry env use 3.9.18
Once you setup your environment, to install the dependencies (
poetry.lock
), simply run πββοΈ :poetry install
We mainly use Poe the Poet, a pythonic task runner that works well with
poetry
.To make sure your environmnet is setup correctly, simply run πββοΈ :
poe greet
For more options for task runners, simply run πββοΈ :
poe --help
π FormattingΒΆ
To ease the process and reduce headache πββοΈ , we have serialized the required formatting commands to save more time β°. To apply all the required
formatting
steps, simply run πββοΈ :poe format
poe format
command is essentially runspoe add-trailing-comma
,poe black
andpoe isort
commands behind the scene in a serial fashion. You can learn more about each steps below π .Different versions of python require commas in different places. Trailing commas π is a common issue (C812) in code styles that add-trailing-comma has solved it. To apply
add-trailing-comma
, simply run πββοΈ :poe add-trailing-comma
We save a lot of time β³ and mental energy π for more important matters by using black β¬ as our main code formatter. The only option we have specified over the default values is
line-length = 100
. To applyblack
, simply run πββοΈ :poe black
We also use isort to sort imports libraries alphabetically, and automatically π separated into sections and by type. To apply
isort
, simply run πββοΈ :poe isort
πͺ LintingΒΆ
Similar to formatting, to ease the process and reduce headache πββοΈ , we have serialized the required linting commands to save more time β°. To apply all the required
linting
steps, simply run πββοΈ :poe check
poe check
command is essentially runspoe black --check
,poe isort --check-only
,poe flake8
, andpoe mypy
commands behind the scene in a serial fashion. You can learn more about each steps below π .To lint our code base we use flake8 with flake8-commas extension, and more specification laid out in .flake8 file. To apply
flake8
to the code base, simply run πββοΈ :poe flake8
We also use mypy with more specification laid out in mypy.ini to check static typing of our code base. To apply
mypy
to the code base, simply run πββοΈ :poe mypy
To check if the code is formatted correctly via
black
, you can simply run πββοΈ :poe black --check
To check if the imporetd libraries is sorted correctly via
isort
, you can simply run πββοΈ :poe isort --check-only
π§ͺ TestingΒΆ
We believe in Modern Test Driven Development (TDD) and mainly use pytest, assertpy along with various plugins including pytest-cov with more specification laid out in .coveragerc to develop our unit-tests.
All unit-tests live in
tests/
directory separted from the source code.All unit-test files should begin with the word
test
i.e.test_foo.py
.Our naming convention for naming tests is
test_<method_under_test>__<when>__<then>
pattern which would increase the code readbility.We use pytest-cov plugin π helps to populated a coverage report π for the unit-tests and see the parts of the code that the related unit-tests have not touched π π΅οΈββοΈ.
To run all unit-tests, simply run πββοΈ :
poe test
To run a specific test file, simply run πββοΈ :
poe test tests/test_<file_name>.py
π DocumentationΒΆ
We follow numpydoc style guidelines for docstrings syntax, and best practices π .
We use Sphinx Auto API π€ for generating our API documentation πͺ .
In order to generate the API documentation π from source π² , simply run πββοΈ :
poe sphinx
The generated API documentation file can be found at
docs/_build/index.html
.You can also add a new page in
.rst
ormd
formats underdocs/pages
.All
sphinx
configurations that we are using are available indocs/conf.py
.
π₯ Pull RequestsΒΆ
We currently have
bug-report
andfeature-request
as issue-templates. As laid out above, please make sure to open-up an issue before start working on a major work and get the core team feedback.Try to fix one bug or add one new feature per PR. This would minimize the amount of code changes and it is easier for code-review. Hefty PRs usually do not get merged so fast while it could have been if the work was splitted into multiple PRs clearly laid out in an issue before hand. Therefore, the code reviewer would not be surprised by the work.
We recommend to follow Fork and Pull Request Workflow.
Fork our repository to your own Github account.
Clone the forked repository to your machine.
Create a branch locally; our naming conventions are
bugfix/the-bug-i-fix
andfeature/the-new-feature-i-add
for bug fixes and new features, respectively.Please use present tense verbs for your commit messages i.e.
Fix bug ...
,Add feature ...
, and avoid using past tense verbs.Try to
rebase
the commits as much as possible to keep the git history clean.Follow the
formatting
,linting
, andtesting
guidelines above.Finally, to check cross-compatibility of your changes using different operating systems and python versions, simply run πββοΈ :
poe tox
π Please note that, we are currently running
tox
againstpython versions 3.9, 3.10, and 3.11
. Therefore, you can leveragepyenv
and install these versions and usepyenv local
command (i.e.pyenv local 3.9.X 3.10.Y 3.11.Z
) to activate them before runningpoe tox
.Now, you are ready to push your changes to your forked repository.
Lastly, open a PR in our repository to the
master
branch and follow the PR template so that we can efficiently review the changes as soon as possible and get your feature/bug-fix merged.Nicely done! You are all set! You are now officially part of SlickML contributors.
β π π² Need Help?ΒΆ
Please join our Slack Channel to interact directly with the core team and our small community. This is a good place to discuss your questions and ideas or in general ask for help π¨βπ©βπ§ π« π¨βπ©βπ¦ .