Skip to content

Commit

Permalink
chore: apply ruff format
Browse files Browse the repository at this point in the history
  • Loading branch information
timonviola committed Jan 17, 2025
1 parent 4db6a1d commit 82b2db3
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/dagcellent/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Common Airflow dags and plugins for DFDS."""

# SPDX-FileCopyrightText: 2024-present Timon Viola <viotimo@dfds.com>
#
# SPDX-License-Identifier: MIT
Expand Down
1 change: 1 addition & 0 deletions src/dagcellent/_connection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Airflow connection utilities."""

from __future__ import annotations

from enum import Enum
Expand Down
1 change: 1 addition & 0 deletions src/dagcellent/dag/_meta.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""DAG metadata related utilities."""

from __future__ import annotations

import os
Expand Down
1 change: 1 addition & 0 deletions src/dagcellent/data_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities related to handling various data sources e.g.: databases, cloud blob storage."""

from __future__ import annotations

# pyright: reportUnknownVariableType=false
Expand Down
1 change: 1 addition & 0 deletions src/dagcellent/data_utils/sql_reflection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""SqlAlchemy based utility functions to interact with databases."""

from __future__ import annotations

import logging
Expand Down
1 change: 1 addition & 0 deletions src/dagcellent/operators/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Reusable operators to build Airflow DAGs."""

from __future__ import annotations

from dagcellent.operators.external_table_arrow import CreateExternalTableArrow
Expand Down
2 changes: 1 addition & 1 deletion src/dagcellent/operators/mlflow/_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Mlflow helpers."""

# ruff: noqa: G004
# typing: ignore
from __future__ import annotations
Expand All @@ -7,7 +8,6 @@
from typing import TYPE_CHECKING, TypedDict

if TYPE_CHECKING:

import mlflow.entities.model_registry


Expand Down
19 changes: 8 additions & 11 deletions src/dagcellent/operators/mlflow/operators.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from __future__ import annotations

import logging
Expand Down Expand Up @@ -52,7 +51,7 @@ def __init__(
self.version = version
self.tag = tag

super().__init__(**kwargs) # type: ignore [reportUnknownMemberType]
super().__init__(**kwargs) # type: ignore [reportUnknownMemberType]

def execute(self, context: Any) -> None:
"""Operator execute method.
Expand Down Expand Up @@ -95,8 +94,7 @@ def __init__(
self.stage = stage
self.model_name = model_name

super().__init__(**kwargs) # type: ignore [reportUnknownMemberType]

super().__init__(**kwargs) # type: ignore [reportUnknownMemberType]

def execute(self, context: Any) -> list[SlimModelVersion]:
"""Connect to Mlflow hook and dump messages to tmp file."""
Expand Down Expand Up @@ -131,7 +129,7 @@ def __init__(
self.tracking_uri = tracking_uri
self.upstream_task_id = upstream_task_id

super().__init__(**kwargs)# type: ignore [reportUnknownMemberType]
super().__init__(**kwargs) # type: ignore [reportUnknownMemberType]

def execute(self, context: Any) -> Any:
"""Operator execute method.
Expand All @@ -147,13 +145,13 @@ def execute(self, context: Any) -> Any:
key="return_value", task_ids=self.upstream_task_id
)
if isinstance(xcom_val, list):
_first_item = xcom_val.pop() # type: ignore [unknownTypeIssue]
run_id = _first_item["run_id"]# type: ignore [unknownTypeIssue]
_first_item = xcom_val.pop() # type: ignore [unknownTypeIssue]
run_id = _first_item["run_id"] # type: ignore [unknownTypeIssue]
logging.warning(
"Multiple items returned from upstream task. Defaulting to first item"
)
elif isinstance(xcom_val, dict):
run_id = xcom_val["run_id"]# type: ignore [unknownTypeIssue]
run_id = xcom_val["run_id"] # type: ignore [unknownTypeIssue]
else:
logging.error(
"Operator has no implementation for this type: %s", f"{type(xcom_val)}."
Expand All @@ -164,8 +162,7 @@ def execute(self, context: Any) -> Any:
raise ValueError(f"{run_id} must be an instance of 'str'")
data = client_hook.get_run(run_id)
logging.info("%s", f"{data=}")
return data.data.metrics # type: ignore [unknownTypeIssue]

return data.data.metrics # type: ignore [unknownTypeIssue]


class GetLatestModelVersion(BaseOperator):
Expand All @@ -192,7 +189,7 @@ def __init__(
self.tracking_uri = tracking_uri
self.model_name = model_name

super().__init__(**kwargs)# type: ignore [reportUnknownMemberType]
super().__init__(**kwargs) # type: ignore [reportUnknownMemberType]

def execute(self, context: Any) -> SlimModelVersion:
"""Operator execute method.
Expand Down
1 change: 0 additions & 1 deletion tests/dags/test_msql_reflect_otherdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
schedule="@once",
catchup=False,
) as dag:

reflect_table = SQLReflectOperator(
task_id="reflect_database", conn_id=CONN_ID, table_name="kaka", database="model"
)
Expand Down
1 change: 1 addition & 0 deletions tests/dags/test_mssql_reflect.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Test DAG to show the usage of SQL reflection
and executing the returned query.
"""

from __future__ import annotations

import datetime
Expand Down
1 change: 1 addition & 0 deletions tests/dags/test_psql_reflect.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test SQL reflection on PostrgeSQL."""

from __future__ import annotations

import datetime
Expand Down
1 change: 1 addition & 0 deletions tests/dags/test_psql_s3.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test SQL reflection on PostrgeSQL."""

from __future__ import annotations

import datetime
Expand Down
1 change: 1 addition & 0 deletions tests/test_mlflow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for the operators.mlflow module."""

from __future__ import annotations


Expand Down

0 comments on commit 82b2db3

Please sign in to comment.