Skip to content

Commit

Permalink
Update templates (#5)
Browse files Browse the repository at this point in the history
* ignore envrc file used by direnv

* add Makefile with install command

* cleanup globals a la netid_arrest

* python 3.8 EOL, use Flask 3
  • Loading branch information
counik authored Oct 16, 2024
1 parent b57dc43 commit 11f699b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ ipython_config.py
# pyenv
.python-version

# direnv
.envrc

# 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
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.ONESHELL:

.PHONY: install
install: ## Install the project in dev mode.
@./venv/bin/pip install -U pip
@./venv/bin/pip install --no-input 'urllib3<2' keyring keyrings.google-artifactregistry-auth
@if ! poetry --version >/dev/null; then pip install poetry ; fi
@poetry install --with=dev
2 changes: 2 additions & 0 deletions example_app/app.template.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import importlib.metadata as importlib_metadata # Python ^3.9 change

from flask import Flask, jsonify

Expand All @@ -13,6 +14,7 @@ def index():

APP_VERSION = None


@app.route("/status")
def status():
global APP_VERSION
Expand Down
4 changes: 2 additions & 2 deletions pyproject.template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ description = ""
authors = []

[tool.poetry.dependencies]
python = "^3.8"
Flask = "^2.0.2"
python = "^3.9"
Flask = "^3.0"

[tool.poetry.dev-dependencies]
pytest = "^6.2.5"
Expand Down
13 changes: 7 additions & 6 deletions scripts/globals.template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ export APP_NAME="${template:app_name}"

function get_instance_status {
local stage="$1"
local url="https://${APP_NAME}.iam${stage}.s.uw.edu/status"
curl -sk $url
# substitute '_' for '-' in APP_NAME
local url="https://${APP_NAME//_/-}.iam${stage}.s.uw.edu/status"
curl -sk "$url" || >&2 echo "Failed to check $url"
}

function get_poetry_version {
cat pyproject.toml | grep 'version =' | cut -f2 -d\" | head -n1
grep 'version =' pyproject.toml | cut -f2 -d\" | head -n1
}


Expand All @@ -20,13 +21,13 @@ function get_promotion_version {
local target=$1
case $target in
dev)
echo $(get_poetry_version)
get_poetry_version
;;
eval)
echo $(get_instance_status dev | jq -r .version)
get_instance_status dev | jq -r .version
;;
prod)
echo $(get_instance_status eval | jq -r .version)
get_instance_status eval | jq -r .version
;;
esac
}

0 comments on commit 11f699b

Please sign in to comment.