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

Name module #126

Merged
merged 13 commits into from
Mar 19, 2024
8 changes: 4 additions & 4 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: 3.11
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -24,10 +24,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: 3.11
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
contents: write
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: 3.11
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11-alpine
FROM python:3.12-alpine

WORKDIR /usr/app

Expand All @@ -16,4 +16,4 @@ WORKDIR /usr/app/src

EXPOSE 8888

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8888"]
CMD ["uvicorn", "regtech_user_fi_management.main:app", "--host", "0.0.0.0", "--port", "8888"]
4 changes: 2 additions & 2 deletions db_revisions/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from logging.config import fileConfig
from sqlalchemy import engine_from_config, pool
from alembic import context
from entities.models import Base
from regtech_user_fi_management.entities.models.dao import Base

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
Expand All @@ -21,7 +21,7 @@

if ENV == "LOCAL":
file_dir = os.path.dirname(os.path.realpath(__file__))
load_dotenv(f"{file_dir}/../src/.env.local")
load_dotenv(f"{file_dir}/../src/regtech_user_fi_management/.env.local")
else:
load_dotenv()

Expand Down
94 changes: 49 additions & 45 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,19 @@
name = "regtech-user-fi-management"
version = "0.1.0"
description = ""
authors = ["lchen-2101 <[email protected]>"]
authors = ["CFPB's RegTech Team"]
readme = "README.md"
packages = [{ include = "regtech-user-fi-management" }]
packages = [{ include = "regtech_user_fi_management", from = "src" }]

[tool.poetry.dependencies]
python = "^3.11"
fastapi = "^0.109.1"
python = ">=3.12,<4"
uvicorn = "^0.22.0"
python-dotenv = "^1.0.0"
python-keycloak = "^3.0.0"
SQLAlchemy = "^2.0.16"
psycopg2-binary = "^2.9.6"
python-jose = "^3.3.0"
requests = "^2.31.0"
asyncpg = "^0.27.0"
asyncpg = "^0.29.0"
alembic = "^1.12.0"
pydantic-settings = "^2.0.3"
regtech-api-commons = {git = "https://github.com/cfpb/regtech-api-commons.git"}

[tool.poetry.group.dev.dependencies]
Expand Down
3 changes: 0 additions & 3 deletions src/entities/engine/__init__.py

This file was deleted.

53 changes: 0 additions & 53 deletions src/entities/models/__init__.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions src/config.py → src/regtech_user_fi_management/config.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import os
from pathlib import Path
from typing import Set
from urllib import parse
from typing import Any, Set

from pydantic import field_validator, ValidationInfo
from pydantic.networks import PostgresDsn
from pydantic import field_validator, PostgresDsn, ValidationInfo
from pydantic_settings import BaseSettings, SettingsConfigDict

from regtech_api_commons.oauth2.config import KeycloakSettings


JWT_OPTS_PREFIX = "jwt_opts_"

env_files_to_load = [".env"]
env_files_to_load: list[Path | str] = [".env"]
if os.getenv("ENV", "LOCAL") == "LOCAL":
env_files_to_load.append(".env.local")

Expand All @@ -23,23 +23,23 @@ class Settings(BaseSettings):
inst_db_pwd: str
inst_db_host: str
inst_db_scheme: str = "postgresql+asyncpg"
inst_conn: PostgresDsn | None = None
inst_conn: str | None = None
admin_scopes: Set[str] = set(["query-groups", "manage-users"])

def __init__(self, **data):
super().__init__(**data)

@field_validator("inst_conn", mode="before")
@classmethod
def build_postgres_dsn(cls, postgres_dsn, info: ValidationInfo) -> Any:
def build_postgres_dsn(cls, field_value, info: ValidationInfo) -> str:
postgres_dsn = PostgresDsn.build(
scheme=info.data.get("inst_db_scheme"),
username=info.data.get("inst_db_user"),
password=parse.quote(info.data.get("inst_db_pwd"), safe=""),
password=parse.quote(str(info.data.get("inst_db_pwd")), safe=""),
host=info.data.get("inst_db_host"),
path=info.data.get("inst_db_name"),
)
return str(postgres_dsn)
return postgres_dsn.unicode_string()

model_config = SettingsConfigDict(env_file=env_files_to_load, extra="allow")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from sqlalchemy.ext.asyncio import AsyncSession
from typing import List, Optional
from itertools import chain
from config import settings
from regtech_user_fi_management.config import settings

from entities.engine import get_session
from entities.repos import institutions_repo as repo
from regtech_user_fi_management.entities.engine.engine import get_session
import regtech_user_fi_management.entities.repos.institutions_repo as repo
from starlette.authentication import AuthCredentials
from regtech_api_commons.models.auth import AuthenticatedUser

Expand Down
File renamed without changes.
Loading
Loading