validio-cli 0.15.0__tar.gz → 0.16.0__tar.gz
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.
- {validio_cli-0.15.0 → validio_cli-0.16.0}/PKG-INFO +1 -1
- {validio_cli-0.15.0 → validio_cli-0.16.0}/pyproject.toml +1 -1
- {validio_cli-0.15.0 → validio_cli-0.16.0}/validio_cli/bin/entities/code.py +13 -4
- validio_cli-0.16.0/validio_cli/bin/entities/dbt.py +120 -0
- validio_cli-0.15.0/validio_cli/bin/entities/dbt.py +0 -59
- {validio_cli-0.15.0 → validio_cli-0.16.0}/LICENSE +0 -0
- {validio_cli-0.15.0 → validio_cli-0.16.0}/README_PUBLIC.md +0 -0
- {validio_cli-0.15.0 → validio_cli-0.16.0}/validio_cli/__init__.py +0 -0
- {validio_cli-0.15.0 → validio_cli-0.16.0}/validio_cli/bin/entities/channels.py +0 -0
- {validio_cli-0.15.0 → validio_cli-0.16.0}/validio_cli/bin/entities/config.py +0 -0
- {validio_cli-0.15.0 → validio_cli-0.16.0}/validio_cli/bin/entities/credentials.py +0 -0
- {validio_cli-0.15.0 → validio_cli-0.16.0}/validio_cli/bin/entities/incidents.py +0 -0
- {validio_cli-0.15.0 → validio_cli-0.16.0}/validio_cli/bin/entities/metrics.py +0 -0
- {validio_cli-0.15.0 → validio_cli-0.16.0}/validio_cli/bin/entities/notification_rules.py +0 -0
- {validio_cli-0.15.0 → validio_cli-0.16.0}/validio_cli/bin/entities/recommendations.py +0 -0
- {validio_cli-0.15.0 → validio_cli-0.16.0}/validio_cli/bin/entities/resources.py +0 -0
- {validio_cli-0.15.0 → validio_cli-0.16.0}/validio_cli/bin/entities/segmentations.py +0 -0
- {validio_cli-0.15.0 → validio_cli-0.16.0}/validio_cli/bin/entities/segments.py +0 -0
- {validio_cli-0.15.0 → validio_cli-0.16.0}/validio_cli/bin/entities/sources.py +0 -0
- {validio_cli-0.15.0 → validio_cli-0.16.0}/validio_cli/bin/entities/users.py +0 -0
- {validio_cli-0.15.0 → validio_cli-0.16.0}/validio_cli/bin/entities/validators.py +0 -0
- {validio_cli-0.15.0 → validio_cli-0.16.0}/validio_cli/bin/entities/windows.py +0 -0
- {validio_cli-0.15.0 → validio_cli-0.16.0}/validio_cli/bin/main.py +0 -0
- {validio_cli-0.15.0 → validio_cli-0.16.0}/validio_cli/components.py +0 -0
- {validio_cli-0.15.0 → validio_cli-0.16.0}/validio_cli/metadata.py +0 -0
- {validio_cli-0.15.0 → validio_cli-0.16.0}/validio_cli/namespace.py +0 -0
- {validio_cli-0.15.0 → validio_cli-0.16.0}/validio_cli/schema.py +0 -0
|
@@ -3,7 +3,7 @@ name = "validio-cli"
|
|
|
3
3
|
# This version does not represent the released version or any tag. For each
|
|
4
4
|
# release we automatically bump this before building and publishing so this
|
|
5
5
|
# should be kept at 0.0.1dev1
|
|
6
|
-
version = "0.
|
|
6
|
+
version = "0.16.0"
|
|
7
7
|
description = "CLI tool to interact with the Validio platform"
|
|
8
8
|
authors = ["Validio <support@validio.io>"]
|
|
9
9
|
license = "Apache-2.0"
|
|
@@ -426,16 +426,25 @@ def _show_update_resource_diff(
|
|
|
426
426
|
diff_output: DiffOutput,
|
|
427
427
|
) -> None:
|
|
428
428
|
for r in resources.values():
|
|
429
|
-
class_key = r.manifest.
|
|
429
|
+
class_key = r.manifest.__class__.__name__
|
|
430
430
|
|
|
431
|
-
print(f"{class_key} '{r.manifest.
|
|
431
|
+
print(f"{class_key} '{r.manifest.name}' will be updated")
|
|
432
432
|
|
|
433
433
|
rewrites = _diff_field_rewrites(show_schema)
|
|
434
|
+
|
|
434
435
|
a_value = code_plan._create_resource_diff_object(
|
|
435
|
-
r.manifest
|
|
436
|
+
r.manifest,
|
|
437
|
+
show_secrets=show_secrets,
|
|
438
|
+
rewrites=rewrites,
|
|
439
|
+
secrets_changed=r.secrets_changed,
|
|
440
|
+
is_manifest=True,
|
|
436
441
|
)
|
|
437
442
|
b_value = code_plan._create_resource_diff_object(
|
|
438
|
-
r.server
|
|
443
|
+
r.server,
|
|
444
|
+
show_secrets=show_secrets,
|
|
445
|
+
rewrites=rewrites,
|
|
446
|
+
secrets_changed=r.secrets_changed,
|
|
447
|
+
is_manifest=False,
|
|
439
448
|
)
|
|
440
449
|
|
|
441
450
|
_show_diff(b_value, a_value, color, diff_output, class_key)
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Any, Optional, Tuple
|
|
4
|
+
|
|
5
|
+
import typer
|
|
6
|
+
from validio_sdk import ValidioError, dbt, util
|
|
7
|
+
|
|
8
|
+
from validio_cli import AsyncTyper, ConfigDir, Namespace, get_client_and_config
|
|
9
|
+
from validio_cli.bin.entities import credentials
|
|
10
|
+
|
|
11
|
+
app = AsyncTyper(help="dbt related commands")
|
|
12
|
+
|
|
13
|
+
"""
|
|
14
|
+
Well-known file name for the manifest artifact.
|
|
15
|
+
|
|
16
|
+
https://docs.getdbt.com/reference/artifacts/dbt-artifacts
|
|
17
|
+
"""
|
|
18
|
+
MANIFEST_FILE_NAME = "manifest.json"
|
|
19
|
+
|
|
20
|
+
"""
|
|
21
|
+
Well-known file name for the run-results artifact.
|
|
22
|
+
|
|
23
|
+
https://docs.getdbt.com/reference/artifacts/dbt-artifacts
|
|
24
|
+
"""
|
|
25
|
+
RUN_RESULTS_FILE_NAME = "run_results.json"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _resolve_file_paths(
|
|
29
|
+
explicit_manifest_path: Optional[Path],
|
|
30
|
+
explicit_run_result_path: Optional[Path],
|
|
31
|
+
target_path: Optional[Path],
|
|
32
|
+
) -> Tuple[Path, Optional[Path]]:
|
|
33
|
+
if explicit_manifest_path or explicit_run_result_path:
|
|
34
|
+
print(
|
|
35
|
+
"Deprecation notice ⚠️: The --manifest and --run-results flags "
|
|
36
|
+
"have been deprecated and will be removed in a future version. "
|
|
37
|
+
"Please use the --target-path argument instead."
|
|
38
|
+
)
|
|
39
|
+
if not explicit_manifest_path:
|
|
40
|
+
raise ValidioError(
|
|
41
|
+
"--manifest is required when combined with the --run-results argument"
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
return explicit_manifest_path, explicit_run_result_path
|
|
45
|
+
|
|
46
|
+
if not target_path:
|
|
47
|
+
raise ValidioError("Missing --target-path argument")
|
|
48
|
+
|
|
49
|
+
manifest_path = target_path / MANIFEST_FILE_NAME
|
|
50
|
+
run_results_path = target_path / RUN_RESULTS_FILE_NAME
|
|
51
|
+
if not manifest_path.is_file():
|
|
52
|
+
raise ValidioError(f"manifest file not found at {manifest_path}")
|
|
53
|
+
|
|
54
|
+
if not run_results_path.is_file():
|
|
55
|
+
print(
|
|
56
|
+
"Warning: run_results file not found at {run_results_path}. "
|
|
57
|
+
"Uploading only manifest file"
|
|
58
|
+
)
|
|
59
|
+
return manifest_path, None
|
|
60
|
+
|
|
61
|
+
return manifest_path, run_results_path
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@app.async_command(help="Upload dbt artifact")
|
|
65
|
+
async def upload(
|
|
66
|
+
config_dir: str = ConfigDir,
|
|
67
|
+
namespace: str = Namespace(),
|
|
68
|
+
credential_id: str = typer.Option(..., help="Credential name or ID"),
|
|
69
|
+
manifest: Optional[Path] = typer.Option(
|
|
70
|
+
help="Path to the manifest file. "
|
|
71
|
+
"(deprecated in favor of the --target-path flag)",
|
|
72
|
+
default=None,
|
|
73
|
+
),
|
|
74
|
+
job_name: str = typer.Option(
|
|
75
|
+
..., help="The job that the dbt execution belongs to, e.g. `staging-pipeline`"
|
|
76
|
+
),
|
|
77
|
+
run_results: Optional[Path] = typer.Option(
|
|
78
|
+
help="Path to the run results file. "
|
|
79
|
+
"(deprecated in favor of the --target-path flag)",
|
|
80
|
+
default=None,
|
|
81
|
+
),
|
|
82
|
+
target_path: Optional[Path] = typer.Option(
|
|
83
|
+
help="Path to the dbt artifacts target directory. "
|
|
84
|
+
"(supersedes the --manifest flag)",
|
|
85
|
+
default=None,
|
|
86
|
+
),
|
|
87
|
+
) -> None:
|
|
88
|
+
vc, cfg = await get_client_and_config(config_dir)
|
|
89
|
+
|
|
90
|
+
resolved_credential_id = await credentials.get_credential_id(
|
|
91
|
+
vc, cfg, credential_id, namespace
|
|
92
|
+
)
|
|
93
|
+
if resolved_credential_id is None:
|
|
94
|
+
raise ValidioError(f"Credential '{credential_id}' not found")
|
|
95
|
+
|
|
96
|
+
manifest, run_results = _resolve_file_paths(manifest, run_results, target_path)
|
|
97
|
+
|
|
98
|
+
run_results_content = None
|
|
99
|
+
try:
|
|
100
|
+
manifest_content = typing.cast(dict[str, Any], util.read_json_file(manifest))
|
|
101
|
+
if run_results is not None:
|
|
102
|
+
run_results_content = typing.cast(
|
|
103
|
+
dict[str, Any],
|
|
104
|
+
util.read_json_file(run_results),
|
|
105
|
+
)
|
|
106
|
+
except Exception as e:
|
|
107
|
+
raise ValidioError(f"Failed to process artifacts file: {e}")
|
|
108
|
+
|
|
109
|
+
await dbt.upload_artifacts(
|
|
110
|
+
client=vc,
|
|
111
|
+
credential_id=resolved_credential_id,
|
|
112
|
+
job_name=job_name,
|
|
113
|
+
manifest=manifest_content,
|
|
114
|
+
run_results=run_results_content,
|
|
115
|
+
)
|
|
116
|
+
return print("dbt artifact uploaded successfully")
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
if __name__ == "__main__":
|
|
120
|
+
typer.run(app())
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
import typing
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
from typing import Any
|
|
5
|
-
|
|
6
|
-
import typer
|
|
7
|
-
from validio_sdk import ValidioError, dbt, util
|
|
8
|
-
from validio_sdk.graphql_client.input_types import DbtArtifactUploadInput
|
|
9
|
-
|
|
10
|
-
from validio_cli import AsyncTyper, ConfigDir, Namespace, get_client_and_config
|
|
11
|
-
from validio_cli.bin.entities import credentials
|
|
12
|
-
|
|
13
|
-
app = AsyncTyper(help="dbt related commands")
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
@app.async_command(help="Upload dbt artifact")
|
|
17
|
-
async def upload(
|
|
18
|
-
config_dir: str = ConfigDir,
|
|
19
|
-
namespace: str = Namespace(),
|
|
20
|
-
credential_id: str = typer.Option(..., help="Credential name or ID"),
|
|
21
|
-
manifest: Path = typer.Option(..., help="Path to the manifest file"),
|
|
22
|
-
job_name: str = typer.Option(
|
|
23
|
-
..., help="The job that the dbt execution belongs to, e.g. `staging-pipeline`"
|
|
24
|
-
),
|
|
25
|
-
run_results: Path = typer.Option(help="Path to the run results file", default=None),
|
|
26
|
-
) -> None:
|
|
27
|
-
vc, cfg = await get_client_and_config(config_dir)
|
|
28
|
-
|
|
29
|
-
resolved_credential_id = await credentials.get_credential_id(
|
|
30
|
-
vc, cfg, credential_id, namespace
|
|
31
|
-
)
|
|
32
|
-
if resolved_credential_id is None:
|
|
33
|
-
raise ValidioError(f"Credential '{credential_id}' not found")
|
|
34
|
-
|
|
35
|
-
try:
|
|
36
|
-
manifest_content = util.read_json_file(manifest)
|
|
37
|
-
trimmed_manifest = dbt.trim_manifest_json(
|
|
38
|
-
typing.cast(dict[str, Any], manifest_content)
|
|
39
|
-
)
|
|
40
|
-
except Exception as e:
|
|
41
|
-
raise ValidioError(f"Failed to process manifest file: {e}")
|
|
42
|
-
|
|
43
|
-
run_results_content = None
|
|
44
|
-
if run_results is not None:
|
|
45
|
-
run_results_content = json.dumps(util.read_json_file(run_results))
|
|
46
|
-
|
|
47
|
-
await vc.dbt_artifact_upload(
|
|
48
|
-
input=DbtArtifactUploadInput(
|
|
49
|
-
credential_id=resolved_credential_id,
|
|
50
|
-
manifest=json.dumps(trimmed_manifest),
|
|
51
|
-
run_results=run_results_content,
|
|
52
|
-
job_name=job_name,
|
|
53
|
-
)
|
|
54
|
-
)
|
|
55
|
-
return print("dbt artifact uploaded successfully")
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if __name__ == "__main__":
|
|
59
|
-
typer.run(app())
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|