From 8093db0d7ca2166f5814df7fd823573e6d371b9c Mon Sep 17 00:00:00 2001 From: Chenyu Li Date: Tue, 17 Jan 2023 16:18:04 -0800 Subject: [PATCH 1/4] move snapshot task --- core/dbt/cli/main.py | 11 +++++++++-- core/dbt/contracts/results.py | 6 +++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/core/dbt/cli/main.py b/core/dbt/cli/main.py index 2d66733f37e..4ebcc4722cd 100644 --- a/core/dbt/cli/main.py +++ b/core/dbt/cli/main.py @@ -14,6 +14,7 @@ from dbt.task.deps import DepsTask from dbt.task.run import RunTask from dbt.task.test import TestTask +from dbt.task.snapshot import SnapshotTask # CLI invocation @@ -401,10 +402,16 @@ def seed(ctx, **kwargs): @p.threads @p.vars @requires.preflight +@requires.profile +@requires.project def snapshot(ctx, **kwargs): """Execute snapshots defined in your project""" - click.echo(f"`{inspect.stack()[0][3]}` called\n flags: {ctx.obj['flags']}") - return None, True + config = RuntimeConfig.from_parts(ctx.obj["project"], ctx.obj["profile"], ctx.obj["flags"]) + task = SnapshotTask(ctx.obj["flags"], config) + + results = task.run() + success = task.interpret_results(results) + return results, success # dbt source diff --git a/core/dbt/contracts/results.py b/core/dbt/contracts/results.py index 97c43396e33..fee769c1666 100644 --- a/core/dbt/contracts/results.py +++ b/core/dbt/contracts/results.py @@ -207,11 +207,15 @@ class RunExecutionResult( generated_at: datetime = field(default_factory=datetime.utcnow) def write(self, path: str): + # just need shallow copy as we're not modifying content in dict + args = self.args.copy() + args.pop("MP_CONTEXT", None) + args.pop("mp_context", None) writable = RunResultsArtifact.from_execution_results( results=self.results, elapsed_time=self.elapsed_time, generated_at=self.generated_at, - args=self.args, + args=args, ) writable.write(path) From c3517634d3023c0a9dea9c955b72e4d8ddbae0c0 Mon Sep 17 00:00:00 2001 From: Github Build Bot Date: Wed, 18 Jan 2023 00:24:18 +0000 Subject: [PATCH 2/4] Add generated CLI API docs --- .../docs/build/doctrees/environment.pickle | Bin 182098 -> 182098 bytes .../dbt/docs/build/html/_static/alabaster.css | 4 +++- core/dbt/docs/build/html/genindex.html | 2 +- core/dbt/docs/build/html/index.html | 2 +- core/dbt/docs/build/html/search.html | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/dbt/docs/build/doctrees/environment.pickle b/core/dbt/docs/build/doctrees/environment.pickle index 6a2d234ffe5c0e955d6cd8258c3911cb82ac3cc8..9c9eb6d15e3b1372bfe01bb717b2eb7f74c37ba2 100644 GIT binary patch delta 29 lcmccA$9<`fdqa~v+sE@fy%TDiJLKCtQuick search | Powered by Sphinx 6.1.3 - & Alabaster 0.7.12 + & Alabaster 0.7.13 diff --git a/core/dbt/docs/build/html/index.html b/core/dbt/docs/build/html/index.html index 3253006b935..0c4438bc8ea 100644 --- a/core/dbt/docs/build/html/index.html +++ b/core/dbt/docs/build/html/index.html @@ -827,7 +827,7 @@

Quick search

| Powered by Sphinx 6.1.3 - & Alabaster 0.7.12 + & Alabaster 0.7.13 | Related Topics | Powered by Sphinx 6.1.3 - & Alabaster 0.7.12 + & Alabaster 0.7.13 From a73f7c54ea9ab4a3f1a29d665da0c6e6d7b62769 Mon Sep 17 00:00:00 2001 From: Chenyu Li Date: Tue, 17 Jan 2023 16:26:03 -0800 Subject: [PATCH 3/4] add changelog --- .changes/unreleased/Under the Hood-20230117-162505.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Under the Hood-20230117-162505.yaml diff --git a/.changes/unreleased/Under the Hood-20230117-162505.yaml b/.changes/unreleased/Under the Hood-20230117-162505.yaml new file mode 100644 index 00000000000..5980bd2632a --- /dev/null +++ b/.changes/unreleased/Under the Hood-20230117-162505.yaml @@ -0,0 +1,6 @@ +kind: Under the Hood +body: dbt snapshot works in click +time: 2023-01-17T16:25:05.973769-08:00 +custom: + Author: ChenyuLInx + Issue: "5554" From 2597a79457d1592bce7825c21e8b1563dd397279 Mon Sep 17 00:00:00 2001 From: Chenyu Li Date: Wed, 18 Jan 2023 15:56:06 -0800 Subject: [PATCH 4/4] fix args dict in a separate pr --- core/dbt/contracts/results.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/core/dbt/contracts/results.py b/core/dbt/contracts/results.py index fee769c1666..97c43396e33 100644 --- a/core/dbt/contracts/results.py +++ b/core/dbt/contracts/results.py @@ -207,15 +207,11 @@ class RunExecutionResult( generated_at: datetime = field(default_factory=datetime.utcnow) def write(self, path: str): - # just need shallow copy as we're not modifying content in dict - args = self.args.copy() - args.pop("MP_CONTEXT", None) - args.pop("mp_context", None) writable = RunResultsArtifact.from_execution_results( results=self.results, elapsed_time=self.elapsed_time, generated_at=self.generated_at, - args=args, + args=self.args, ) writable.write(path)