Skip to content

Commit

Permalink
Fix static check
Browse files Browse the repository at this point in the history
  • Loading branch information
pankajastro committed Jul 29, 2024
1 parent 7d4e6b7 commit a6c8d3f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
13 changes: 6 additions & 7 deletions dev/dags/jaffle_shop_kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,21 @@
https://astronomer.github.io/astronomer-cosmos/getting_started/kubernetes.html#kubernetes
"""

from airflow import DAG
from airflow.providers.cncf.kubernetes.secret import Secret
from pendulum import datetime

from cosmos import (
ProfileConfig,
DbtSeedKubernetesOperator,
ProfileConfig,
)
from cosmos.profiles import PostgresUserPasswordProfileMapping

DBT_IMAGE = "dbt-jaffle-shop:1.0.0"


project_seeds = [
{"project": "jaffle_shop", "seeds": ["raw_customers", "raw_payments", "raw_orders"]}
]
project_seeds = [{"project": "jaffle_shop", "seeds": ["raw_customers", "raw_payments", "raw_orders"]}]

postgres_password_secret = Secret(
deploy_type="env",
Expand Down Expand Up @@ -61,7 +60,7 @@
conn_id="postgres_default",
profile_args={
"schema": "public",
}
)
)
},
),
),
)
1 change: 0 additions & 1 deletion scripts/test/kubernetes-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,3 @@ kubectl get svc --namespace default
echo "pg log"
kubectl logs postgres-postgresql-0 -c postgresql
kubectl describe pod postgres-postgresql-0

12 changes: 6 additions & 6 deletions tests/test_example_dags.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
except ImportError:
from functools import lru_cache as cache


import airflow
import pytest
from airflow.models.dagbag import DagBag
Expand All @@ -26,10 +27,12 @@

MIN_VER_DAG_FILE: dict[str, list[str]] = {
"2.4": ["cosmos_seed_dag.py"],
"2.8": ["cosmos_manifest_example.py"],
}

IGNORED_DAG_FILES = ["performance_dag.py"]


# Sort descending based on Versions and convert string to an actual version
MIN_VER_DAG_FILE_VER: dict[Version, list[str]] = {
Version(version): MIN_VER_DAG_FILE[version] for version in sorted(MIN_VER_DAG_FILE, key=Version, reverse=True)
Expand All @@ -48,7 +51,7 @@ def session():


@cache
def get_dag_bag(in_kube: bool = False) -> DagBag:
def get_dag_bag() -> DagBag:
"""Create a DagBag by adding the files that are not supported to .airflowignore"""
if AIRFLOW_VERSION in PARTIALLY_SUPPORTED_AIRFLOW_VERSIONS:
return DagBag(dag_folder=None, include_examples=False)
Expand All @@ -69,9 +72,6 @@ def get_dag_bag(in_kube: bool = False) -> DagBag:
if DBT_VERSION < Version("1.6.0"):
file.writelines(["example_model_version.py\n"])

if not in_kube:
file.writelines(["jaffle_shop_kubernetes.py\n"])

print(".airflowignore contents: ")
print(AIRFLOW_IGNORE_FILE.read_text())
db = DagBag(EXAMPLE_DAGS_DIR, include_examples=False)
Expand All @@ -80,8 +80,8 @@ def get_dag_bag(in_kube: bool = False) -> DagBag:
return db


def get_dag_ids(in_kube: bool = False) -> list[str]:
dag_bag = get_dag_bag(in_kube)
def get_dag_ids() -> list[str]:
dag_bag = get_dag_bag()
return dag_bag.dag_ids


Expand Down
6 changes: 3 additions & 3 deletions tests/test_example_k8s_dags.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

import pytest
from airflow.models.dagbag import DagBag

from . import utils as test_utils
from airflow.utils.db import create_default_connections
from airflow.utils.session import provide_session

from . import utils as test_utils

EXAMPLE_DAGS_DIR = Path(__file__).parent.parent / "dev/dags"
AIRFLOW_IGNORE_FILE = EXAMPLE_DAGS_DIR / ".airflowignore"

Expand Down Expand Up @@ -39,6 +39,6 @@ def get_all_dag_files():
def test_example_dag_kubernetes(session):
get_all_dag_files()
db = DagBag(EXAMPLE_DAGS_DIR, include_examples=False)
#for dag_id in KUBERNETES_DAG_FILES:
# for dag_id in KUBERNETES_DAG_FILES:
dag = db.get_dag("jaffle_shop_kubernetes")
test_utils.run_dag(dag)

0 comments on commit a6c8d3f

Please sign in to comment.