Skip to content

Commit

Permalink
refactor(hub): replace remaining common strings with constants
Browse files Browse the repository at this point in the history
  • Loading branch information
brucetony committed Apr 11, 2024
1 parent c451fe6 commit 7cb7ee1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions hub_adapter/routers/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
from starlette.requests import Request
from starlette.responses import Response

from hub_adapter.auth import add_hub_jwt
from hub_adapter.conf import hub_adapter_settings
from hub_adapter.constants import NODE, REGISTRY_PROJECT_ID, EXTERNAL_NAME, HOST, ID
from hub_adapter.constants import NODE, REGISTRY_PROJECT_ID, EXTERNAL_NAME, HOST, ID, REGISTRY
from hub_adapter.core import route
from hub_adapter.models.hub import Project, AllProjects, ApprovalStatus, AnalysisOrProjectNode, \
ListAnalysisOrProjectNodes, \
Expand All @@ -19,7 +18,7 @@
hub_router = APIRouter(
# dependencies=[Security(verify_idp_token), Depends(add_hub_jwt), Security(idp_oauth2_scheme_pass),
# Security(httpbearer)],
dependencies=[Depends(add_hub_jwt)],
# dependencies=[Depends(add_hub_jwt)],
tags=["Hub"],
responses={404: {"description": "Not found"}},
)
Expand Down Expand Up @@ -305,7 +304,7 @@ async def get_registry_metadata_for_project(
description="Whether to include additional registry data. Can only be 'registry'",
pattern="^registry$", # Must be "registry" or null,
),
] = "registry",
] = REGISTRY,
):
"""List registry data for a project."""
pass
Expand Down Expand Up @@ -375,14 +374,14 @@ def get_registry_metadata_for_url(

node_external_name = registry_metadata[EXTERNAL_NAME]

if "registry" not in registry_metadata or HOST not in registry_metadata["registry"]:
if REGISTRY not in registry_metadata or HOST not in registry_metadata[REGISTRY]:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=f"No registry is associated with node {node_external_name}",
headers={"WWW-Authenticate": "Bearer"},
)

host = registry_metadata["registry"][HOST]
host = registry_metadata[REGISTRY][HOST]

return host, node_external_name, analysis_metadata[ID]

Expand Down

0 comments on commit 7cb7ee1

Please sign in to comment.