Skip to content

Latest commit

 

History

History
132 lines (89 loc) · 3.68 KB

CONTRIBUTING.md

File metadata and controls

132 lines (89 loc) · 3.68 KB

How to become a contributor and submit your own code

Table of contents

Contributor License Agreements

We'd love to accept your sample apps and patches! Before we can take them, we have to jump a couple of legal hurdles.

Please fill out either the individual or corporate Contributor License Agreement (CLA).

  • If you are an individual writing original source code and you're sure you own the intellectual property, then you'll need to sign an individual CLA.
  • If you work for a company that wants to allow you to contribute your work, then you'll need to sign a corporate CLA.

Follow either of the two links above to access the appropriate CLA and instructions for how to sign and return it. Once we receive it, we'll be able to accept your pull requests.

Contributing a Patch

  1. Submit an issue describing your proposed change to the repo in question.
  2. The repo owner will respond to your issue promptly.
  3. If your proposed change is accepted, and you haven't already done so, sign a Contributor License Agreement (see details above).
  4. Fork the desired repo, develop and test your code changes.
  5. Ensure that your code adheres to the existing style in the code to which you are contributing.
  6. Ensure that your code has an appropriate set of tests which all pass.
  7. Title your pull request following Conventional Commits styling.
  8. Submit a pull request.

Before you begin

  1. [Select or create a Cloud Platform project][projects].
  2. [Enable billing for your project][billing].
  3. [Enable the Generative Language API][enable_api].
  4. [Set up authentication with a service account][auth] so you can access the API from your local workstation.

You can use an API-key, but remember never to save it in your source files.

Development

Local install

Install the source in "editable" mode, with testing requirements:

pip install -e .[dev]

This "editable" mode lets you edit the source without needing to reinstall the package.

Testing

To ensure the integrity of the codebase, we have a suite of tests located in the generative-ai-python/tests directory.

You can run all these tests using Python's built-in unittest module or the pytest library.

For unittest, open a terminal and navigate to the root directory of the project. Then, execute the following command:

python -m unittest discover -s tests

# or more simply
python -m unittest

Alternatively, if you prefer using pytest, you can install it using pip:

pip install pytest

Then, run the tests with the following command:

pytest tests

# or more simply
pytest

Or to debug, use:

pip install nose2

nose2 --debugger

### Type checking 

Use `pytype` (configured in `pyproject.toml`)

pip install pytype touch google/init.py # google/pytype#464 pytype rm google/init.py


### Formatting:

Use black:

pip install black black .


### Generate api reference

python docs/build_docs.py



[setup]: https://cloud.google.com/nodejs/docs/setup
[projects]: https://console.cloud.google.com/project
[billing]: https://support.google.com/cloud/answer/6293499#enable-billing
[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=generativelanguage.googleapis.com
[auth]: https://cloud.google.com/docs/authentication/getting-started