Style guide:
- PEP-8 (as implemented by the
black
code formatting tool) - Python 3.8+ compatible code
- PEP-484 type hints
The development is done using git
, we encourage you to get familiar with it.
Here's a rough guide (improvements are welcome!)
To get the code and start working on the changes you can start a console and:
- Clone the cwltool:
git clone https://github.com/common-workflow-language/cwltool.git
- Switch to cwltool directory:
cd cwltool
It is suggested that you run git config blame.ignoreRevsFile .git-blame-ignore-revs
to filter out mass-formatting commits from git blame
.
In order to contribute to the development of cwltool
, the source code needs to
pass the test before your changes are accepted. There are a couple ways to test
the code with your changes: let tox
manage installation and test running in
virtual environments, or do it manually (preferably in a virtual environment):
- Install
tox
preferably using the OS' package manager, otherwise it can be installed withpip install --user -U tox
- Make your changes to the code and add tests for new cool things you're adding!
- Run the tests with the command
tox
, it's recommended to use some parameters as tox will try to run all the checks in all available python interpreters. - The important tests to run are "unit tests" and "type tests".
To run these two in Python 3.7 (for example), we can tell tox to run only those
tests by running:
tox -e py37-mypy
. (themypy
tox target also runs the unit tests; to just run the type checker usemake mypy
as shown below) - Run
tox -l
to see all available tests and runtimes
For the more traditional workflow:
- Create a virtual environment:
python3 -m venv cwltool
(if you have multiple version of Python installed, then you can replacepython3
in this command with the version you want to use,python3.10
for example) - To begin using the virtual environment, it needs to be activated:
source venv/bin/activate
- To check if you have the virtual environment set up:
which python
and it should point to python executable in your virtualenv - Install the latest versions of
pip
andwheel
withpip install --upgrade pip wheel
- Install cwltool in development mode, along with development tools:
make install-dep dev
- Check the
cwltool
version which might be different from the version installed in general on your system:cwltool --version
- Make your changes to the code and add tests for new cool things you're adding!
- Run the unit-tests to see :
make test
- After you're done working on
cwltool
, you can deactivate the virtual environment:deactivate
Before you commit your code (or at least before you push to GitHub) it is
recommended to run make cleanup
(which is a shortcut for make sort_imports format flake8 diff_pydocstyle_report
)
to fix common issues and point out any remaining code formatting issues
that cannot be fixed automatically.
When tests are passing, you can create git commits in a new branch and push to
GitHub to make a pull request on cwltool
repo
Useful make
commands:
The make
commands below can help you to install the dependencies, format and test your code
make help
to show the list of commands that can be used with the make functionmake install-dep
will install the dependencies needed bycwltool
make format
will clean up your code according to the accepted python standardmake test
will perform the tests ofcwltool
(can take a while to run all tests)make sort_imports
will clean up and sort your import statementsmake remove_unused_imports
will remove any unneededimport
statementsmake flake8
will catch format issues thatmake format
cannot fix automaticallymake diff_pydocstyle_report
check Python docstring style for changed files onlymake diff-cover
to run the tests and point out which lines of code that have been changed as compared to themain
branch are missing test coverage. This is also calculated automatically after all the automatic tests run when you open a Pull Request on GitHub; running it locally can help you confirm that any changes or additions to the tests are sufficient before pushing to GitHub.make cleanup
is a shortcut formake sort_imports format flake8 diff_pydocstyle_report