Skip to content

Commit

Permalink
Merge pull request #1 from google-gemini/main
Browse files Browse the repository at this point in the history
develop
  • Loading branch information
meslubi2021 authored Dec 29, 2024
2 parents e0df577 + 5a3ba73 commit ee62753
Show file tree
Hide file tree
Showing 405 changed files with 94,849 additions and 2,739 deletions.
23 changes: 0 additions & 23 deletions .github/ISSUE_TEMPLATE/bug_report.yml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/ISSUE_TEMPLATE/feature_request.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
'status:awaiting review':
- '**/*'

'component:python sdk':
- '**/*'
86 changes: 86 additions & 0 deletions .github/workflows/samples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Validate samples

on:
pull_request:
types: [opened, synchronize] # new, updates

jobs:
update-python-list:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Get Changed Files
id: changed_files
uses: tj-actions/changed-files@v44
with:
files: |
samples/*.py
- name: Check Python samples
env:
NEW_FILES: ${{ steps.changed_files.outputs.all_modified_files }}
README: samples/README.md
run: |
#!/bin/bash
for file in ${NEW_FILES}; do
echo "Testing $file"
name=$(basename $file)
if [[ -f ${file} ]]; then
# File exists, so needs to be listed.
if ! grep -q $name ${README}; then
echo "Error: Sample not listed in README ($name)"
exit 1
fi
else
# File does not exist, ensure it's not listed
if grep -q $name ${README}; then
echo "Error: Sample should not be listed in README ($name)"
exit 1
fi
fi
done
update-rest-list:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Get Changed Files
id: changed_files
uses: tj-actions/changed-files@v44
with:
files: |
samples/rest/*.sh
- name: Check REST samples
env:
NEW_FILES: ${{ steps.changed_files.outputs.all_modified_files }}
README: samples/rest/README.md
run: |
#!/bin/bash
for file in ${NEW_FILES}; do
echo "Testing $file"
if [[ -f ${file} ]]; then
# File exists, so needs to be listed.
echo $(basename $file)
name=$(basename $file)
if ! grep -q $name ${README}; then
echo "Error: Sample not listed in README ($name)"
exit 1
fi
else
# File does not exist, ensure it's not listed
name=$(basename $file)
if grep -q $name ${README}; then
echo "Error: Sample should not be listed in README ($name)"
exit 1
fi
fi
done
4 changes: 2 additions & 2 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-issue-stale: 14
days-before-issue-close: 14
stale-issue-label: "stale"
stale-issue-label: "status:stale"
close-issue-reason: not_planned
any-of-labels: "status:awaiting user response,status:more data needed"
stale-issue-message: >
Expand All @@ -35,7 +35,7 @@ jobs:
Please post a new issue if you need further assistance. Thanks!
days-before-pr-stale: 14
days-before-pr-close: 14
stale-pr-label: "stale"
stale-pr-label: "status:stale"
stale-pr-message: >
Marking this pull request as stale since it has been open for 14 days with no activity.
This PR will be closed if no further activity occurs.
Expand Down
39 changes: 28 additions & 11 deletions .github/workflows/test_pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,26 @@ on:
paths:
- "google/**"
- "tests/**"
- "samples/**"
- "pyproject.toml"
- "setup.py"
# Allow manual runs
workflow_dispatch:

jobs:
test3_12:
name: Test Py3.12
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Run tests
run: |
python --version
pip install .[dev]
python -m unittest
test3_11:
name: Test Py3.11
runs-on: ubuntu-latest
Expand All @@ -23,8 +39,8 @@ jobs:
- name: Run tests
run: |
python --version
pip install -q -e .[dev]
python -m unittest discover --pattern '*test*.py'
pip install .[dev]
python -m unittest
test3_10:
name: Test Py3.10
runs-on: ubuntu-latest
Expand All @@ -36,8 +52,8 @@ jobs:
- name: Run tests
run: |
python --version
pip install -q -e .[dev]
python -m unittest discover --pattern '*test*.py'
pip install -q .[dev]
python -m unittest
test3_9:
name: Test Py3.9
runs-on: ubuntu-latest
Expand All @@ -49,21 +65,22 @@ jobs:
- name: Run tests
run: |
python --version
pip install -q -e .[dev]
python -m unittest discover --pattern '*test*.py'
pytype3_10:
name: pytype 3.10
pip install .[dev]
python -m unittest
pytype3_11:
name: pytype 3.11
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
- name: Run pytype
run: |
python --version
pip install -q -e .[dev]
pip install .[dev]
pip install -q gspread ipython
touch google/__init__.py # https://github.com/google/pytype/issues/464
pytype
format:
name: Check format with black
Expand All @@ -76,7 +93,7 @@ jobs:
- name: Check format
run: |
python --version
pip install -q -e .
pip install -q .
pip install -q black
black . --check
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/.idea/
/.pytype/
/build/
/docs/api
*.egg-info
.DS_Store
__pycache__
*.iml
/dist/
40 changes: 33 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ 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
## Contributing a Patch

1. Submit an issue describing your proposed change to the repo in question.
1. The repo owner will respond to your issue promptly.
Expand All @@ -45,7 +45,7 @@ accept your pull requests.
1. [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 same it in your source files.
You can use an API-key, but remember never to save it in your source files.


## Development
Expand All @@ -62,15 +62,40 @@ This "editable" mode lets you edit the source without needing to reinstall the p

### Testing

Use the builtin unittest package:
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
```
python -m unittest discover --pattern '*test*.py'

Then, run the tests with the following command:

```
pytest tests
# or more simply
pytest
```


Or to debug, use:

```commandline
```
pip install nose2
nose2 --debugger
```

Expand All @@ -80,7 +105,9 @@ Use `pytype` (configured in `pyproject.toml`)

```
pip install pytype
touch google/__init__.py # https://github.com/google/pytype/issues/464
pytype
rm google/__init__.py
```

### Formatting:
Expand All @@ -98,9 +125,8 @@ black .
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
[auth]: https://cloud.google.com/docs/authentication/getting-started
Loading

0 comments on commit ee62753

Please sign in to comment.