Skip to content

Commit ee62753

Browse files
authored
Merge pull request #1 from google-gemini/main
develop
2 parents e0df577 + 5a3ba73 commit ee62753

File tree

405 files changed

+94849
-2739
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

405 files changed

+94849
-2739
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/feature_request.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/labeler.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
'status:awaiting review':
22
- '**/*'
3+
4+
'component:python sdk':
5+
- '**/*'

.github/workflows/samples.yaml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Validate samples
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize] # new, updates
6+
7+
jobs:
8+
update-python-list:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout Code
13+
uses: actions/checkout@v3
14+
15+
- name: Get Changed Files
16+
id: changed_files
17+
uses: tj-actions/changed-files@v44
18+
with:
19+
files: |
20+
samples/*.py
21+
22+
- name: Check Python samples
23+
env:
24+
NEW_FILES: ${{ steps.changed_files.outputs.all_modified_files }}
25+
README: samples/README.md
26+
run: |
27+
#!/bin/bash
28+
29+
for file in ${NEW_FILES}; do
30+
echo "Testing $file"
31+
name=$(basename $file)
32+
if [[ -f ${file} ]]; then
33+
# File exists, so needs to be listed.
34+
if ! grep -q $name ${README}; then
35+
echo "Error: Sample not listed in README ($name)"
36+
exit 1
37+
fi
38+
else
39+
# File does not exist, ensure it's not listed
40+
if grep -q $name ${README}; then
41+
echo "Error: Sample should not be listed in README ($name)"
42+
exit 1
43+
fi
44+
fi
45+
done
46+
47+
update-rest-list:
48+
runs-on: ubuntu-latest
49+
50+
steps:
51+
- name: Checkout Code
52+
uses: actions/checkout@v3
53+
54+
- name: Get Changed Files
55+
id: changed_files
56+
uses: tj-actions/changed-files@v44
57+
with:
58+
files: |
59+
samples/rest/*.sh
60+
61+
- name: Check REST samples
62+
env:
63+
NEW_FILES: ${{ steps.changed_files.outputs.all_modified_files }}
64+
README: samples/rest/README.md
65+
run: |
66+
#!/bin/bash
67+
68+
for file in ${NEW_FILES}; do
69+
echo "Testing $file"
70+
if [[ -f ${file} ]]; then
71+
# File exists, so needs to be listed.
72+
echo $(basename $file)
73+
name=$(basename $file)
74+
if ! grep -q $name ${README}; then
75+
echo "Error: Sample not listed in README ($name)"
76+
exit 1
77+
fi
78+
else
79+
# File does not exist, ensure it's not listed
80+
name=$(basename $file)
81+
if grep -q $name ${README}; then
82+
echo "Error: Sample should not be listed in README ($name)"
83+
exit 1
84+
fi
85+
fi
86+
done

.github/workflows/stale.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
repo-token: ${{ secrets.GITHUB_TOKEN }}
2525
days-before-issue-stale: 14
2626
days-before-issue-close: 14
27-
stale-issue-label: "stale"
27+
stale-issue-label: "status:stale"
2828
close-issue-reason: not_planned
2929
any-of-labels: "status:awaiting user response,status:more data needed"
3030
stale-issue-message: >
@@ -35,7 +35,7 @@ jobs:
3535
Please post a new issue if you need further assistance. Thanks!
3636
days-before-pr-stale: 14
3737
days-before-pr-close: 14
38-
stale-pr-label: "stale"
38+
stale-pr-label: "status:stale"
3939
stale-pr-message: >
4040
Marking this pull request as stale since it has been open for 14 days with no activity.
4141
This PR will be closed if no further activity occurs.

.github/workflows/test_pr.yaml

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,26 @@ on:
88
paths:
99
- "google/**"
1010
- "tests/**"
11+
- "samples/**"
12+
- "pyproject.toml"
13+
- "setup.py"
1114
# Allow manual runs
1215
workflow_dispatch:
1316

1417
jobs:
18+
test3_12:
19+
name: Test Py3.12
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v3
23+
- uses: actions/setup-python@v4
24+
with:
25+
python-version: '3.12'
26+
- name: Run tests
27+
run: |
28+
python --version
29+
pip install .[dev]
30+
python -m unittest
1531
test3_11:
1632
name: Test Py3.11
1733
runs-on: ubuntu-latest
@@ -23,8 +39,8 @@ jobs:
2339
- name: Run tests
2440
run: |
2541
python --version
26-
pip install -q -e .[dev]
27-
python -m unittest discover --pattern '*test*.py'
42+
pip install .[dev]
43+
python -m unittest
2844
test3_10:
2945
name: Test Py3.10
3046
runs-on: ubuntu-latest
@@ -36,8 +52,8 @@ jobs:
3652
- name: Run tests
3753
run: |
3854
python --version
39-
pip install -q -e .[dev]
40-
python -m unittest discover --pattern '*test*.py'
55+
pip install -q .[dev]
56+
python -m unittest
4157
test3_9:
4258
name: Test Py3.9
4359
runs-on: ubuntu-latest
@@ -49,21 +65,22 @@ jobs:
4965
- name: Run tests
5066
run: |
5167
python --version
52-
pip install -q -e .[dev]
53-
python -m unittest discover --pattern '*test*.py'
54-
pytype3_10:
55-
name: pytype 3.10
68+
pip install .[dev]
69+
python -m unittest
70+
pytype3_11:
71+
name: pytype 3.11
5672
runs-on: ubuntu-latest
5773
steps:
5874
- uses: actions/checkout@v3
5975
- uses: actions/setup-python@v4
6076
with:
61-
python-version: '3.10'
77+
python-version: '3.11'
6278
- name: Run pytype
6379
run: |
6480
python --version
65-
pip install -q -e .[dev]
81+
pip install .[dev]
6682
pip install -q gspread ipython
83+
touch google/__init__.py # https://github.com/google/pytype/issues/464
6784
pytype
6885
format:
6986
name: Check format with black
@@ -76,7 +93,7 @@ jobs:
7693
- name: Check format
7794
run: |
7895
python --version
79-
pip install -q -e .
96+
pip install -q .
8097
pip install -q black
8198
black . --check
8299

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
/.idea/
44
/.pytype/
55
/build/
6-
/docs/api
76
*.egg-info
87
.DS_Store
98
__pycache__
109
*.iml
10+
/dist/

CONTRIBUTING.md

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Follow either of the two links above to access the appropriate CLA and
2424
instructions for how to sign and return it. Once we receive it, we'll be able to
2525
accept your pull requests.
2626

27-
## Contributing A Patch
27+
## Contributing a Patch
2828

2929
1. Submit an issue describing your proposed change to the repo in question.
3030
1. The repo owner will respond to your issue promptly.
@@ -45,7 +45,7 @@ accept your pull requests.
4545
1. [Set up authentication with a service account][auth] so you can access the
4646
API from your local workstation.
4747

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

5050

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

6363
### Testing
6464

65-
Use the builtin unittest package:
65+
To ensure the integrity of the codebase, we have a suite of tests located in the `generative-ai-python/tests` directory.
6666

67+
You can run all these tests using Python's built-in `unittest` module or the `pytest` library.
68+
69+
For `unittest`, open a terminal and navigate to the root directory of the project. Then, execute the following command:
70+
71+
```
72+
python -m unittest discover -s tests
73+
74+
# or more simply
75+
python -m unittest
76+
```
77+
78+
Alternatively, if you prefer using `pytest`, you can install it using pip:
79+
80+
```
81+
pip install pytest
6782
```
68-
python -m unittest discover --pattern '*test*.py'
83+
84+
Then, run the tests with the following command:
85+
86+
```
87+
pytest tests
88+
89+
# or more simply
90+
pytest
6991
```
7092

93+
7194
Or to debug, use:
7295

73-
```commandline
96+
```
97+
pip install nose2
98+
7499
nose2 --debugger
75100
```
76101

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

81106
```
82107
pip install pytype
108+
touch google/__init__.py # https://github.com/google/pytype/issues/464
83109
pytype
110+
rm google/__init__.py
84111
```
85112

86113
### Formatting:
@@ -98,9 +125,8 @@ black .
98125
python docs/build_docs.py
99126
```
100127

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

0 commit comments

Comments
 (0)