Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasecchig committed Oct 7, 2024
1 parent 0f634e4 commit cc7aa5e
Show file tree
Hide file tree
Showing 74 changed files with 13,562 additions and 1 deletion.
1 change: 0 additions & 1 deletion gemini/sample-apps/e2e-gen-ai-app-starter-pack
Submodule e2e-gen-ai-app-starter-pack deleted from 5bccf1
194 changes: 194 additions & 0 deletions gemini/sample-apps/e2e-gen-ai-app-starter-pack/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*.pyc
*$py.class
**/dist
/tmp
/out-tsc
/bazel-out

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
Pipfile.lock
Pipfile

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
.venv*
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# macOS
.DS_Store

# PyCharm
.idea

# User-specific files
.terraform*
.Terraform*


tmp*

# Node
**/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# Miscellaneous
**/.angular/*
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings

# System files
.DS_Store
Thumbs.db
*.vscode*

.persist_vector_store
tests/load_test/.results/*.html
tests/load_test/.results/*.csv
locust_env
my_env.tfvars
.streamlit_chats
.saved_chats
47 changes: 47 additions & 0 deletions gemini/sample-apps/e2e-gen-ai-app-starter-pack/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# How to Contribute

We'd love to accept your patches and contributions to this sample. There are
just a few small guidelines you need to follow.

## Contributor License Agreement

Contributions to this project must be accompanied by a Contributor License Agreement. You (or your employer) retain the copyright to your contribution; this simply gives us permission to use and redistribute your contributions as part of the project. Head over to [Google Developers CLA](https://cla.developers.google.com/) to see your current agreements on file or to sign a new one.

You generally only need to submit a CLA once, so if you've already submitted one (even if it was for a different project), you probably don't need to do it again.

## Community Guidelines, Code Reviews, Contributor Guide

Please refer to the [root repository CONTRIBUTING.md file](https://github.com/GoogleCloudPlatform/generative-ai/blob/main/CONTRIBUTING.md) for Community Guidelines, Code Reviews, Contributor Guide, or specific guidance for Google Employees.

## Code Quality Checks

To ensure code quality, we utilize automated checks. Before submitting a pull request, please run the following commands locally:

```bash
poetry install --with streamlit,jupyter,lint
```

This installs development dependencies, including linting tools.

Then, execute the following Makefile targets:

```bash
make lint
```

This command runs the following linters to check for code style, potential errors, and type hints:

- **codespell**: Detects common spelling mistakes in code and documentation.
- **ruff**: A fast linter that combines the functionality of several popular tools like flake8, isort, pycodestyle, and others.
- **mypy**: Performs static type checking to catch type errors before runtime.

```bash
make test
```

This command runs the test suite using pytest, covering both unit and integration tests:

- **`poetry run pytest tests/unit`**: Executes unit tests located in the `tests/unit` directory.
- **`poetry run pytest tests/integration`**: Executes integration tests located in the `tests/integration` directory.

Your pull request will also be automatically checked by these tools using GitHub Actions. Ensuring your code passes these checks locally will help expedite the review process.
17 changes: 17 additions & 0 deletions gemini/sample-apps/e2e-gen-ai-app-starter-pack/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:3.11-slim

RUN pip install --no-cache-dir poetry==1.6.1

RUN poetry config virtualenvs.create false

WORKDIR /code

COPY ./pyproject.toml ./README.md ./poetry.lock* ./

COPY ./app ./app

RUN poetry install --no-interaction --no-ansi --no-dev

EXPOSE 8080

CMD ["uvicorn", "app.server:app", "--host", "0.0.0.0", "--port", "8080"]
20 changes: 20 additions & 0 deletions gemini/sample-apps/e2e-gen-ai-app-starter-pack/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
test:
poetry run pytest tests/unit && poetry run pytest tests/integration

playground:
poetry run uvicorn app.server:app --host 0.0.0.0 --port 8000 --reload & poetry run streamlit run streamlit/streamlit_app.py --browser.serverAddress=localhost --server.enableCORS=false --server.enableXsrfProtection=false

backend:
poetry run uvicorn app.server:app --host 0.0.0.0 --port 8000 --reload

frontend:
poetry run streamlit run streamlit/streamlit_app.py --browser.serverAddress=localhost --server.enableCORS=false --server.enableXsrfProtection=false

load_test:
poetry run locust -f tests/load_test/load_test.py -H $RUN_SERVICE_URL --headless -t 30s -u 60 -r 2 --csv=tests/load_test/.results/results --html=tests/load_test/.results/report.html

lint:
poetry run codespell
poetry run ruff .
poetry run mypy .
poetry run black .
Loading

0 comments on commit cc7aa5e

Please sign in to comment.