The documentation and benchmarking of GT4SD is contained in this repository. To contribute to this project or any of the elements of GT4SD we recommend you start by reading this contributing guide.
Before you can submit any code we need all contributors to sign a contributor license agreement. By signing a contributor license agreement (CLA) you're basically just attesting to the fact that you are the author of the contribution and that you're freely contributing it under the terms of the MIT License.
When you contribute to the GT4SD project with a new pull request, a bot will evaluate whether you have signed the CLA. If required, the bot will comment on the pull request, including a link to accept the agreement. The individual CLA document is available for review in this repo. You can sign the agreement right away by opening an issue clicking here.
If you would like to contribute to the package, we recommend the following development setup.
-
Create a copy of the repository via the "Fork" button.
-
Clone the gt4sd-core repository:
git clone [email protected]:${GH_ACCOUNT_OR_ORG}/gt4sd-core.git
-
Add remote gt4sd-core repo as an "upstream" in your local repo, so you can check/update remote changes.
git remote add upstream [email protected]:GT4SD/gt4sd-core.git
-
Create a dedicated branch:
cd gt4sd-core git checkout -b a-super-nice-feature-we-all-need
-
Create and activate a dedicated conda environment:
conda env create -f conda_cpu_mac.yml # for linux use conda_cpu_linux.yml conda activate gt4sd
-
Install
gt4sd
in editable mode:pip install -e.
-
Implement your changes and once you are ready run the tests:
# this can take quite long a it's downloading all models and running them multiple times in the tests python -m pytest -sv
And the style checks:
# blacking and sorting imports (this might change your files) python -m black src/gt4sd # checking flake8 and mypy python -m flake8 --disable-noqa --per-file-ignores="__init__.py:F401" src/gt4sd python -m mypy src/gt4sd
Ensure the license headers:
licenseheaders -y 2023 -d src/gt4sd -o "GT4SD team" -t mit.tmpl
-
Once the tests and checks passes, but most importantly you are happy with the implemented feature, commit your changes.
# add the changes git add # commit them git commit -s -m "feat: implementing super nice feature." -m "A feature we all need." # check upstream changes git fetch upstream git rebase upstream/main # push changes to your fork git push -u origin a-super-nice-feature-we-all-need
-
From your fork, open a pull request via the "Contribute" button, the maintainers will be happy to review it.
We recommend the "Python Docstring Generator" extension in VSCode.
However, the types should not be duplicated. The sphinx documentation will pick it up from type annotations. Unfortunately, a custom template is required to not add any types at all.
Its settings are:
"autoDocstring.docstringFormat": "google",
"autoDocstring.startOnNewLine": false,
"autoDocstring.customTemplatePath": "/absolute_path_to/.google_pep484.mustache"
where the last line would point to the custom template file (e.g. in your user home) with the following content: (just placeholders for types are removed):
{{! Google Docstring Template }}
{{summaryPlaceholder}}
{{extendedSummaryPlaceholder}}
{{#parametersExist}}
Args:
{{#args}}
{{var}}: {{descriptionPlaceholder}}
{{/args}}
{{#kwargs}}
{{var}}: {{descriptionPlaceholder}}. Defaults to {{&default}}.
{{/kwargs}}
{{/parametersExist}}
{{#exceptionsExist}}
Raises:
{{#exceptions}}
{{type}}: {{descriptionPlaceholder}}
{{/exceptions}}
{{/exceptionsExist}}
{{#returnsExist}}
Returns:
{{#returns}}
{{descriptionPlaceholder}}
{{/returns}}
{{/returnsExist}}
{{#yieldsExist}}
Yields:
{{#yields}}
{{descriptionPlaceholder}}
{{/yields}}
{{/yieldsExist}}