Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ mypy = "^1.2.0"
pylint = "^2.0.0"
ruff = "^0.4.4"
toml-sort = "^0.23.0"
types-PyYAML = "^6.0.0"
types-requests = "^2.28.11.17"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PyYAML doesn't ship type stubs, so mypy raises [import-untyped] on import yaml. This is the same pattern as types-requests above.


[tool.poetry.group.sphinx-deps.dependencies]
Expand Down
14 changes: 7 additions & 7 deletions src/groundlight/edge/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing_extensions import Self


class GlobalConfig(BaseModel):
class GlobalConfig(BaseModel): # pylint: disable=too-few-public-methods
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pydantic data models intentionally have few methods. Pylint doesn't understand this pattern, so we suppress too-few-public-methods (same as RequestsRetryDecorator in internalapi.py)

"""Global runtime settings for edge-endpoint behavior."""

model_config = ConfigDict(extra="forbid")
Expand All @@ -21,7 +21,7 @@ class GlobalConfig(BaseModel):
)


class InferenceConfig(BaseModel):
class InferenceConfig(BaseModel): # pylint: disable=too-few-public-methods
"""
Configuration for edge inference on a specific detector.
"""
Expand Down Expand Up @@ -71,7 +71,7 @@ def validate_configuration(self) -> Self:
return self


class DetectorConfig(BaseModel):
class DetectorConfig(BaseModel): # pylint: disable=too-few-public-methods
"""
Configuration for a specific detector.
"""
Expand All @@ -93,15 +93,15 @@ class ConfigBase(BaseModel):
@field_validator("edge_inference_configs", mode="before")
@classmethod
def hydrate_inference_config_names(
cls, value: dict[str, InferenceConfig | dict[str, Any]] | None
) -> dict[str, InferenceConfig | dict[str, Any]]:
cls, value: Optional[dict[str, Union[InferenceConfig, dict[str, Any]]]]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This syntax is required for Python 3.9

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a ticket for us to drop 3.9 support in the future

) -> dict[str, Union[InferenceConfig, dict[str, Any]]]:
"""Hydrate InferenceConfig.name from payload mapping keys."""
if value is None:
return {}
if not isinstance(value, dict):
return value

hydrated_configs: dict[str, InferenceConfig | dict[str, Any]] = {}
hydrated_configs: dict[str, Union[InferenceConfig, dict[str, Any]]] = {}
for name, config in value.items():
if isinstance(config, InferenceConfig):
hydrated_configs[name] = config
Expand Down Expand Up @@ -187,7 +187,7 @@ def from_yaml(
if filename is not None:
if not filename.strip():
raise ValueError("filename must be a non-empty path when provided.")
with open(filename, "r") as f:
with open(filename, "r", encoding="utf-8") as f:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linter wants an explicit encoding set

yaml_str = f.read()

yaml_text = yaml_str or ""
Expand Down
Loading