Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update templates #5

Merged
merged 4 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless echos!? I was going to talk a bunch of trash but then realized I didn't actually write these...

;;
esac
}
Loading