Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: common artifact metadata #2778

Merged
merged 3 commits into from
Sep 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## dbt 0.19.0 (Release TBD)

### Breaking changes
- The format for sources.json, run-results.json, manifest.json, and catalog.json has changed to include a common metadata field ([#2761](https://github.com/fishtown-analytics/dbt/issues/2761), [#2778](https://github.com/fishtown-analytics/dbt/pull/2778))

### Features
- dbt will compare configurations using the un-rendered form of the config block in dbt_project.yml ([#2713](https://github.com/fishtown-analytics/dbt/issues/2713), [#2735](https://github.com/fishtown-analytics/dbt/pull/2735))
- Added state and defer arguments to the RPC client, matching the CLI ([#2678](https://github.com/fishtown-analytics/dbt/issues/2678), [#2736](https://github.com/fishtown-analytics/dbt/pull/2736))
Expand Down
29 changes: 13 additions & 16 deletions core/dbt/contracts/graph/manifest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import abc
import enum
from dataclasses import dataclass, field
from datetime import datetime
from itertools import chain, islice
from multiprocessing.synchronize import Lock
from typing import (
Expand All @@ -11,8 +10,6 @@
from typing_extensions import Protocol
from uuid import UUID

from hologram import JsonSchemaMixin

from dbt.contracts.graph.compiled import (
CompileResultNode, ManifestNode, NonSourceCompiledNode, GraphMemberNode
)
Expand All @@ -22,7 +19,7 @@
)
from dbt.contracts.files import SourceFile
from dbt.contracts.util import (
VersionedSchema, Replaceable, MacroKey, SourceKey, SchemaVersion
BaseArtifactMetadata, MacroKey, SourceKey, ArtifactMixin, schema_version
)
from dbt.exceptions import (
raise_duplicate_resource_name, raise_compiler_error, warn_or_error,
Expand Down Expand Up @@ -172,8 +169,11 @@ def _search_packages(


@dataclass
class ManifestMetadata(JsonSchemaMixin, Replaceable):
class ManifestMetadata(BaseArtifactMetadata):
"""Metadata for the manifest."""
dbt_schema_version: str = field(
default_factory=lambda: str(WritableManifest.dbt_schema_version)
)
project_id: Optional[str] = field(
default=None,
metadata={
Expand Down Expand Up @@ -209,6 +209,12 @@ def __post_init__(self):
not tracking.active_user.do_not_track
)

@classmethod
def default(cls):
return cls(
dbt_schema_version=str(WritableManifest.dbt_schema_version),
)


def _sort_values(dct):
"""Given a dictionary, sort each value. This makes output deterministic,
Expand Down Expand Up @@ -430,7 +436,6 @@ class Manifest:
macros: MutableMapping[str, ParsedMacro]
docs: MutableMapping[str, ParsedDocumentation]
reports: MutableMapping[str, ParsedReport]
generated_at: datetime
disabled: List[CompileResultNode]
files: MutableMapping[str, SourceFile]
metadata: ManifestMetadata = field(default_factory=ManifestMetadata)
Expand All @@ -456,7 +461,6 @@ def from_macros(
macros=macros,
docs={},
reports={},
generated_at=datetime.utcnow(),
disabled=[],
files=files,
)
Expand Down Expand Up @@ -726,7 +730,6 @@ def deepcopy(self):
macros={k: _deepcopy(v) for k, v in self.macros.items()},
docs={k: _deepcopy(v) for k, v in self.docs.items()},
reports={k: _deepcopy(v) for k, v in self.reports.items()},
generated_at=self.generated_at,
disabled=[_deepcopy(n) for n in self.disabled],
metadata=self.metadata,
files={k: _deepcopy(v) for k, v in self.files.items()},
Expand All @@ -746,7 +749,6 @@ def writable_manifest(self):
macros=self.macros,
docs=self.docs,
reports=self.reports,
generated_at=self.generated_at,
metadata=self.metadata,
disabled=self.disabled,
child_map=forward_edges,
Expand Down Expand Up @@ -911,7 +913,6 @@ def __reduce_ex__(self, protocol):
self.macros,
self.docs,
self.reports,
self.generated_at,
self.disabled,
self.files,
self.metadata,
Expand All @@ -924,9 +925,8 @@ def __reduce_ex__(self, protocol):


@dataclass
class WritableManifest(VersionedSchema):
dbt_schema_version = SchemaVersion('manifest', 1)

@schema_version('manifest', 1)
class WritableManifest(ArtifactMixin):
nodes: Mapping[UniqueID, ManifestNode] = field(
metadata=dict(description=(
'The nodes defined in the dbt project and its dependencies'
Expand Down Expand Up @@ -955,9 +955,6 @@ class WritableManifest(VersionedSchema):
disabled: Optional[List[CompileResultNode]] = field(metadata=dict(
description='A list of the disabled nodes in the target'
))
generated_at: datetime = field(metadata=dict(
description='The time at which the manifest was generated',
))
parent_map: Optional[NodeEdgeMap] = field(metadata=dict(
description='A mapping from child nodes to their dependencies',
))
Expand Down
Loading