Skip to content

Commit

Permalink
Release 2023.08.1 (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
thekaveman authored Aug 16, 2023
2 parents 9d52639 + 68df688 commit 89a9bfc
Show file tree
Hide file tree
Showing 15 changed files with 93 additions and 97 deletions.
16 changes: 9 additions & 7 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
FROM eligibility_server:latest

# install python tooling
COPY .devcontainer/requirements.txt .devcontainer/requirements.txt
RUN pip install --no-cache-dir -r .devcontainer/requirements.txt
# install devcontainer requirements
RUN pip install -e .[dev,test]

# install docs tooling
# docs requirements are in a separate file for the GitHub Action
COPY docs/requirements.txt docs/requirements.txt
RUN pip install --no-cache-dir -r docs/requirements.txt

# install test tooling
COPY tests/requirements.txt tests/requirements.txt
RUN pip install -r tests/requirements.txt
# install pre-commit environments in throwaway Git repository
# https://stackoverflow.com/a/68758943
COPY .pre-commit-config.yaml .
RUN git init . && \
pre-commit install-hooks && \
rm -rf .git
41 changes: 22 additions & 19 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,27 @@
"postStartCommand": ["/bin/bash", "bin/init.sh"],
"postAttachCommand": ["/bin/bash", ".devcontainer/postAttach.sh"],

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash"
}
"customizations": {
// Set *default* container specific settings.json values on container create.
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash"
}
}
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"bpruitt-goddard.mermaid-markdown-syntax-highlighting",
"eamodio.gitlens",
"esbenp.prettier-vscode",
"hashicorp.terraform",
"mhutchie.git-graph",
"ms-python.python",
"ms-python.vscode-pylance"
]
}
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"bpruitt-goddard.mermaid-markdown-syntax-highlighting",
"eamodio.gitlens",
"esbenp.prettier-vscode",
"hashicorp.terraform",
"mhutchie.git-graph",
"ms-python.python",
"ms-python.vscode-pylance"
]
}
}
3 changes: 0 additions & 3 deletions .devcontainer/requirements.txt

This file was deleted.

2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/" # requirements.txt
directory: "/" # pyproject.toml
schedule:
interval: "daily"
commit-message:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ jobs:
- name: Install package and dependencies
run: |
python -m pip install --upgrade pip
pip install -r tests/requirements.txt
pip install -r requirements.txt
pip install -e .[test]
- name: Load environment variables
uses: cardinalby/export-env-action@v2
Expand Down
8 changes: 5 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@
"[python]": {
"editor.defaultFormatter": "ms-python.python"
},
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.formatting.provider": "black",
"python.languageServer": "Pylance",
"python.linting.flake8Enabled": true,
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.testing.pytestArgs": ["tests"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"[terraform]": {
"editor.defaultFormatter": "hashicorp.terraform"
},
"[terraform-vars]": {
"editor.defaultFormatter": "hashicorp.terraform"
},
"workbench.editorAssociations": {
"*.db": "sqlite-viewer.option"
}
}
10 changes: 4 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ FROM ghcr.io/cal-itp/docker-python-web:main

ENV FLASK_APP=eligibility_server/app.py

# install python app dependencies
COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# upgrade pip
RUN python -m pip install --upgrade pip

# copy source files
COPY bin/ bin/
COPY bin bin
COPY eligibility_server/ eligibility_server/
COPY *.py .
COPY README.md .
COPY pyproject.toml pyproject.toml

# install source as a package
RUN pip install -e .
Expand Down
1 change: 1 addition & 0 deletions data/server.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sub,name,type
71162,Box,courtesy_card
32587,Gonzales,courtesy_card
03552,McCulley,courtesy_card
Expand Down
3 changes: 3 additions & 0 deletions eligibility_server/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__version__ = "2023.08.1"

VERSION = __version__
11 changes: 6 additions & 5 deletions eligibility_server/db/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,18 @@ def import_csv_users(csv_path, remote):
# open in read mode explicitly since the file may still be open if we downloaded from remote
# newline="" is important here, see https://docs.python.org/3/library/csv.html#id3
with open(csv_path, mode="r", encoding="utf-8", newline="") as file:
data = csv.reader(
data = csv.DictReader(
file,
delimiter=config.csv_delimiter,
quoting=config.csv_quoting,
quotechar=config.csv_quotechar,
)
# unpack each record in data to the 3 columns
for sub, name, types in data:

for row in data:
# type lists are expected to be a comma-separated value and quoted if the CSV delimiter is a comma
types = [type.replace(config.csv_quotechar, "") for type in types.split(",") if type]
save_user(sub, name, types)
types = row["type"]
types = [types.replace(config.csv_quotechar, "") for type in types.split(",") if type]
save_user(row["sub"], row["name"], types)

# close and remove the temp file if needed
if temp_csv:
Expand Down
45 changes: 40 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,46 @@
# Configuration for Black.
[build-system]
requires = ["setuptools>=64", "wheel"]
build-backend = "setuptools.build_meta"

# NOTE: you have to use single-quoted strings in TOML for regular expressions.
# It's the equivalent of r-strings in Python. Multiline strings are treated as
# verbose regular expressions by Black. Use [ ] to denote a significant space
# character.
[project]
classifiers = ["Programming Language :: Python :: 3 :: Only"]
description = "Server implementation of the Eligibility Verification API"
dependencies = [
"eligibility-api==2023.6.1",
"Flask==2.3.2",
"Flask-RESTful==0.3.10",
"Flask-SQLAlchemy==3.0.5",
"requests==2.31.0"
]
dynamic = ["version"]
keywords = ["flask"]
license = { file = "LICENSE" }
name = "eligibility-server"
readme = "README.md"
requires-python = ">=3.9"

[project.optional-dependencies]
dev = [
"black",
"flake8",
"pre-commit",
]
test = [
"coverage",
"pytest",
"pytest-mock",
]

[project.urls]
Code = "https://github.com/cal-itp/eligibility-server"
Documentation = "https://docs.calitp.org/eligibility-server"
Issues = "https://github.com/cal-itp/eligibility-server/issues"

# Configuration for black
[tool.black]
line-length = 127
target-version = ['py310']
include = '\.pyi?$'

[tool.setuptools]
packages = ["eligibility_server"]
5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.

37 changes: 0 additions & 37 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion terraform/uptime.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module "healthcheck" {
application_insights = azurerm_application_insights.main
# not strictly necessary to include the environment name, but helps to make the alerts more clear
name = "mst-courtesy-cards-eligibility-server-${local.env_name}-healthcheck"
url = "https://${azurerm_linux_web_app.main.default_hostname}/healthcheck"
url = "https://${azurerm_cdn_frontdoor_endpoint.main.host_name}/healthcheck"
}

# ignore when app restarts as data is being reloaded
Expand Down
3 changes: 0 additions & 3 deletions tests/requirements.txt

This file was deleted.

0 comments on commit 89a9bfc

Please sign in to comment.