Skip to content

Commit

Permalink
Merge pull request #1151 from lsst-sqre/tickets/DM-47646
Browse files Browse the repository at this point in the history
DM-47646: Move or remove model_config settings
  • Loading branch information
rra authored Nov 19, 2024
2 parents 461aa18 + 64b5c45 commit 10e25d5
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 82 deletions.
32 changes: 16 additions & 16 deletions src/gafaelfawr/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,16 +549,16 @@ def _validate_use_kerberos(self) -> Self:
class FirestoreConfig(BaseModel):
"""Configuration for Firestore-based UID/GID assignment."""

model_config = ConfigDict(
alias_generator=to_camel, extra="forbid", populate_by_name=True
)

project: str = Field(
...,
title="Firestore GCP project",
description="Project containing the Firestore collections",
)

model_config = ConfigDict(
alias_generator=to_camel, extra="forbid", populate_by_name=True
)


class OIDCClient(BaseModel):
"""Configuration for a single OpenID Connect client of our server.
Expand All @@ -567,6 +567,8 @@ class OIDCClient(BaseModel):
secret rather than the Helm values file and does not support camel-case.
"""

model_config = ConfigDict(extra="forbid")

id: str = Field(
..., title="Client ID", description="Unique identifier of the client"
)
Expand All @@ -585,8 +587,6 @@ class OIDCClient(BaseModel):
),
)

model_config = ConfigDict(extra="forbid")


class OIDCServerConfig(EnvFirstSettings):
"""Configuration for the OpenID Connect server."""
Expand Down Expand Up @@ -660,6 +660,8 @@ def keypair(self) -> RSAKeyPair:
class NotebookQuota(BaseModel):
"""Quota settings for the Notebook Aspect."""

model_config = ConfigDict(extra="forbid")

cpu: float = Field(
..., title="CPU limit", description="Maximum number of CPU equivalents"
)
Expand All @@ -670,8 +672,6 @@ class NotebookQuota(BaseModel):
description="Maximum memory usage in GiB",
)

model_config = ConfigDict(extra="forbid")


class QuotaGrant(BaseModel):
"""One grant of quotas.
Expand All @@ -680,6 +680,8 @@ class QuotaGrant(BaseModel):
overall quota configuration.
"""

model_config = ConfigDict(extra="forbid")

api: dict[str, int] = Field(
{},
title="Service quotas",
Expand All @@ -694,12 +696,12 @@ class QuotaGrant(BaseModel):
description="Quota settings for the Notebook Aspect",
)

model_config = ConfigDict(extra="forbid")


class QuotaConfig(BaseModel):
"""Quota configuration."""

model_config = ConfigDict(extra="forbid")

default: QuotaGrant = Field(
..., title="Default quota", description="Default quotas for all users"
)
Expand All @@ -710,29 +712,27 @@ class QuotaConfig(BaseModel):
description="Additional quota grants by group name",
)

model_config = ConfigDict(extra="forbid")


class GitHubGroupTeam(BaseModel):
"""Specification for a GitHub team."""

model_config = ConfigDict(extra="forbid")

organization: str = Field(..., title="Name of the organization")

team: str = Field(..., title="Slug of the team")

model_config = ConfigDict(extra="forbid")

def __str__(self) -> str:
return group_name_for_github_team(self.organization, self.team)


class GitHubGroup(BaseModel):
"""An individual GitHub team."""

github: GitHubGroupTeam = Field(..., title="Details of the GitHub team")

model_config = ConfigDict(extra="forbid")

github: GitHubGroupTeam = Field(..., title="Details of the GitHub team")

def __str__(self) -> str:
return str(self.github)

Expand Down
4 changes: 1 addition & 3 deletions src/gafaelfawr/models/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from pydantic import BaseModel, ConfigDict, Field
from pydantic import BaseModel, Field

__all__ = ["Admin"]

Expand All @@ -16,5 +16,3 @@ class Admin(BaseModel):
description="Username of the token administrator",
examples=["adminuser"],
)

model_config = ConfigDict(from_attributes=True)
6 changes: 1 addition & 5 deletions src/gafaelfawr/models/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import Any, Generic, Self, TypeVar
from urllib.parse import parse_qs, urlencode

from pydantic import BaseModel, ConfigDict, Field, field_validator
from pydantic import BaseModel, Field, field_validator
from safir.datetime import current_datetime
from starlette.datastructures import URL

Expand Down Expand Up @@ -76,8 +76,6 @@ class AdminHistoryEntry(BaseModel):
examples=[1614986130],
)

model_config = ConfigDict(from_attributes=True)

_normalize_ip_address = field_validator("ip_address", mode="before")(
normalize_ip_address
)
Expand Down Expand Up @@ -336,8 +334,6 @@ class TokenChangeHistoryEntry(BaseModel):
examples=[1614985631],
)

model_config = ConfigDict(from_attributes=True)

_normalize_scopes = field_validator("scopes", "old_scopes", mode="before")(
normalize_scopes
)
Expand Down
Loading

0 comments on commit 10e25d5

Please sign in to comment.