Contributing
This page provides the general guidelines for contributing to the Gen AI SDK.
Requirements
Below are the requirements needed to contribute to the Gen AI SDK.
Python 3.11+
Although not required, it is recommended to use Miniconda to manage python environments.
Poetry 2.1.3+
Please refer to the installation guide. After installing, close and re-open the terminal window for the changes to take effect.
gcloud CLI
Please refer to the installation guide. After installing, please run
gcloud auth loginto authorize gcloud to access the Cloud Platform with Google user credentials.
Getting Started
Below are the step-by-step guideline to setup a development environment for a Gen AI SDK module:
Go to the module directory by running cd libs/gllm-<module_name>. Optionally, the gllm-<module_name> module folder can also be opened using an IDE (e.g. Cursor).
Configure poetry permission to access Google Cloud repositories. These permissions can expire. If you get authorization errors after a while, please simply rerun these commands.
poetry config http-basic.gen-ai oauth2accesstoken "$(gcloud auth print-access-token)"
poetry config http-basic.gen-ai-internal oauth2accesstoken "$(gcloud auth print-access-token)"
poetry config http-basic.gen-ai-publication oauth2accesstoken "$(gcloud auth print-access-token)"
poetry config http-basic.gen-ai-internal-publication oauth2accesstoken "$(gcloud auth print-access-token)"Install the module dependencies.
poetry install --all-extrasInstall pre-commit hooks. This will make sure our code is compliant with the style guide before committing.
pre-commit install --config ../../.pre-commit-config.yamlTest Files
The test files for each module are located in the gllm-<module_name>/tests directory, which further contains 2 subdirectories:
unit_tests: Contains the unit tests for the module.integration_tests: Contains the integration tests for the module.
Any prerequisites and setup required to run the integration tests must be put in the respective module's README.md file.
To run the tests, please use:
To see the coverage report, please use:
Dependencies Management
Below are the conventions for the Gen AI SDK modules dependencies management:
Arrangements:
Dependencies must be sorted alphabetically by default.
Dependencies may be grouped if necessary.
Dependencies should be arranged as follows:
To modify the dependencies for the module, either:
Manually update the
pyproject.tomlfile, then runpoetry lock --no-cache --regenerateUse poetry commands:
To add package:
poetry add <package_name>.To remove package:
poetry remove <package_name>.To update package:
poetry update <package_name>.
After using poetry commands, please adjust the package ordering accordingly.
After modifying dependencies, please make sure to commit the updated
poetry.lock.Versioning:
For stable packages (major version >= 1), please use
^x.y.z, e.g.pandas = "^2.2.3".For unstable packages (major version = 0), please use
>=0.y.z,<0.y+1.z, e.g.fastapi = ">=0.115.0,<0.116.0".If necessary, package can be locked strictly to a specific version, e.g.
transformers = "4.46.1". However, please be careful as this may cause version conflict between modules.
Code Convention
Below are the code convention for the Gen AI SDK:
For general code convention, please refer to the Python Style Guide.
Modules are located in the
libsdirectory. Each module has its own directory with the following structure:<snake_case_module_name>: contains the source code for the module.tests: contains the tests for the module.pyproject.toml: contains the configuration for the module.poetry.lock: contains the dependencies for the module.README.md: contains the documentation for the module.
For logging, please use our logger manager:
For function logging, define the logger outside of the function:
For class logging, please set the logger as a protected attribute:
For deprecation, please use our deprecated decorator.
To deprecate a function, simply add the decorator:
To deprecate a class, add the decorator to the constructor:
For optional packages, please use our check optional packages util as follows:
To use an optional package in a function, put the checker and import in the function:
To use an optional package in a class, put the checker and import in the class constructor:
Contributing General Flow
The general steps for contributing to the Gen AI SDK are as follows:
Create a new branch from main.
Work on the branch to apply the changes.
Commit the changes. If any dependency are modified, please dont forget to also commit the poetry.lock file.
Push the changes.
Create a PR. The PR description should contain the following:
Description: Brief description on what the PR is about.
Changes: Bulleted list of specific modifications and their purpose.
How to Test: Provide a brief guidelines for the reviewers to verify the changes.
Request for reviews:
At least 2 approval are required in order to merge the PR, 1 on which should be from the Gen AI SDK team. Please communicate with the Gen AI SDK team whenever help is needed for PR reviews.
Merge the PR. Please always use Squash and Merge.
Create a release for the merged changes:
Go to the Draft a new release page.
Click on
Choose a Tag.The tag name should follow the following convention:
Format:
gllm_<package_name>-v<major>.<minor>.<patch>.The version should be updated as follows:
If your changes contain breaking changes, please bump the minor version.
Otherwise, please bump the patch version.
For example, say you've just made changes to the GLLM Core module, and its current latest tag is
gllm_core-v0.2.5(The latest tag should be visible when you start typing the tag name):If your changes contain breaking changes, please create
gllm_core-v0.3.0.Otherwise, please create
gllm_core-v0.2.6.
Click on
Generate release noteand adjust the message accordingly.Click on
Publish releaseto create the release.
Verifying build:
After creating the release, go to the Build binary page.
Find the recent release's build.
Please make sure that all jobs are executed successfully, which means the changes are ready to be used.
If there are any failing builds, please consult to the Gen AI SDK team or the DSO team, as unattended failing builds may result in versioning problem in the future due to missing build.
Creating New Package
Coming soon!
Github Issues
For feature request or bug report, feel free to open a Github issue.
Static Code Analysis
When creating a Pull Request and a commit is pushed to GitHub, it will trigger an SCA job.
To request access to the SCA report, please fill out this ticket form by including the project keys of each modules.
You can check the project key in
./sonar-project.propertiesof each module (example: gllm-core).
Last updated