Skip to content

Commit

Permalink
[Coding Conventions] Enforce sending self as first arg of instance me…
Browse files Browse the repository at this point in the history
…thods (#5653)
  • Loading branch information
Yacouby committed May 30, 2024
1 parent c55cfde commit b799702
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions mlrun/common/schemas/model_monitoring/model_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def from_flat_dict(cls, endpoint_dict: dict, json_parse_values: list = None):
)

@validator("monitor_configuration")
@classmethod
def set_name(cls, monitor_configuration):
return monitor_configuration or {
EventFieldType.DRIFT_DETECTED_THRESHOLD: (
Expand All @@ -115,6 +116,7 @@ def set_name(cls, monitor_configuration):
}

@validator("model_uri")
@classmethod
def validate_model_uri(cls, model_uri):
"""Validate that the model uri includes the required prefix"""
prefix, uri = mlrun.datastore.parse_store_uri(model_uri)
Expand Down
2 changes: 2 additions & 0 deletions mlrun/datastore/datastore_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Config:
extra = pydantic.Extra.forbid

@pydantic.validator("name")
@classmethod
def lower_case(cls, v):
return v.lower()

Expand Down Expand Up @@ -304,6 +305,7 @@ def check_bucket(cls, v):
return v

@pydantic.validator("gcp_credentials", pre=True, always=True)
@classmethod
def convert_dict_to_json(cls, v):
if isinstance(v, dict):
return json.dumps(v)
Expand Down
4 changes: 2 additions & 2 deletions mlrun/model_monitoring/db/stores/sqldb/models/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class _ApplicationResultOrMetric:
)

@declared_attr
def endpoint_id(cls):
def endpoint_id(self):
return Column(
String(40),
ForeignKey(f"{EventFieldType.MODEL_ENDPOINTS}.{EventFieldType.UID}"),
Expand All @@ -81,7 +81,7 @@ class ApplicationMetricsTable(

class MonitoringSchedulesTable(Base, MonitoringSchedulesBaseTable):
@declared_attr
def endpoint_id(cls):
def endpoint_id(self):
return Column(
String(40),
ForeignKey(f"{EventFieldType.MODEL_ENDPOINTS}.{EventFieldType.UID}"),
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ extend-select = [
"I", # isort
"UP", # pyupgrade
"CPY", # flake8-copyright
"N805", # first argument of instance method should be 'self'
"N806", # lowercase variable names
"N816", # snake_case for global variable names
"N999", # snake_case for module names
Expand Down
1 change: 1 addition & 0 deletions tests/model_monitoring/test_stores/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class TestSQLStore:
def store_connection(tmp_path: Path) -> str:
return f"sqlite:///{tmp_path / 'test.db'}"

@classmethod
@pytest.fixture()
def _mock_random_endpoint(
cls,
Expand Down

0 comments on commit b799702

Please sign in to comment.