Skip to content

Commit

Permalink
Generate cookiecutter my_bank_app in build_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rjambrecic committed Nov 29, 2024
1 parent 107a0e6 commit e112df2
Show file tree
Hide file tree
Showing 42 changed files with 1,167 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ node_modules/
/playwright-report/
/blob-report/
/playwright/.cache/
my_bank_app/
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
my_bank_app
├── docker
│   ├── content
│   │   ├── nginx.conf.template
│   │   └── run_fastagency.sh
│   └── Dockerfile
├── my_bank_app
│   ├── deployment
│   │   ├── __init__.py
│   │   └── main.py
│   ├── local
│   │   ├── __init__.py
│   │   ├── main_console.py
│   │   └── main_mesop.py
│   ├── __init__.py
│   └── workflow.py
├── scripts
│   ├── build_docker.sh
│   ├── check-registered-app-pre-commit.sh
│   ├── check-registered-app.sh
│   ├── deploy_to_fly_io.sh
│   ├── lint-pre-commit.sh
│   ├── lint.sh
│   ├── register_to_fly_io.sh
│   ├── run_docker.sh
│   ├── run_mesop_locally.sh
│   ├── static-analysis.sh
│   └── static-pre-commit.sh
├── tests
│   ├── __init__.py
│   ├── conftest.py
│   └── test_workflow.py
├── README.md
├── fly.toml
└── pyproject.toml
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CONTAINER_PREFIX=${USER}

# LLM keys
# Set atleast one of the following keys
OPENAI_API_KEY=${OPENAI_API_KEY}
TOGETHER_API_KEY=${TOGETHER_API_KEY}
ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"name": "python-3.12",
"dockerComposeFile": [
"./docker-compose.yml"
],
"service": "python-3.12-my_bank_app",

"secrets": {
"OPENAI_API_KEY": {
"description": "This key is optional and only needed if you are working on OpenAI-related code. Leave it blank if not required. You can always set it later as an environment variable in the codespace terminal."
},
"TOGETHER_API_KEY": {
"description": "This key is optional and only needed if you are working with Together API-related code. Leave it blank if not required. You can always set it later as an environment variable in the codespace terminal."
},
"ANTHROPIC_API_KEY": {
"description": "This key is optional and only needed if you are working with Anthropic API-related code. Leave it blank if not required. You can always set it later as an environment variable in the codespace terminal."
}
},
"shutdownAction": "stopCompose",
"workspaceFolder": "/workspaces/my_bank_app",
// "runArgs": [],
"remoteEnv": {},
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": true,
"installOhMyZsh": true,
"configureZshAsDefaultShell": true,
"username": "vscode",
"userUid": "1000",
"userGid": "1000"
// "upgradePackages": "true"
},
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/git-lfs:1": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
"updateContentCommand": "bash .devcontainer/setup.sh",
"postCreateCommand": [],
"customizations": {
"vscode": {
"settings": {
"python.linting.enabled": true,
"python.testing.pytestEnabled": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "always"
},
"[python]": {
"editor.defaultFormatter": "ms-python.vscode-pylance"
},
"editor.rulers": [
80
]
},
"extensions": [
"ms-python.python",
"ms-toolsai.jupyter",
"ms-toolsai.vscode-jupyter-cell-tags",
"ms-toolsai.jupyter-keymap",
"ms-toolsai.jupyter-renderers",
"ms-toolsai.vscode-jupyter-slideshow",
"ms-python.vscode-pylance"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3'

services:
# nosemgrep: yaml.docker-compose.security.writable-filesystem-service.writable-filesystem-service
python-3.12-my_bank_app:
image: mcr.microsoft.com/devcontainers/python:3.12
container_name: my_bank_app-${USER}-python-3.12
volumes:
- ../:/workspaces/my_bank_app:cached
command: sleep infinity

env_file:
- ./devcontainer.env
security_opt:
- no-new-privileges:true
networks:
- my_bank_app-network

networks:
my_bank_app-network:
name: my_bank_app-${USER}-network
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# update pip
pip install --upgrade pip

# install dev packages
pip install -e ".[dev]"

# install pre-commit hooks
pre-commit install

# install fly.io CLI and set fly.io CLI PATH in bashrc and zshrc
curl -L https://fly.io/install.sh | sh
echo 'export FLYCTL_INSTALL="/home/vscode/.fly"' | tee -a ~/.bashrc ~/.zshrc
echo 'export PATH="$FLYCTL_INSTALL/bin:$PATH"' | tee -a ~/.bashrc ~/.zshrc

# check OPENAI_API_KEY environment variable is set
if [ -z "$OPENAI_API_KEY" ]; then
echo
echo -e "\033[33mWarning: OPENAI_API_KEY environment variable is not set.\033[0m"
echo
fi
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
# GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
# Python
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

name: Fly Deploy

on:
push:
branches:
- main
workflow_dispatch:

env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master

- name: Check if the app name is registered in fly.io and deploy
run: ./scripts/deploy_to_fly_io.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

name: Test

on:
push:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
strategy:
matrix:
python-version: ["3.12"]
fail-fast: false
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: pyproject.toml
- uses: actions/cache@v4
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test-v03
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pip install .[testing]
- name: Check for OPENAI_API_KEY
run: |
if [ -z "${{ secrets.OPENAI_API_KEY }}" ]; then
echo "Error: OPENAI_API_KEY is not set in GitHub secrets."
echo "Please set the OPENAI_API_KEY secret in your repository settings."
echo "Follow the instructions here:"
echo "https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository"
exit 1
fi
- name: Run tests
run: pytest
env:
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
__pycache__
dist
.idea
venv*
.venv*
.env
.env*
*.lock
.vscode
.pypirc
.pytest_cache
.ruff_cache
.mypy_cache
.coverage*
.cache
htmlcov
token
.DS_Store
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

- repo: local
hooks:
- id: lint
name: Linter
entry: "scripts/lint-pre-commit.sh"
language: python
# language_version: python3.12
types: [python]
require_serial: true
verbose: true

- repo: local
hooks:
- id: static-analysis
name: Static analysis
entry: "scripts/static-pre-commit.sh"
language: python
# language_version: python3.12
types: [python]
require_serial: true
verbose: true

- repo: https://github.com/Yelp/detect-secrets
rev: v1.5.0
hooks:
- id: detect-secrets
args: ["--baseline", ".secrets.baseline"]

- repo: local
hooks:
- id: check-registered-app
name: Check if the app name is registered in fly.io
entry: "scripts/check-registered-app-pre-commit.sh"
language: python
require_serial: true
verbose: true
Loading

0 comments on commit e112df2

Please sign in to comment.