Contribute as a developer#
Fork the project to create a copy.
Clone the repository to download the copy to your local machine.
Install the project in editable mode.
Verify your changes to the project by running tests.
Adhere to code style.
Understand the different CI/CD pipelines that are executed automatically.
Fork the repository#
Forking the repository is the first step to contributing to the project. This allows you to have your own copy of the project so that you can make changes without affecting the main project. Once you have made your changes, you can submit a pull request to the main project to have your changes reviewed and merged.
Note
If you are an Ansys employee, you can skip this step.
Clone the repository#
Clone the repository in development mode:
git clone https://github.com/pyansys/pyansys-heart
Note
If you are not an Ansys employee, you must fork the repository and
replace ansys
with your GitHub user name in the git clone
command.
Install for developers#
Installing PyAnsys Heart in development mode lets you change the code and see these changes reflected in your environment without having to reinstall the library every time you make a change.
Set up a virtual environment#
Navigate to the project’s root directory :
cd pyansys-heart
Create a virtual environment named
.venv
to isolate your Python environment:
python -m venv .venv
Activate the virtual environment:
.venv\Scripts\activate.bat
.venv\Scripts\Activate.ps1
source .venv/bin/activate
Install in development mode#
Install PyAnsys Heart in editable mode:
python -m pip install --editable .
Verify the installation by checking the version of the library:
from ansys.health.heart import __version__
print(f"PyAnsys Heart version is {__version__}")
>>> PyAnsys Heart version is 0.13.3.
Install Tox#
Once the project is installed, you can install Tox. This is a cross-platform automation tool. The main advantage of Tox is that it eases routine tasks like project testing, documentation generation, and wheel building in separate and isolated Python virtual environments.
Install Tox:
python -m pip install tox
#. Verify the installation by listing all the different environments (automation rules) for PyAnsys Heart:
python -m tox listDefault Tox environments
Environment
Description
code-style
Check for code style
tests310-coverage
Environment for project testing with Python 3.10 and coverage
tests310
Environment for project testing with Python 3.10
tests311-coverage
Environment for project testing with Python 3.11 and coverage
tests311
Environment for project testing with Python 3.11
tests312-coverage
Environment for project testing with Python 3.12 and coverage
tests312
Environment for project testing with Python 3.12
tests313-coverage
Environment for project testing with Python 3.13 and coverage
tests313
Environment for project testing with Python 3.13
doc-links
Environment for verifying the integrity of external links within the documentation
doc-html
Environment for generating HTML documentation
doc-pdf
Environment for generating PDF documentation
dist
Checks project distribution
doc-clean
Environment for cleaning documentation generated files
tests
Environment for project testing with Python3
Run the tests#
Once you have made your changes, you can run the tests to verify that your changes did not break the project. PyAnsys Heart tests support different markers to allow testing with or without coverage (and against specific Python versions). These markers are associated with dedicated Tox environments.
Testing environments
Environment |
Command |
---|---|
tests310-coverage |
python -m tox -e tests310-coverage |
tests310 |
python -m tox -e tests310 |
tests311-coverage |
python -m tox -e tests311-coverage |
tests311 |
python -m tox -e tests311 |
tests312-coverage |
python -m tox -e tests312-coverage |
tests312 |
python -m tox -e tests312 |
tests313-coverage |
python -m tox -e tests313-coverage |
tests313 |
python -m tox -e tests313 |
tests |
python -m tox -e tests |
Note
The preceding test code runs all tests, including those that require Fluent (which take longer). For more
selective testing, append -- -vv -m "not requires_fluent or (not extract_models)"
or -- -vv -m "requires_fluent"
to Tox testing commands:
# run quick tests
python -m tox -e tests312-coverage -- -vv -m "not requires_fluent or (not extract_models)"
# run tests requiring Fluent
python -m tox -e tests312-coverage -- -vv -m "requires_fluent"
Check code style#
PyAnsys Heart follows the PEP 8 standard as described in PEP 8 in the PyAnsys developer’s guide and implements style checking using pre-commit.
To ensure your code meets minimum code styling standards, run the following Tox environment:
Code style environment
Environment |
Command |
---|---|
code-style |
python -m tox -e code-style |
This way, it’s not possible for you to push code that fails the style checks:
$ git commit -am "added my cool feature"
black....................................................................Passed
blacken-docs.............................................................Passed
isort....................................................................Passed
flake8...................................................................Passed
codespell................................................................Passed
pydocstyle...............................................................Passed
check for merge conflicts................................................Passed
debug statements (python)................................................Passed
check yaml...............................................................Passed
trim trailing whitespace.................................................Passed
Validate GitHub Workflows................................................Passed
Run CI/CD pipelines#
PyAnsys Heart has a set of CI/CD pipelines that are executed automatically when certain events are detected in the repository. Some of these events include opening a pull request, labeling a pull-request, and tagging a commit.
You can label a pull request to skip certain jobs in the pipeline. Supported labels are listed on the PyAnsys Heart labels page.
Label |
Description |
---|---|
|
Skip the model generation tests |