dvt-core 1.11.0b4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dvt-core might be problematic. Click here for more details.
- dvt/__init__.py +7 -0
- dvt/_pydantic_shim.py +26 -0
- dvt/adapters/__init__.py +16 -0
- dvt/adapters/multi_adapter_manager.py +268 -0
- dvt/artifacts/__init__.py +0 -0
- dvt/artifacts/exceptions/__init__.py +1 -0
- dvt/artifacts/exceptions/schemas.py +31 -0
- dvt/artifacts/resources/__init__.py +116 -0
- dvt/artifacts/resources/base.py +68 -0
- dvt/artifacts/resources/types.py +93 -0
- dvt/artifacts/resources/v1/analysis.py +10 -0
- dvt/artifacts/resources/v1/catalog.py +23 -0
- dvt/artifacts/resources/v1/components.py +275 -0
- dvt/artifacts/resources/v1/config.py +282 -0
- dvt/artifacts/resources/v1/documentation.py +11 -0
- dvt/artifacts/resources/v1/exposure.py +52 -0
- dvt/artifacts/resources/v1/function.py +53 -0
- dvt/artifacts/resources/v1/generic_test.py +32 -0
- dvt/artifacts/resources/v1/group.py +22 -0
- dvt/artifacts/resources/v1/hook.py +11 -0
- dvt/artifacts/resources/v1/macro.py +30 -0
- dvt/artifacts/resources/v1/metric.py +173 -0
- dvt/artifacts/resources/v1/model.py +146 -0
- dvt/artifacts/resources/v1/owner.py +10 -0
- dvt/artifacts/resources/v1/saved_query.py +112 -0
- dvt/artifacts/resources/v1/seed.py +42 -0
- dvt/artifacts/resources/v1/semantic_layer_components.py +72 -0
- dvt/artifacts/resources/v1/semantic_model.py +315 -0
- dvt/artifacts/resources/v1/singular_test.py +14 -0
- dvt/artifacts/resources/v1/snapshot.py +92 -0
- dvt/artifacts/resources/v1/source_definition.py +85 -0
- dvt/artifacts/resources/v1/sql_operation.py +10 -0
- dvt/artifacts/resources/v1/unit_test_definition.py +78 -0
- dvt/artifacts/schemas/__init__.py +0 -0
- dvt/artifacts/schemas/base.py +191 -0
- dvt/artifacts/schemas/batch_results.py +24 -0
- dvt/artifacts/schemas/catalog/__init__.py +12 -0
- dvt/artifacts/schemas/catalog/v1/__init__.py +0 -0
- dvt/artifacts/schemas/catalog/v1/catalog.py +60 -0
- dvt/artifacts/schemas/freshness/__init__.py +1 -0
- dvt/artifacts/schemas/freshness/v3/__init__.py +0 -0
- dvt/artifacts/schemas/freshness/v3/freshness.py +159 -0
- dvt/artifacts/schemas/manifest/__init__.py +2 -0
- dvt/artifacts/schemas/manifest/v12/__init__.py +0 -0
- dvt/artifacts/schemas/manifest/v12/manifest.py +212 -0
- dvt/artifacts/schemas/results.py +148 -0
- dvt/artifacts/schemas/run/__init__.py +2 -0
- dvt/artifacts/schemas/run/v5/__init__.py +0 -0
- dvt/artifacts/schemas/run/v5/run.py +184 -0
- dvt/artifacts/schemas/upgrades/__init__.py +4 -0
- dvt/artifacts/schemas/upgrades/upgrade_manifest.py +174 -0
- dvt/artifacts/schemas/upgrades/upgrade_manifest_dbt_version.py +2 -0
- dvt/artifacts/utils/validation.py +153 -0
- dvt/cli/__init__.py +1 -0
- dvt/cli/context.py +16 -0
- dvt/cli/exceptions.py +56 -0
- dvt/cli/flags.py +558 -0
- dvt/cli/main.py +971 -0
- dvt/cli/option_types.py +121 -0
- dvt/cli/options.py +79 -0
- dvt/cli/params.py +803 -0
- dvt/cli/requires.py +478 -0
- dvt/cli/resolvers.py +32 -0
- dvt/cli/types.py +40 -0
- dvt/clients/__init__.py +0 -0
- dvt/clients/checked_load.py +82 -0
- dvt/clients/git.py +164 -0
- dvt/clients/jinja.py +206 -0
- dvt/clients/jinja_static.py +245 -0
- dvt/clients/registry.py +192 -0
- dvt/clients/yaml_helper.py +68 -0
- dvt/compilation.py +833 -0
- dvt/compute/__init__.py +26 -0
- dvt/compute/base.py +288 -0
- dvt/compute/engines/__init__.py +13 -0
- dvt/compute/engines/duckdb_engine.py +368 -0
- dvt/compute/engines/spark_engine.py +273 -0
- dvt/compute/query_analyzer.py +212 -0
- dvt/compute/router.py +483 -0
- dvt/config/__init__.py +4 -0
- dvt/config/catalogs.py +95 -0
- dvt/config/compute_config.py +406 -0
- dvt/config/profile.py +411 -0
- dvt/config/profiles_v2.py +464 -0
- dvt/config/project.py +893 -0
- dvt/config/renderer.py +232 -0
- dvt/config/runtime.py +491 -0
- dvt/config/selectors.py +209 -0
- dvt/config/utils.py +78 -0
- dvt/connectors/.gitignore +6 -0
- dvt/connectors/README.md +306 -0
- dvt/connectors/catalog.yml +217 -0
- dvt/connectors/download_connectors.py +300 -0
- dvt/constants.py +29 -0
- dvt/context/__init__.py +0 -0
- dvt/context/base.py +746 -0
- dvt/context/configured.py +136 -0
- dvt/context/context_config.py +350 -0
- dvt/context/docs.py +82 -0
- dvt/context/exceptions_jinja.py +179 -0
- dvt/context/macro_resolver.py +195 -0
- dvt/context/macros.py +171 -0
- dvt/context/manifest.py +73 -0
- dvt/context/providers.py +2198 -0
- dvt/context/query_header.py +14 -0
- dvt/context/secret.py +59 -0
- dvt/context/target.py +74 -0
- dvt/contracts/__init__.py +0 -0
- dvt/contracts/files.py +413 -0
- dvt/contracts/graph/__init__.py +0 -0
- dvt/contracts/graph/manifest.py +1904 -0
- dvt/contracts/graph/metrics.py +98 -0
- dvt/contracts/graph/model_config.py +71 -0
- dvt/contracts/graph/node_args.py +42 -0
- dvt/contracts/graph/nodes.py +1806 -0
- dvt/contracts/graph/semantic_manifest.py +233 -0
- dvt/contracts/graph/unparsed.py +812 -0
- dvt/contracts/project.py +417 -0
- dvt/contracts/results.py +53 -0
- dvt/contracts/selection.py +23 -0
- dvt/contracts/sql.py +86 -0
- dvt/contracts/state.py +69 -0
- dvt/contracts/util.py +46 -0
- dvt/deprecations.py +347 -0
- dvt/deps/__init__.py +0 -0
- dvt/deps/base.py +153 -0
- dvt/deps/git.py +196 -0
- dvt/deps/local.py +80 -0
- dvt/deps/registry.py +131 -0
- dvt/deps/resolver.py +149 -0
- dvt/deps/tarball.py +121 -0
- dvt/docs/source/_ext/dbt_click.py +118 -0
- dvt/docs/source/conf.py +32 -0
- dvt/env_vars.py +64 -0
- dvt/event_time/event_time.py +40 -0
- dvt/event_time/sample_window.py +60 -0
- dvt/events/__init__.py +16 -0
- dvt/events/base_types.py +37 -0
- dvt/events/core_types_pb2.py +2 -0
- dvt/events/logging.py +109 -0
- dvt/events/types.py +2534 -0
- dvt/exceptions.py +1487 -0
- dvt/flags.py +89 -0
- dvt/graph/__init__.py +11 -0
- dvt/graph/cli.py +248 -0
- dvt/graph/graph.py +172 -0
- dvt/graph/queue.py +213 -0
- dvt/graph/selector.py +375 -0
- dvt/graph/selector_methods.py +976 -0
- dvt/graph/selector_spec.py +223 -0
- dvt/graph/thread_pool.py +18 -0
- dvt/hooks.py +21 -0
- dvt/include/README.md +49 -0
- dvt/include/__init__.py +3 -0
- dvt/include/global_project.py +4 -0
- dvt/include/starter_project/.gitignore +4 -0
- dvt/include/starter_project/README.md +15 -0
- dvt/include/starter_project/__init__.py +3 -0
- dvt/include/starter_project/analyses/.gitkeep +0 -0
- dvt/include/starter_project/dvt_project.yml +36 -0
- dvt/include/starter_project/macros/.gitkeep +0 -0
- dvt/include/starter_project/models/example/my_first_dbt_model.sql +27 -0
- dvt/include/starter_project/models/example/my_second_dbt_model.sql +6 -0
- dvt/include/starter_project/models/example/schema.yml +21 -0
- dvt/include/starter_project/seeds/.gitkeep +0 -0
- dvt/include/starter_project/snapshots/.gitkeep +0 -0
- dvt/include/starter_project/tests/.gitkeep +0 -0
- dvt/internal_deprecations.py +27 -0
- dvt/jsonschemas/__init__.py +3 -0
- dvt/jsonschemas/jsonschemas.py +309 -0
- dvt/jsonschemas/project/0.0.110.json +4717 -0
- dvt/jsonschemas/project/0.0.85.json +2015 -0
- dvt/jsonschemas/resources/0.0.110.json +2636 -0
- dvt/jsonschemas/resources/0.0.85.json +2536 -0
- dvt/jsonschemas/resources/latest.json +6773 -0
- dvt/links.py +4 -0
- dvt/materializations/__init__.py +0 -0
- dvt/materializations/incremental/__init__.py +0 -0
- dvt/materializations/incremental/microbatch.py +235 -0
- dvt/mp_context.py +8 -0
- dvt/node_types.py +37 -0
- dvt/parser/__init__.py +23 -0
- dvt/parser/analysis.py +21 -0
- dvt/parser/base.py +549 -0
- dvt/parser/common.py +267 -0
- dvt/parser/docs.py +52 -0
- dvt/parser/fixtures.py +51 -0
- dvt/parser/functions.py +30 -0
- dvt/parser/generic_test.py +100 -0
- dvt/parser/generic_test_builders.py +334 -0
- dvt/parser/hooks.py +119 -0
- dvt/parser/macros.py +137 -0
- dvt/parser/manifest.py +2204 -0
- dvt/parser/models.py +574 -0
- dvt/parser/partial.py +1179 -0
- dvt/parser/read_files.py +445 -0
- dvt/parser/schema_generic_tests.py +423 -0
- dvt/parser/schema_renderer.py +111 -0
- dvt/parser/schema_yaml_readers.py +936 -0
- dvt/parser/schemas.py +1467 -0
- dvt/parser/search.py +149 -0
- dvt/parser/seeds.py +28 -0
- dvt/parser/singular_test.py +20 -0
- dvt/parser/snapshots.py +44 -0
- dvt/parser/sources.py +557 -0
- dvt/parser/sql.py +63 -0
- dvt/parser/unit_tests.py +622 -0
- dvt/plugins/__init__.py +20 -0
- dvt/plugins/contracts.py +10 -0
- dvt/plugins/exceptions.py +2 -0
- dvt/plugins/manager.py +164 -0
- dvt/plugins/manifest.py +21 -0
- dvt/profiler.py +20 -0
- dvt/py.typed +1 -0
- dvt/runners/__init__.py +2 -0
- dvt/runners/exposure_runner.py +7 -0
- dvt/runners/no_op_runner.py +46 -0
- dvt/runners/saved_query_runner.py +7 -0
- dvt/selected_resources.py +8 -0
- dvt/task/__init__.py +0 -0
- dvt/task/base.py +504 -0
- dvt/task/build.py +197 -0
- dvt/task/clean.py +57 -0
- dvt/task/clone.py +162 -0
- dvt/task/compile.py +151 -0
- dvt/task/compute.py +366 -0
- dvt/task/debug.py +650 -0
- dvt/task/deps.py +280 -0
- dvt/task/docs/__init__.py +3 -0
- dvt/task/docs/generate.py +408 -0
- dvt/task/docs/index.html +250 -0
- dvt/task/docs/serve.py +28 -0
- dvt/task/freshness.py +323 -0
- dvt/task/function.py +122 -0
- dvt/task/group_lookup.py +46 -0
- dvt/task/init.py +374 -0
- dvt/task/list.py +237 -0
- dvt/task/printer.py +176 -0
- dvt/task/profiles.py +256 -0
- dvt/task/retry.py +175 -0
- dvt/task/run.py +1146 -0
- dvt/task/run_operation.py +142 -0
- dvt/task/runnable.py +802 -0
- dvt/task/seed.py +104 -0
- dvt/task/show.py +150 -0
- dvt/task/snapshot.py +57 -0
- dvt/task/sql.py +111 -0
- dvt/task/test.py +464 -0
- dvt/tests/fixtures/__init__.py +1 -0
- dvt/tests/fixtures/project.py +620 -0
- dvt/tests/util.py +651 -0
- dvt/tracking.py +529 -0
- dvt/utils/__init__.py +3 -0
- dvt/utils/artifact_upload.py +151 -0
- dvt/utils/utils.py +408 -0
- dvt/version.py +249 -0
- dvt_core-1.11.0b4.dist-info/METADATA +252 -0
- dvt_core-1.11.0b4.dist-info/RECORD +261 -0
- dvt_core-1.11.0b4.dist-info/WHEEL +5 -0
- dvt_core-1.11.0b4.dist-info/entry_points.txt +2 -0
- dvt_core-1.11.0b4.dist-info/top_level.txt +1 -0
dvt/parser/search.py
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from typing import (
|
|
4
|
+
Callable,
|
|
5
|
+
Generic,
|
|
6
|
+
Iterable,
|
|
7
|
+
Iterator,
|
|
8
|
+
List,
|
|
9
|
+
Optional,
|
|
10
|
+
Set,
|
|
11
|
+
TypeVar,
|
|
12
|
+
Union,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
from dvt import deprecations
|
|
16
|
+
from dvt.config import Project
|
|
17
|
+
from dvt.contracts.files import AnySourceFile, FilePath
|
|
18
|
+
from dvt.exceptions import DbtInternalError, ParsingError
|
|
19
|
+
from pathspec import PathSpec # type: ignore
|
|
20
|
+
|
|
21
|
+
from dbt_common.clients._jinja_blocks import ExtractWarning
|
|
22
|
+
from dbt_common.clients.jinja import BlockTag, extract_toplevel_blocks
|
|
23
|
+
from dbt_common.clients.system import find_matching
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# What's the point of wrapping a SourceFile with this class?
|
|
27
|
+
# Could it be removed?
|
|
28
|
+
@dataclass
|
|
29
|
+
class FileBlock:
|
|
30
|
+
file: AnySourceFile
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def name(self):
|
|
34
|
+
base = os.path.basename(self.file.path.relative_path)
|
|
35
|
+
name, _ = os.path.splitext(base)
|
|
36
|
+
return name
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def contents(self):
|
|
40
|
+
return self.file.contents
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def path(self):
|
|
44
|
+
return self.file.path
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# The BlockTag is used in Jinja processing
|
|
48
|
+
# Why do we have different classes where the only
|
|
49
|
+
# difference is what 'contents' returns?
|
|
50
|
+
@dataclass
|
|
51
|
+
class BlockContents(FileBlock):
|
|
52
|
+
file: AnySourceFile # if you remove this, mypy will get upset
|
|
53
|
+
block: BlockTag
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def name(self):
|
|
57
|
+
return self.block.block_name
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
def contents(self):
|
|
61
|
+
return self.block.contents
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@dataclass
|
|
65
|
+
class FullBlock(FileBlock):
|
|
66
|
+
file: AnySourceFile # if you remove this, mypy will get upset
|
|
67
|
+
block: BlockTag
|
|
68
|
+
|
|
69
|
+
@property
|
|
70
|
+
def name(self):
|
|
71
|
+
return self.block.block_name
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
def contents(self):
|
|
75
|
+
return self.block.full_block
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def filesystem_search(
|
|
79
|
+
project: Project,
|
|
80
|
+
relative_dirs: List[str],
|
|
81
|
+
extension: str,
|
|
82
|
+
ignore_spec: Optional[PathSpec] = None,
|
|
83
|
+
):
|
|
84
|
+
ext = "[!.#~]*" + extension
|
|
85
|
+
root = project.project_root
|
|
86
|
+
file_path_list = []
|
|
87
|
+
for result in find_matching(root, relative_dirs, ext, ignore_spec):
|
|
88
|
+
if "searched_path" not in result or "relative_path" not in result:
|
|
89
|
+
raise DbtInternalError("Invalid result from find_matching: {}".format(result))
|
|
90
|
+
file_match = FilePath(
|
|
91
|
+
searched_path=result["searched_path"],
|
|
92
|
+
relative_path=result["relative_path"],
|
|
93
|
+
modification_time=result["modification_time"],
|
|
94
|
+
project_root=root,
|
|
95
|
+
)
|
|
96
|
+
file_path_list.append(file_match)
|
|
97
|
+
|
|
98
|
+
return file_path_list
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
Block = Union[BlockContents, FullBlock]
|
|
102
|
+
|
|
103
|
+
BlockSearchResult = TypeVar("BlockSearchResult", BlockContents, FullBlock)
|
|
104
|
+
|
|
105
|
+
BlockSearchResultFactory = Callable[[AnySourceFile, BlockTag], BlockSearchResult]
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
class BlockSearcher(Generic[BlockSearchResult], Iterable[BlockSearchResult]):
|
|
109
|
+
def __init__(
|
|
110
|
+
self,
|
|
111
|
+
source: List[FileBlock],
|
|
112
|
+
allowed_blocks: Set[str],
|
|
113
|
+
source_tag_factory: BlockSearchResultFactory,
|
|
114
|
+
check_jinja: bool = True,
|
|
115
|
+
) -> None:
|
|
116
|
+
self.source = source
|
|
117
|
+
self.allowed_blocks = allowed_blocks
|
|
118
|
+
self.source_tag_factory: BlockSearchResultFactory = source_tag_factory
|
|
119
|
+
self.check_jinja = check_jinja
|
|
120
|
+
|
|
121
|
+
def extract_blocks(self, source_file: FileBlock) -> Iterable[BlockTag]:
|
|
122
|
+
# This is a bit of a hack to get the file path to the deprecation
|
|
123
|
+
def wrap_handle_extract_warning(warning: ExtractWarning) -> None:
|
|
124
|
+
self._handle_extract_warning(warning=warning, file=source_file.path.relative_path)
|
|
125
|
+
|
|
126
|
+
try:
|
|
127
|
+
blocks = extract_toplevel_blocks(
|
|
128
|
+
source_file.contents,
|
|
129
|
+
allowed_blocks=self.allowed_blocks,
|
|
130
|
+
collect_raw_data=False,
|
|
131
|
+
warning_callback=wrap_handle_extract_warning if self.check_jinja else None,
|
|
132
|
+
)
|
|
133
|
+
# this makes mypy happy, and this is an invariant we really need
|
|
134
|
+
for block in blocks:
|
|
135
|
+
assert isinstance(block, BlockTag)
|
|
136
|
+
yield block
|
|
137
|
+
|
|
138
|
+
except ParsingError as exc:
|
|
139
|
+
if exc.node is None:
|
|
140
|
+
exc.add_node(source_file)
|
|
141
|
+
raise
|
|
142
|
+
|
|
143
|
+
def _handle_extract_warning(self, warning: ExtractWarning, file: str) -> None:
|
|
144
|
+
deprecations.warn("unexpected-jinja-block-deprecation", msg=warning.msg, file=file)
|
|
145
|
+
|
|
146
|
+
def __iter__(self) -> Iterator[BlockSearchResult]:
|
|
147
|
+
for entry in self.source:
|
|
148
|
+
for block in self.extract_blocks(entry):
|
|
149
|
+
yield self.source_tag_factory(entry.file, block)
|
dvt/parser/seeds.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from dvt.context.context_config import ContextConfig
|
|
2
|
+
from dvt.contracts.graph.nodes import SeedNode
|
|
3
|
+
from dvt.node_types import NodeType
|
|
4
|
+
from dvt.parser.base import SimpleSQLParser
|
|
5
|
+
from dvt.parser.search import FileBlock
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class SeedParser(SimpleSQLParser[SeedNode]):
|
|
9
|
+
def parse_from_dict(self, dct, validate=True) -> SeedNode:
|
|
10
|
+
# seeds need the root_path because the contents are not loaded
|
|
11
|
+
dct["root_path"] = self.project.project_root
|
|
12
|
+
if "language" in dct:
|
|
13
|
+
del dct["language"]
|
|
14
|
+
# raw_code is not currently used, but it might be in the future
|
|
15
|
+
if validate:
|
|
16
|
+
SeedNode.validate(dct)
|
|
17
|
+
return SeedNode.from_dict(dct)
|
|
18
|
+
|
|
19
|
+
@property
|
|
20
|
+
def resource_type(self) -> NodeType:
|
|
21
|
+
return NodeType.Seed
|
|
22
|
+
|
|
23
|
+
@classmethod
|
|
24
|
+
def get_compiled_path(cls, block: FileBlock):
|
|
25
|
+
return block.path.relative_path
|
|
26
|
+
|
|
27
|
+
def render_with_context(self, parsed_node: SeedNode, config: ContextConfig) -> None:
|
|
28
|
+
"""Seeds don't need to do any rendering."""
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from dvt.contracts.graph.nodes import SingularTestNode
|
|
2
|
+
from dvt.node_types import NodeType
|
|
3
|
+
from dvt.parser.base import SimpleSQLParser
|
|
4
|
+
from dvt.parser.search import FileBlock
|
|
5
|
+
from dvt.utils import get_pseudo_test_path
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class SingularTestParser(SimpleSQLParser[SingularTestNode]):
|
|
9
|
+
def parse_from_dict(self, dct, validate=True) -> SingularTestNode:
|
|
10
|
+
if validate:
|
|
11
|
+
SingularTestNode.validate(dct)
|
|
12
|
+
return SingularTestNode.from_dict(dct)
|
|
13
|
+
|
|
14
|
+
@property
|
|
15
|
+
def resource_type(self) -> NodeType:
|
|
16
|
+
return NodeType.Test
|
|
17
|
+
|
|
18
|
+
@classmethod
|
|
19
|
+
def get_compiled_path(cls, block: FileBlock):
|
|
20
|
+
return get_pseudo_test_path(block.name, block.path.relative_path)
|
dvt/parser/snapshots.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
from dvt.contracts.graph.nodes import SnapshotNode
|
|
5
|
+
from dvt.node_types import NodeType
|
|
6
|
+
from dvt.parser.base import SQLParser
|
|
7
|
+
from dvt.parser.search import BlockContents, BlockSearcher, FileBlock
|
|
8
|
+
from dvt.utils import split_path
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class SnapshotParser(SQLParser[SnapshotNode]):
|
|
12
|
+
def parse_from_dict(self, dct, validate=True) -> SnapshotNode:
|
|
13
|
+
if validate:
|
|
14
|
+
SnapshotNode.validate(dct)
|
|
15
|
+
return SnapshotNode.from_dict(dct)
|
|
16
|
+
|
|
17
|
+
@property
|
|
18
|
+
def resource_type(self) -> NodeType:
|
|
19
|
+
return NodeType.Snapshot
|
|
20
|
+
|
|
21
|
+
@classmethod
|
|
22
|
+
def get_compiled_path(cls, block: FileBlock):
|
|
23
|
+
return block.path.relative_path
|
|
24
|
+
|
|
25
|
+
def get_fqn(self, path: str, name: str) -> List[str]:
|
|
26
|
+
"""Get the FQN for the node. This impacts node selection and config
|
|
27
|
+
application.
|
|
28
|
+
|
|
29
|
+
On snapshots, the fqn includes the filename.
|
|
30
|
+
"""
|
|
31
|
+
no_ext = os.path.splitext(path)[0]
|
|
32
|
+
fqn = [self.project.project_name]
|
|
33
|
+
fqn.extend(split_path(no_ext))
|
|
34
|
+
fqn.append(name)
|
|
35
|
+
return fqn
|
|
36
|
+
|
|
37
|
+
def parse_file(self, file_block: FileBlock) -> None:
|
|
38
|
+
blocks = BlockSearcher(
|
|
39
|
+
source=[file_block],
|
|
40
|
+
allowed_blocks={"snapshot"},
|
|
41
|
+
source_tag_factory=BlockContents,
|
|
42
|
+
)
|
|
43
|
+
for block in blocks:
|
|
44
|
+
self.parse_node(block)
|