Skip to content

Commit

Permalink
Unit test bug fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishek Mohan committed Jul 20, 2023
1 parent 13c07c7 commit 02c33d7
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 16 deletions.
4 changes: 2 additions & 2 deletions cosmos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from cosmos.dataset import get_dbt_dataset

# re-export the dag and task group
from cosmos.dag import DbtDag
from cosmos.task_group import DbtTaskGroup
from cosmos.airflow.dag import DbtDag
from cosmos.airflow.task_group import DbtTaskGroup
from cosmos.operators.lazy_load import MissingPackage

# re-export the operators
Expand Down
8 changes: 4 additions & 4 deletions cosmos/dataset.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
from typing import Any
from typing import Any, Tuple


try:
from airflow.datasets import Dataset
except ImportError:
except (ImportError, ModuleNotFoundError):
from logging import getLogger

logger = getLogger(__name__)

class Dataset: # type: ignore[no-redef]
cosmos_override = True

def __init__(self, id: str, *args: tuple[Any], **kwargs: str):
def __init__(self, id: str, *args: Tuple[Any], **kwargs: str):
self.id = id
logger.warning("Datasets are not supported in Airflow < 2.5.0")

def __eq__(self, other: Dataset) -> bool:
def __eq__(self, other: "Dataset") -> bool:
return self.id == other.id # type: ignore[no-any-return]


Expand Down
5 changes: 4 additions & 1 deletion cosmos/dbt/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
import logging
from pathlib import Path

from cosmos.dbt.graph import DbtNode
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from cosmos.dbt.graph import DbtNode

Check warning on line 8 in cosmos/dbt/selector.py

View check run for this annotation

Codecov / codecov/patch

cosmos/dbt/selector.py#L8

Added line #L8 was not covered by tests


SUPPORTED_CONFIG = ["materialized", "schema", "tags"]
Expand Down
2 changes: 1 addition & 1 deletion cosmos/operators/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class DbtRunOperationDockerOperator(DbtDockerBaseOperator):
"""

ui_color = "#8194E0"
template_fields: Sequence[str] = "args"
template_fields: Sequence[str] = ("args",)

def __init__(self, macro_name: str, args: Optional[dict[str, Any]] = None, **kwargs: str) -> None:
self.macro_name = macro_name
Expand Down
2 changes: 1 addition & 1 deletion cosmos/operators/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class DbtRunOperationKubernetesOperator(DbtKubernetesBaseOperator):
"""

ui_color = "#8194E0"
template_fields: Sequence[str] = "args"
template_fields: Sequence[str] = ("args",)

def __init__(self, macro_name: str, args: Optional[dict[str, Any]] = None, **kwargs: str) -> None:
self.macro_name = macro_name
Expand Down
6 changes: 3 additions & 3 deletions cosmos/operators/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import signal
import tempfile
from pathlib import Path
from typing import Any, Callable, Optional, Sequence
from typing import Any, Callable, Optional, Sequence, Tuple

import yaml
from airflow.compat.functools import cached_property
Expand Down Expand Up @@ -126,7 +126,7 @@ def store_compiled_sql(self, tmp_project_dir: str, context: Context, session: Se
).delete()
session.add(rtif)

def run_subprocess(self, *args: tuple[Any], **kwargs: Any) -> FullOutputSubprocessResult:
def run_subprocess(self, *args: Tuple[Any], **kwargs: Any) -> FullOutputSubprocessResult:
return self.subprocess_hook.run_command(*args, **kwargs) # type: ignore[no-any-return]

def get_profile_name(self, project_dir: str) -> str:
Expand Down Expand Up @@ -405,7 +405,7 @@ class DbtRunOperationLocalOperator(DbtLocalBaseOperator):
"""

ui_color = "#8194E0"
template_fields: Sequence[str] = "args"
template_fields: Sequence[str] = ("args",)

def __init__(self, macro_name: str, args: Optional[dict[str, Any]] = None, **kwargs: Any) -> None:
self.macro_name = macro_name
Expand Down
8 changes: 4 additions & 4 deletions cosmos/operators/virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, Tuple


from airflow.compat.functools import cached_property
Expand Down Expand Up @@ -85,9 +85,9 @@ def venv_dbt_path(
self.log.info("Using dbt version %s available at %s", dbt_version, dbt_binary)
return str(dbt_binary)

def run_subprocess(self, *args: tuple[Any], **kwargs: Any) -> FullOutputSubprocessResult:
command = kwargs["command"]

def run_subprocess( # type: ignore[override]
self, *args: Tuple[Any], command: list[str], **kwargs: Any
) -> FullOutputSubprocessResult:
if self.py_requirements:
command[0] = self.venv_dbt_path

Expand Down

0 comments on commit 02c33d7

Please sign in to comment.