├── .github ├── ISSUE_TEMPLATE │ ├── blank.md │ ├── bug_report.md │ ├── feature_request.md │ └── subtask-template.md └── workflows │ ├── ci.yml │ ├── main.yml │ ├── python-package.yml │ └── python-publish.yml ├── .gitignore ├── .readthedocs.yaml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── __init__.py ├── docs ├── Makefile ├── make.bat └── source │ ├── Makefile │ ├── conf.py │ ├── index.rst │ ├── make.bat │ ├── modules.rst │ ├── transformerx.data_loader.rst │ ├── transformerx.layers.addnorm.rst │ ├── transformerx.layers.dot_product_attention.rst │ ├── transformerx.layers.masks.global_attention_mask.rst │ ├── transformerx.layers.masks.rst │ ├── transformerx.layers.multihead_attention.rst │ ├── transformerx.layers.positional_encoding.rst │ ├── transformerx.layers.positionwise_ffn.rst │ ├── transformerx.layers.rst │ ├── transformerx.layers.transformer_decoder.rst │ ├── transformerx.layers.transformer_decoder_block.rst │ ├── transformerx.layers.transformer_encoder.rst │ ├── transformerx.layers.transformer_encoder_block.rst │ ├── transformerx.rst │ ├── transformerx.training.base.rst │ ├── transformerx.training.rst │ ├── transformerx.txplot.plot_pe.rst │ ├── transformerx.txplot.rst │ └── transformerx.utils.rst ├── examples ├── encoder_only_classifier.py └── eng2fr_translation.py ├── logo.jpeg ├── pyproject.toml ├── requirements.txt ├── setup.py ├── tests └── layers │ ├── masks │ ├── sequence_masks │ │ └── test_generic.py │ ├── test_atomic_sparse_attention.py │ └── test_core.py │ ├── test_addnorm.py │ ├── test_dot_product_attention.py │ ├── test_multihead_attention.py │ ├── test_positional_encoding.py │ ├── test_positionwise_ffn.py │ ├── test_transformer_decoder.py │ ├── test_transformer_decoder_block.py │ ├── test_transformer_encoder.py │ └── test_transformer_encoder_block.py └── transformerx ├── __backends__.py ├── __init__.py ├── __version__.py ├── data_loader.py ├── layers ├── __init__.py ├── addnorm.py ├── dot_product_attention.py ├── masks │ ├── __init__.py │ ├── atomic_sparse_attention.py │ ├── core.py │ ├── global_attention_mask.py │ ├── lookahead.py │ └── padding.py ├── multihead_attention.py ├── positional_encoding.py ├── positionwise_ffn.py ├── transformer_decoder.py ├── transformer_decoder_block.py ├── transformer_encoder.py └── transformer_encoder_block.py ├── training ├── __init__.py └── base.py ├── txplot ├── __init__.py └── plot_pe.py └── utils.py /.github/ISSUE_TEMPLATE/blank.md: -------------------------------------------------------------------------------- 1 | 2 | [Title] 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG]" 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '[Issues] (https://github.com/issues)' 16 | 2. Click on 'New issue' 17 | 3. Describe the issue 18 | 4. If applicable, copy and paste the full exception message 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Please complete the following information:** 27 | - Version [e.g. 22] 28 | 29 | **Additional context** 30 | Add any other context about the problem here. 31 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[Enhancement]" 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I like to suggest ... 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/subtask-template.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Subtask template 3 | about: Create a subtask issue to reference in a pull request 4 | title: "[Issue name] [#Issue_number]" 5 | labels: Subtask 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Naming convention** 11 | [issue name in the subtasks] [#main_issue_number] 12 | 13 | **Describe the issue in more details** 14 | 15 | **Provide other additional information if available** 16 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Continuous Integration 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | - uses: actions/setup-python@v2 14 | with: 15 | python-version: 3.8 16 | - run: pip install -r requirements.txt 17 | # - run: pytest 18 | - name: Run tests 19 | run: | 20 | pytest tests/ 21 | env: 22 | PYTHONPATH: ${{ github.workspace }} 23 | 24 | - name: Close Stale Issues 25 | uses: actions/stale@v4.1.1 26 | 27 | 28 | # - name: Install dependencies 29 | # run: pip install flake8 30 | # - run: flake8 31 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Auto Assign 2 | on: 3 | issues: 4 | types: [opened] 5 | pull_request: 6 | types: [opened] 7 | jobs: 8 | run: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: bubkoo/auto-assign@v1 12 | with: 13 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 14 | CONFIG_FILE: .github/auto-assign.yml 15 | -------------------------------------------------------------------------------- /.github/workflows/python-package.yml: -------------------------------------------------------------------------------- 1 | # This workflow will install Python dependencies, run tests and lint with a variety of Python versions 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python 3 | 4 | name: Python package 5 | 6 | on: 7 | push: 8 | branches: [ "master" ] 9 | pull_request: 10 | branches: [ "master" ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | strategy: 17 | fail-fast: false 18 | matrix: 19 | python-version: ["3.8", "3.9", "3.10"] 20 | 21 | steps: 22 | - uses: actions/checkout@v3 23 | - name: Set up Python ${{ matrix.python-version }} 24 | uses: actions/setup-python@v3 25 | with: 26 | python-version: ${{ matrix.python-version }} 27 | - name: Install dependencies 28 | run: | 29 | python -m pip install --upgrade pip 30 | python -m pip install flake8 pytest 31 | if [ -f requirements.txt ]; then pip install -r requirements.txt; fi 32 | - name: Lint with flake8 33 | run: | 34 | # stop the build if there are Python syntax errors or undefined names 35 | flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics 36 | # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide 37 | flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics 38 | - name: Test with pytest 39 | run: | 40 | pytest 41 | env: 42 | PYTHONPATH: ${{ github.workspace }} 43 | -------------------------------------------------------------------------------- /.github/workflows/python-publish.yml: -------------------------------------------------------------------------------- 1 | # This workflow will upload a Python Package using Twine when a release is created 2 | # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries 3 | 4 | # This workflow uses actions that are not certified by GitHub. 5 | # They are provided by a third-party and are governed by 6 | # separate terms of service, privacy policy, and support 7 | # documentation. 8 | 9 | name: TransformerX 10 | 11 | on: 12 | release: 13 | types: [published] 14 | 15 | permissions: 16 | contents: read 17 | 18 | jobs: 19 | deploy: 20 | 21 | runs-on: ubuntu-latest 22 | 23 | steps: 24 | - uses: actions/checkout@v3 25 | - name: Set up Python 26 | uses: actions/setup-python@v3 27 | with: 28 | python-version: '3.x' 29 | - name: Install dependencies 30 | run: | 31 | python -m pip install --upgrade pip 32 | pip install build 33 | - name: Build package 34 | run: python -m build 35 | - name: Publish package 36 | uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 37 | with: 38 | user: __token__ 39 | password: ${{ secrets.PYPI_API_TOKEN }} 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | **/__pycache__/ 4 | *.py[cod] 5 | *$py.class 6 | 7 | # C extensions 8 | *.so 9 | 10 | # Distribution / packaging 11 | .Python 12 | #build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | pip-wheel-metadata/ 25 | share/python-wheels/ 26 | *.egg-info/ 27 | .installed.cfg 28 | *.egg 29 | MANIFEST 30 | 31 | # PyInstaller 32 | # Usually these files are written by a python script from a template 33 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 34 | *.manifest 35 | *.spec 36 | 37 | # Installer logs 38 | pip-log.txt 39 | pip-delete-this-directory.txt 40 | 41 | # Unit test / coverage reports 42 | htmlcov/ 43 | .tox/ 44 | .nox/ 45 | .coverage 46 | .coverage.* 47 | .cache 48 | nosetests.xml 49 | coverage.xml 50 | *.cover 51 | *.py,cover 52 | .hypothesis/ 53 | .pytest_cache/ 54 | 55 | # Translations 56 | #*.mo 57 | #*.pot 58 | 59 | # Django stuff: 60 | *.log 61 | local_settings.py 62 | db.sqlite3 63 | db.sqlite3-journal 64 | 65 | # Flask stuff: 66 | instance/ 67 | .webassets-cache 68 | 69 | # Scrapy stuff: 70 | .scrapy 71 | 72 | # Sphinx documentation 73 | docs/_build/ 74 | 75 | # PyBuilder 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | .python-version 87 | 88 | # pipenv 89 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 90 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 91 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 92 | # install all needed dependencies. 93 | #Pipfile.lock 94 | 95 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 96 | __pypackages__/ 97 | 98 | # Celery stuff 99 | celerybeat-schedule 100 | celerybeat.pid 101 | 102 | # SageMath parsed files 103 | *.sage.py 104 | 105 | # Environments 106 | .env 107 | .venv 108 | env/ 109 | venv/ 110 | ENV/ 111 | env.bak/ 112 | venv.bak/ 113 | 114 | # Spyder project settings 115 | .spyderproject 116 | .spyproject 117 | 118 | # Rope project settings 119 | .ropeproject 120 | 121 | # mkdocs documentation 122 | /site 123 | 124 | # mypy 125 | .mypy_cache/ 126 | .dmypy.json 127 | dmypy.json 128 | 129 | # Pyre type checker 130 | .pyre/ 131 | /poetry.lock 132 | workdir 133 | tase.toml 134 | /tase.json 135 | /tase/unknown_errors.txt 136 | .idea 137 | /.idea/ 138 | /certs/ 139 | /docs/source/ 140 | /docs/build/doctrees/ 141 | *.bats 142 | Makefile 143 | source/ 144 | /docs/source/* 145 | /docs/build/html/.buildinfo 146 | /docs/build/html/_static/basic.css 147 | /docs/build/html/_static/debug.css 148 | /docs/build/html/_static/doctools.js 149 | /docs/build/html/_static/documentation_options.js 150 | /docs/build/html/_static/file.png 151 | /docs/build/html/_static/styles/furo.css 152 | /docs/build/html/_static/styles/furo.css.map 153 | /docs/build/html/_static/scripts/furo.js 154 | /docs/build/html/_static/scripts/furo.js.LICENSE.txt 155 | /docs/build/html/_static/scripts/furo.js.map 156 | /docs/build/html/_static/styles/furo-extensions.css 157 | /docs/build/html/_static/styles/furo-extensions.css.map 158 | /docs/build/html/_static/scripts/furo-extensions.js 159 | /docs/build/html/genindex.html 160 | /docs/build/html/index.html 161 | /docs/build/html/_sources/index.rst.txt 162 | /docs/build/html/_static/language_data.js 163 | /docs/build/html/_static/minus.png 164 | /docs/build/html/modules.html 165 | /docs/build/html/_sources/modules.rst.txt 166 | /docs/build/html/objects.inv 167 | /docs/build/html/_static/plus.png 168 | /docs/build/html/py-modindex.html 169 | /docs/build/html/_static/pygments.css 170 | /docs/build/html/search.html 171 | /docs/build/html/searchindex.js 172 | /docs/build/html/_static/searchtools.js 173 | /docs/build/html/_static/skeleton.css 174 | /docs/build/html/_static/sphinx_highlight.js 175 | /examples/temp.py 176 | /docs/build/html/transformerx.data_loader.html 177 | /docs/build/html/_sources/transformerx.data_loader.rst.txt 178 | /docs/build/html/transformerx.html 179 | /docs/build/html/transformerx.layers.addnorm.html 180 | /docs/build/html/_sources/transformerx.layers.addnorm.rst.txt 181 | /docs/build/html/transformerx.layers.dot_product_attention.html 182 | /docs/build/html/_sources/transformerx.layers.dot_product_attention.rst.txt 183 | /docs/build/html/transformerx.layers.html 184 | /docs/build/html/transformerx.layers.masks.global_attention_mask.html 185 | /docs/build/html/_sources/transformerx.layers.masks.global_attention_mask.rst.txt 186 | /docs/build/html/transformerx.layers.masks.html 187 | /docs/build/html/_sources/transformerx.layers.masks.rst.txt 188 | /docs/build/html/transformerx.layers.multihead_attention.html 189 | /docs/build/html/_sources/transformerx.layers.multihead_attention.rst.txt 190 | /docs/build/html/transformerx.layers.positional_encoding.html 191 | /docs/build/html/_sources/transformerx.layers.positional_encoding.rst.txt 192 | /docs/build/html/transformerx.layers.positionwise_ffn.html 193 | /docs/build/html/_sources/transformerx.layers.positionwise_ffn.rst.txt 194 | /docs/build/html/_sources/transformerx.layers.rst.txt 195 | /docs/build/html/transformerx.layers.transformer_decoder.html 196 | /docs/build/html/_sources/transformerx.layers.transformer_decoder.rst.txt 197 | /docs/build/html/transformerx.layers.transformer_decoder_block.html 198 | /docs/build/html/_sources/transformerx.layers.transformer_decoder_block.rst.txt 199 | /docs/build/html/transformerx.layers.transformer_encoder.html 200 | /docs/build/html/_sources/transformerx.layers.transformer_encoder.rst.txt 201 | /docs/build/html/transformerx.layers.transformer_encoder_block.html 202 | /docs/build/html/_sources/transformerx.layers.transformer_encoder_block.rst.txt 203 | /docs/build/html/_sources/transformerx.rst.txt 204 | /docs/build/html/transformerx.training.base.html 205 | /docs/build/html/_sources/transformerx.training.base.rst.txt 206 | /docs/build/html/transformerx.training.html 207 | /docs/build/html/_sources/transformerx.training.rst.txt 208 | /docs/build/html/transformerx.txplot.html 209 | /docs/build/html/transformerx.txplot.plot_pe.html 210 | /docs/build/html/_sources/transformerx.txplot.plot_pe.rst.txt 211 | /docs/build/html/_sources/transformerx.txplot.rst.txt 212 | /docs/build/html/transformerx.utils.html 213 | /docs/build/html/_sources/transformerx.utils.rst.txt 214 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # .readthedocs.yaml 2 | # Read the Docs configuration file 3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 4 | 5 | # Required 6 | version: 2 7 | 8 | # Set the version of Python and other tools you might need 9 | build: 10 | os: ubuntu-22.04 11 | tools: 12 | python: "3.9" 13 | # You can also specify other tool versions: 14 | # nodejs: "19" 15 | # rust: "1.64" 16 | # golang: "1.19" 17 | 18 | # Build documentation in the docs/ directory with Sphinx 19 | sphinx: 20 | configuration: docs/conf.py 21 | 22 | # If using Sphinx, optionally build your docs in additional formats such as PDF 23 | # formats: 24 | # - pdf 25 | 26 | # Optionally declare the Python requirements required to build your docs 27 | python: 28 | install: 29 | - requirements: docs/requirements.txt -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | soran.gdr.cs@gmail.com. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to the TransformerX 2 | 3 | We want to make contributing to this project as easy and transparent as 4 | possible. 5 | 6 | ## Our Development Process 7 | 8 | Minor changes and improvements will be released on an ongoing basis. Larger 9 | changes (e.g., changesets implementing a new paper) will be released on a 10 | more periodic basis. 11 | 12 | ## Pull Requests 13 | 14 | We actively welcome your pull requests. 15 | 16 | 1. Fork the repo and create your branch from `master`. 17 | 2. If you've added code that should be tested, add tests. 18 | 3. If you've changed APIs, update the documentation. 19 | 4. Ensure the test suite passes. 20 | 5. Make sure your code lints (we recomend using Black plugin on Pycharm). 21 | 22 | ## Issues 23 | 24 | We use GitHub issues to track public bugs. Please ensure your description is 25 | clear and has sufficient instructions to be able to reproduce the issue. 26 | 27 | ## Environment setup 28 | 29 | We recommend using Pycharm which handles all these stuff for you with minimal interaction. Also, there are other good IDEs you can use. 30 | 31 | otherwise: 32 | 33 | ```bash 34 | name@user:~$ cd path/to/transformerX 35 | name@user:path/to/transformerX~$ python3 -m venv myenv 36 | name@user:path/to/transformerX~$ source myenv/bin/activate 37 | (myenv) name@user:path/to/transformerX~$ pip3 install -r requirements-test.txt 38 | ``` 39 | 40 | ## Coding Style 41 | 42 | Two options to make sure that the code is formatted and linted properly: 43 | * either you run black, mypy and isort before opening up your PR. 44 | 45 | ```bash 46 | black . 47 | isort . --profile black 48 | flake8 --config .flake8 49 | mypy --ignore-missing-imports --scripts-are-modules --pretty --exclude build/ --exclude stubs/ . 50 | ``` 51 | 52 | * or you can just install black plugin on Pycharm which will make sure that all of the above is run automatically anytime you commit. 53 | 54 | After these steps each of your commits will run the same linting and formatting routines as the TransformerX continuous integration, which greatly helps getting your PRs all green ! 55 | 56 | ## Testing 57 | 58 | ### Static analysis 59 | 60 | ```bash 61 | mypy --ignore-missing-imports --scripts-are-modules --pretty --exclude stubs/ . 62 | ``` 63 | 64 | ### Unit tests 65 | 66 | ```bash 67 | pytest 68 | ``` 69 | 70 | or 71 | 72 | ``` bash 73 | python -m pytest 74 | ``` 75 | 76 | ### Check test coverage 77 | 78 | ``` bash 79 | python -m pytest --cov-report term --cov=template tests 80 | ``` 81 | 82 | ## Commit Guidelines 83 | 84 | We follow the same guidelines as AngularJS. Each commit message consists of a **header**, 85 | a **body** and a **footer**. The header has a special format that includes a **type**, 86 | and a **subject**: 87 | 88 | ```bash 89 | [] 90 | 91 | 92 | 93 |