From 43e7e2bc83d3a9764695e7211337a19f1cf1d3f8 Mon Sep 17 00:00:00 2001 From: Jeremy Cohen Date: Thu, 9 Feb 2023 12:38:29 +0100 Subject: [PATCH] Return manifest, include project_name in metadata --- core/dbt/cli/main.py | 8 ++++---- core/dbt/config/runtime.py | 6 +++++- core/dbt/contracts/graph/manifest.py | 8 +++++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/core/dbt/cli/main.py b/core/dbt/cli/main.py index ea8849c7a82..5d3ff87f2b4 100644 --- a/core/dbt/cli/main.py +++ b/core/dbt/cli/main.py @@ -1,5 +1,5 @@ from copy import copy -from typing import List, Tuple, Optional +from typing import List, Tuple, Optional, Union import click from dbt.cli import requires, params as p @@ -40,7 +40,7 @@ def __init__( self.profile = profile self.manifest = manifest - def invoke(self, args: List[str]) -> Tuple[Optional[List], bool]: + def invoke(self, args: List[str]) -> Tuple[Union[Manifest, Optional[List]], bool]: try: dbt_ctx = cli.make_context(cli.name, args) dbt_ctx.obj = { @@ -387,10 +387,10 @@ def list(ctx, **kwargs): @requires.project @requires.runtime_config @requires.manifest(write_perf_info=True) -def parse(ctx, **kwargs): +def parse(ctx, **kwargs) -> Tuple[Manifest, bool]: """Parses the project and provides information on performance""" # manifest generation and writing happens in @requires.manifest - return None, True + return ctx.obj["manifest"], True # dbt run diff --git a/core/dbt/config/runtime.py b/core/dbt/config/runtime.py index d58a9009922..2f95ab6d664 100644 --- a/core/dbt/config/runtime.py +++ b/core/dbt/config/runtime.py @@ -271,7 +271,11 @@ def from_args(cls, args: Any) -> "RuntimeConfig": ) def get_metadata(self) -> ManifestMetadata: - return ManifestMetadata(project_id=self.hashed_name(), adapter_type=self.credentials.type) + return ManifestMetadata( + project_name=self.project_name, + project_id=self.hashed_name(), + adapter_type=self.credentials.type, + ) def _get_v2_config_paths( self, diff --git a/core/dbt/contracts/graph/manifest.py b/core/dbt/contracts/graph/manifest.py index 881a2b34435..65b9ca3b1e4 100644 --- a/core/dbt/contracts/graph/manifest.py +++ b/core/dbt/contracts/graph/manifest.py @@ -272,10 +272,16 @@ class ManifestMetadata(BaseArtifactMetadata): dbt_schema_version: str = field( default_factory=lambda: str(WritableManifest.dbt_schema_version) ) + project_name: Optional[str] = field( + default=None, + metadata={ + "description": "Name of the root project", + }, + ) project_id: Optional[str] = field( default=None, metadata={ - "description": "A unique identifier for the project", + "description": "A unique identifier for the project, hashed from the project name", }, ) user_id: Optional[UUID] = field(