Skip to content

Commit

Permalink
Remove pydantic-settings as a dependency
Browse files Browse the repository at this point in the history
Use dotenv instead of pydantic-settings for loading
environment variables from .env file

Signed-off-by: Devansh Singh <[email protected]>
  • Loading branch information
Devansh3712 committed Jun 3, 2024
1 parent f0a9d59 commit f121c49
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 64 deletions.
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ install_requires =
gunicorn
httpx
itsdangerous
pydantic-settings
python-dotenv
teuthology @ git+https://github.com/ceph/teuthology#egg=teuthology[test]

Expand Down
43 changes: 0 additions & 43 deletions src/teuthology_api/config.py

This file was deleted.

11 changes: 6 additions & 5 deletions src/teuthology_api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
import os
from fastapi import FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware
from dotenv import load_dotenv
from starlette.middleware.sessions import SessionMiddleware

from teuthology_api.config import settings
from teuthology_api.routes import suite, kill, login, logout

load_dotenv()

DEPLOYMENT = settings.deployment
SESSION_SECRET_KEY = settings.session_secret_key
PULPITO_URL = settings.pulpito_url
PADDLES_URL = settings.paddles_url
DEPLOYMENT = os.getenv("DEPLOYMENT")
SESSION_SECRET_KEY = os.getenv("SESSION_SECRET_KEY")
PULPITO_URL = os.getenv("PULPITO_URL")
PADDLES_URL = os.getenv("PADDLES_URL")

log = logging.getLogger(__name__)
app = FastAPI()
Expand Down
15 changes: 8 additions & 7 deletions src/teuthology_api/routes/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
import os
from fastapi import APIRouter, HTTPException, Request
from fastapi.responses import RedirectResponse
from dotenv import load_dotenv
import httpx
from teuthology_api.config import settings

load_dotenv()

GH_CLIENT_ID = settings.gh_client_id
GH_CLIENT_SECRET = settings.gh_client_secret
GH_AUTHORIZATION_BASE_URL = settings.gh_authorization_base_url
GH_TOKEN_URL = settings.gh_token_url
GH_FETCH_MEMBERSHIP_URL = settings.gh_fetch_membership_url
PULPITO_URL = settings.pulpito_url
GH_CLIENT_ID = os.getenv("GH_CLIENT_ID")
GH_CLIENT_SECRET = os.getenv("GH_CLIENT_SECRET")
GH_AUTHORIZATION_BASE_URL = os.getenv("GH_AUTHORIZATION_BASE_URL")
GH_TOKEN_URL = os.getenv("GH_TOKEN_URL")
GH_FETCH_MEMBERSHIP_URL = os.getenv("GH_FETCH_MEMBERSHIP_URL")
PULPITO_URL = os.getenv("PULPITO_URL")

log = logging.getLogger(__name__)
router = APIRouter(
Expand Down
4 changes: 2 additions & 2 deletions src/teuthology_api/routes/logout.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import logging
import os
from fastapi import APIRouter, HTTPException, Request
from fastapi.responses import RedirectResponse
from teuthology_api.config import settings

PULPITO_URL = settings.pulpito_url
PULPITO_URL = os.getenv("PULPITO_URL")
log = logging.getLogger(__name__)

router = APIRouter(
Expand Down
9 changes: 5 additions & 4 deletions src/teuthology_api/services/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
from pathlib import Path

from fastapi import HTTPException, Request

from teuthology_api.config import settings
from dotenv import load_dotenv

import teuthology
import requests # Note: import requests after teuthology
from requests.exceptions import HTTPError

PADDLES_URL = settings.paddles_url
ARCHIVE_DIR = settings.archive_dir
load_dotenv()

PADDLES_URL = os.getenv("PADDLES_URL")
ARCHIVE_DIR = os.getenv("ARCHIVE_DIR")

log = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions src/teuthology_api/services/kill.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import logging
import os
import subprocess

from fastapi import HTTPException, Request

from teuthology_api.config import settings
from teuthology_api.services.helpers import get_username, get_run_details


TEUTHOLOGY_PATH = settings.teuthology_path
TEUTHOLOGY_PATH = os.getenv("TEUTHOLOGY_PATH")
log = logging.getLogger(__name__)


Expand Down
Empty file modified start_container.sh
100644 → 100755
Empty file.

0 comments on commit f121c49

Please sign in to comment.