Skip to content

Commit

Permalink
Fix #10098 by undoing conditional agate import in one place (#10103)
Browse files Browse the repository at this point in the history
* Add test case

* Undo conditional agate import
  • Loading branch information
jtcohen6 authored May 8, 2024
1 parent 760e4ce commit fe9e39d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
11 changes: 7 additions & 4 deletions core/dbt/artifacts/schemas/run/v5/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
import threading
from dataclasses import dataclass, field
from datetime import datetime
from typing import TYPE_CHECKING, Any, Dict, Iterable, Optional, Sequence, Tuple
from typing import Any, Dict, Iterable, Optional, Sequence, Tuple

# https://github.com/dbt-labs/dbt-core/issues/10098
# Needed for Mashumaro serialization of RunResult below
# TODO: investigate alternative approaches to restore conditional import
# if TYPE_CHECKING:
import agate

from dbt.artifacts.resources import CompiledResource
from dbt.artifacts.schemas.base import (
Expand All @@ -22,9 +28,6 @@
from dbt_common.clients.system import write_json
from dbt_common.constants import SECRET_ENV_PREFIX

if TYPE_CHECKING:
import agate


@dataclass
class RunResult(NodeResult):
Expand Down
16 changes: 16 additions & 0 deletions tests/functional/artifacts/test_run_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ def test_timing_exists(self, project):
assert len(results.results[0].timing) > 0


class TestRunResultsSerializableInContext:
@pytest.fixture(scope="class")
def models(self):
return {"model.sql": good_model_sql}

@pytest.fixture(scope="class")
def project_config_update(self):
return {
"on-run-end": ["{% for result in results %}{{ log(result.to_dict()) }}{% endfor %}"]
}

def test_results_serializable(self, project):
results = run_dbt(["run"])
assert len(results.results) == 1


# This test is failing due to the faulty assumptions that run_results.json would
# be written multiple times. Temporarily disabling.
@pytest.mark.skip()
Expand Down

0 comments on commit fe9e39d

Please sign in to comment.