Skip to content

Commit

Permalink
Move config.py to root of package (src) (#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigurdp authored Oct 4, 2023
1 parent b32749e commit 78eeaa4
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/webviz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ jobs:
- name: 🤖 Run tests
working-directory: ./backend
env:
WEBVIZ_CLIENT_SECRET: 0
WEBVIZ_SMDA_SUBSCRIPTION_KEY: 0
WEBVIZ_SMDA_RESOURCE_SCOPE: 0
run: |
pytest ./tests/unit
Expand Down
8 changes: 7 additions & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,10 @@ max-branches = 14

[tool.mypy]
ignore_missing_imports = true
disallow_untyped_defs = true
disallow_untyped_defs = true

[tool.pytest.ini_options]
pythonpath = ["."]
filterwarnings = "ignore::DeprecationWarning:pkg_resources"


2 changes: 1 addition & 1 deletion backend/src/backend/auth/auth_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from src.services.utils.authenticated_user import AuthenticatedUser
from src.services.utils.perf_timer import PerfTimer
from src.backend import config
from src import config


class AuthHelper:
Expand Down
6 changes: 2 additions & 4 deletions backend/src/backend/shared_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
from starsessions import SessionMiddleware
from starsessions.stores.redis import RedisStore

from src.backend import config
from src.backend.auth.enforce_logged_in_middleware import (
EnforceLoggedInMiddleware,
)
from src import config
from src.backend.auth.enforce_logged_in_middleware import EnforceLoggedInMiddleware


def add_shared_middlewares(app: FastAPI) -> None:
Expand Down
2 changes: 0 additions & 2 deletions backend/src/backend/config.py → backend/src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
GRAPH_SCOPES = ["User.Read"]

RESOURCE_SCOPES_DICT = {
# "sumo": [f"api://{sumo_app_reg['prod']['RESOURCE_ID']}/access_as_user"],
# Note that when switching back to prod, SUMO env in create_sumo_client_instance() must also be changed
"sumo": [f"api://{sumo_app_reg[SUMO_ENV]['RESOURCE_ID']}/access_as_user"],
"smda": [SMDA_RESOURCE_SCOPE],
}
Expand Down
2 changes: 1 addition & 1 deletion backend/src/services/smda_access/queries/_get_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import requests
from dotenv import load_dotenv

from src.backend import config
from src import config
from src.services.utils.perf_timer import PerfTimer

load_dotenv()
Expand Down
7 changes: 2 additions & 5 deletions backend/src/services/sumo_access/_helpers.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import os

from sumo.wrapper import SumoClient


SUMO_ENV = os.getenv("WEBVIZ_SUMO_ENV", "dev")
from src import config


def create_sumo_client_instance(access_token: str) -> SumoClient:
sumo_client = SumoClient(env=SUMO_ENV, token=access_token, interactive=False)
sumo_client = SumoClient(env=config.SUMO_ENV, token=access_token, interactive=False)
return sumo_client

0 comments on commit 78eeaa4

Please sign in to comment.