datasecops-cli 0.7.0b7__tar.gz → 0.7.0b9__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.
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/.github/workflows/auto-tag.yml +1 -1
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/.github/workflows/test.yml +1 -1
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/CHANGELOG.md +21 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/PKG-INFO +26 -3
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/README.md +24 -1
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/docs/mcp-server.md +7 -3
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/pyproject.toml +2 -2
- datasecops_cli-0.7.0b9/src/datasecops_cli/__init__.py +1 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/menus/development.py +173 -35
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/services/dbt_runner.py +86 -13
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/services/linting_service.py +84 -3
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/services/snowflake_service.py +1 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_mcp/connection.py +1 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_mcp/server.py +143 -71
- datasecops_cli-0.7.0b9/tests/test_dbt_runner.py +245 -0
- datasecops_cli-0.7.0b9/tests/test_linting_service.py +157 -0
- datasecops_cli-0.7.0b9/tests/test_mcp_lint_tools.py +200 -0
- datasecops_cli-0.7.0b7/src/datasecops_cli/__init__.py +0 -1
- datasecops_cli-0.7.0b7/tests/test_dbt_runner.py +0 -47
- datasecops_cli-0.7.0b7/tests/test_linting_service.py +0 -59
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/.github/workflows/publish-cli.yml +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/.gitignore +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/AGENTS.md +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/DEVELOPMENT.md +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/LICENSE +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/docs/dcm.md +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/docs/getting-started.md +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/docs/git-operations.md +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/docs/legacy.md +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/docs/legacy_plan_of_action.md +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/mcp-servers.json +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/scripts/vendor_model.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/setup.ps1 +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/setup.sh +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/config.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/main.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/menus/__init__.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/menus/configuration.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/menus/dcm_operations.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/menus/downloads.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/menus/git_operations.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/models/__init__.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/models/git_helpers.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/models/project_config.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/services/__init__.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/services/bootstrap_service.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/services/dbt_project_generator.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/services/dcm_orchestrator.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/services/dcm_pipelines.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/services/dcm_registry.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/services/dcm_service.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/services/directory_scaffolder.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/services/download_service.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/services/git_service.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/services/model_commands.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/services/pipeline_env.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/services/skill_service.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/services/upstream_service.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/utilities/__init__.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/utilities/display.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/utilities/file_utils.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/utilities/mcp.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_cli/utilities/yaml_utils.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_mcp/__init__.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_mcp/__main__.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_model/__init__.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_model/convert.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_model/diagram.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_model/expand.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_model/extract.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_model/render.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_model/schema.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_model/scope.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_model/scripts.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_model/starter.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_model/templates/macros/role.sql +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_model/templates/macros/role_guard.sql +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_model/templates/macros/warehouse.sql +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/src/datasecops_model/validate.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/tests/__init__.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/tests/test_config.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/tests/test_dbt_project_generator_profiles.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/tests/test_dcm_model.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/tests/test_dcm_orchestrator.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/tests/test_dcm_service.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/tests/test_download_service.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/tests/test_file_utils.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/tests/test_main.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/tests/test_model_commands.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/tests/test_models.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/tests/test_pipeline_env.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/tests/test_version.py +0 -0
- {datasecops_cli-0.7.0b7 → datasecops_cli-0.7.0b9}/tests/test_yaml_utils.py +0 -0
|
@@ -6,6 +6,27 @@ All notable changes to the DataSecOps CLI are documented in this file.
|
|
|
6
6
|
|
|
7
7
|
### Fixed
|
|
8
8
|
|
|
9
|
+
- **CLI connections emitted a `FutureWarning` about `enable_server_session_keep_alive_auto_detection` on every launch** — `SnowflakeService.connect()` and the MCP server's `MCPSnowflakeService.conn` called `snowflake.connector.connect()` without this parameter; `snowflake-connector-python` now warns because its default will change in a future release. Both now pass `enable_server_session_keep_alive_auto_detection=True` explicitly, preserving current behavior and silencing the warning.
|
|
10
|
+
|
|
11
|
+
## [0.7.0b9] - 2026-10-28
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **New `--empty`, `--generate-info-schema` and `--static-analysis strict` flags on `run`/`build`** — the Development menu's run and build flows now prompt for a schema-only dry run (`--empty`, validates dependencies without reading real data) and for writing the dbt Information Schema to `target/info_schema/` (`--generate-info-schema`), optionally with column-level lineage (`--static-analysis strict`).
|
|
16
|
+
- **New `compile` submenu** — compile the whole project, a specific selector, or an ad-hoc dbt-SQL query (`--inline`), with `--no-introspect` (error instead of running introspective warehouse queries) and `--generate-info-schema` prompts.
|
|
17
|
+
- **New `parse` submenu** — adds `--no-partial-parse` (force a full re-parse) and `--generate-info-schema` prompts.
|
|
18
|
+
- **`dbt lint --changed`, `--rules`/`--exclude-rules`, `--jinja-render-mode`, and the separate `dbt format`/`fmt` command** (dbt2 engine only) — the lint menu gained a "changed" option that lints only git-modified files natively, a "format" option that auto-formats SQL via `.sqlfluff` layout rules (with a `--check` dry-run), and the "specific" lint flow now optionally prompts for rule codes to enable/disable and the Jinja render mode.
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- **`dbt build` was missing from the Development menu entirely** — `DbtRunner.build()` already existed and the README already advertised "dbt run, build, test, lint", but no menu option called it. It's now a top-level menu entry with full/modified/specific run options, mirroring `run`.
|
|
23
|
+
|
|
24
|
+
## [0.7.0b8] - 2026-10-27
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- **MCP server's linting tools ignored `dbt_engine` and always ran `sqlfluff`** — `lint_sql`, `fix_sql`, and `lint_project` hardcoded the standalone `sqlfluff` CLI even on dbt 2.0 projects, where it isn't installed or pinned (the CLI's own `datasecops lint` already used `dbt lint` there). They now read the project's `dbt_engine` from `.datasecops.yml` (checking the repository root too when the dbt project is nested under a `dbt/` subdirectory) and dispatch to `dbt lint`/`dbt lint --fix` for dbt 2.x, matching the CLI's engine selection; `lint_project` also drops the `models/` directory requirement for dbt 2.x, since `dbt lint` scopes to the whole project itself. The dbt-snowflake adapter install (needed only by SQLFluff's dbt templater) is now skipped for dbt 2.x projects, where it could otherwise fail before `dbt lint` even runs.
|
|
29
|
+
- **`mcp` optional dependency had no upper bound** — `mcp>=1.0` could resolve to `mcp` 2.x, which renamed `FastMCP` to `MCPServer` and broke `datasecops_mcp.server`'s import outright; pinned to `mcp>=1.0,<2`.
|
|
9
30
|
- **`profiles.yml` writes could still widen file permissions or miss a symlinked file** — the atomic-replace temp file is now created with restrictive (`0600`) permissions and, if `profiles.yml` already existed, its mode is reapplied before the swap, instead of inheriting the process umask (typically `0644`) and exposing credentials. The profiles path itself (not just its parent directory) is now resolved before deriving the lock and temp-file paths, so a symlinked `profiles.yml` is replaced at its real location instead of only the link.
|
|
10
31
|
|
|
11
32
|
## [0.7.0b7] - 2026-10-26
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: datasecops-cli
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.0b9
|
|
4
4
|
Summary: DataSecOps Framework CLI for Snowflake Native App
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -12,7 +12,7 @@ Requires-Dist: pydantic>=2.0
|
|
|
12
12
|
Requires-Dist: pyyaml>=6.0
|
|
13
13
|
Requires-Dist: snowflake-connector-python>=3.0
|
|
14
14
|
Provides-Extra: mcp
|
|
15
|
-
Requires-Dist: mcp
|
|
15
|
+
Requires-Dist: mcp<2,>=1.0; extra == 'mcp'
|
|
16
16
|
Provides-Extra: test
|
|
17
17
|
Requires-Dist: pytest-cov>=4.0; extra == 'test'
|
|
18
18
|
Requires-Dist: pytest>=7.0; extra == 'test'
|
|
@@ -82,11 +82,34 @@ datasecops
|
|
|
82
82
|
|
|
83
83
|
| Menu | Capabilities |
|
|
84
84
|
|------|-------------|
|
|
85
|
-
| **Development** | dbt run, build, test, lint (SQLFluff), deps, seed, compile, snapshot, freshness, docs |
|
|
85
|
+
| **Development** | dbt run, build, test, lint (SQLFluff/`dbt lint`), format (`dbt format`, dbt2), deps, seed, compile, parse, snapshot, freshness, docs |
|
|
86
86
|
| **Git** | Branch create/checkout/delete, commit & push, rebase, squash, deploy to environment branches, cherry-pick, reset branch from main |
|
|
87
87
|
| **DCM Operations** | Plan, deploy, status, download and list the DCM projects in the model |
|
|
88
88
|
| **Downloads** | SQLFluff config, CI/CD pipelines (GitHub Actions / Azure DevOps), dbt packages, CoCo skills |
|
|
89
89
|
|
|
90
|
+
### dbt command flags
|
|
91
|
+
|
|
92
|
+
The Development menu exposes these flags from the underlying `dbt` commands:
|
|
93
|
+
|
|
94
|
+
- **`run` / `build`** - `--full-refresh`; `--empty` runs with zero-row refs/sources to validate
|
|
95
|
+
dependencies cheaply — it still executes each model's SQL against the warehouse, so table
|
|
96
|
+
models are materialized with empty/reduced data and their current contents are replaced; it
|
|
97
|
+
is **not** a no-write dry run. `--generate-info-schema` (dbt2 only) writes the dbt Information
|
|
98
|
+
Schema (queryable project metadata) to `target/info_schema/`; `--static-analysis strict`
|
|
99
|
+
(dbt2 only, independent of `--generate-info-schema`) adds column-level lineage.
|
|
100
|
+
- **`compile`** - compile the whole project, a specific selector, or an ad-hoc dbt-SQL query
|
|
101
|
+
(`--inline`); `--no-introspect` to error instead of running introspective warehouse queries;
|
|
102
|
+
`--generate-info-schema` (dbt2 only) as above.
|
|
103
|
+
- **`parse`** - `--no-partial-parse` to force a full re-parse instead of only recently changed
|
|
104
|
+
files; `--generate-info-schema` (dbt2 only) as above.
|
|
105
|
+
- **`lint` / `format`** *(dbt2 engine only)* - `dbt lint` supports `--rules`/`--exclude-rules`
|
|
106
|
+
(rule codes to enable/disable), `--jinja-render-mode` (`symbolic`/`rendered`/`turbo`), and
|
|
107
|
+
`--changed` to lint only git-modified files. The separate `dbt format`/`dbt fmt` command
|
|
108
|
+
auto-formats SQL files according to `.sqlfluff` layout rules, with a `--check` dry-run mode.
|
|
109
|
+
These are not available on the SQLFluff (dbt Core 1.x) path; on dbt Core the CLI skips
|
|
110
|
+
`--generate-info-schema`/`--static-analysis strict` with a warning instead of sending a flag
|
|
111
|
+
dbt Core would reject.
|
|
112
|
+
|
|
90
113
|
## Non-Interactive Mode (CI/CD)
|
|
91
114
|
|
|
92
115
|
The `download` subcommand lets you pull framework config in CI/CD pipelines without interactive prompts:
|
|
@@ -62,11 +62,34 @@ datasecops
|
|
|
62
62
|
|
|
63
63
|
| Menu | Capabilities |
|
|
64
64
|
|------|-------------|
|
|
65
|
-
| **Development** | dbt run, build, test, lint (SQLFluff), deps, seed, compile, snapshot, freshness, docs |
|
|
65
|
+
| **Development** | dbt run, build, test, lint (SQLFluff/`dbt lint`), format (`dbt format`, dbt2), deps, seed, compile, parse, snapshot, freshness, docs |
|
|
66
66
|
| **Git** | Branch create/checkout/delete, commit & push, rebase, squash, deploy to environment branches, cherry-pick, reset branch from main |
|
|
67
67
|
| **DCM Operations** | Plan, deploy, status, download and list the DCM projects in the model |
|
|
68
68
|
| **Downloads** | SQLFluff config, CI/CD pipelines (GitHub Actions / Azure DevOps), dbt packages, CoCo skills |
|
|
69
69
|
|
|
70
|
+
### dbt command flags
|
|
71
|
+
|
|
72
|
+
The Development menu exposes these flags from the underlying `dbt` commands:
|
|
73
|
+
|
|
74
|
+
- **`run` / `build`** - `--full-refresh`; `--empty` runs with zero-row refs/sources to validate
|
|
75
|
+
dependencies cheaply — it still executes each model's SQL against the warehouse, so table
|
|
76
|
+
models are materialized with empty/reduced data and their current contents are replaced; it
|
|
77
|
+
is **not** a no-write dry run. `--generate-info-schema` (dbt2 only) writes the dbt Information
|
|
78
|
+
Schema (queryable project metadata) to `target/info_schema/`; `--static-analysis strict`
|
|
79
|
+
(dbt2 only, independent of `--generate-info-schema`) adds column-level lineage.
|
|
80
|
+
- **`compile`** - compile the whole project, a specific selector, or an ad-hoc dbt-SQL query
|
|
81
|
+
(`--inline`); `--no-introspect` to error instead of running introspective warehouse queries;
|
|
82
|
+
`--generate-info-schema` (dbt2 only) as above.
|
|
83
|
+
- **`parse`** - `--no-partial-parse` to force a full re-parse instead of only recently changed
|
|
84
|
+
files; `--generate-info-schema` (dbt2 only) as above.
|
|
85
|
+
- **`lint` / `format`** *(dbt2 engine only)* - `dbt lint` supports `--rules`/`--exclude-rules`
|
|
86
|
+
(rule codes to enable/disable), `--jinja-render-mode` (`symbolic`/`rendered`/`turbo`), and
|
|
87
|
+
`--changed` to lint only git-modified files. The separate `dbt format`/`dbt fmt` command
|
|
88
|
+
auto-formats SQL files according to `.sqlfluff` layout rules, with a `--check` dry-run mode.
|
|
89
|
+
These are not available on the SQLFluff (dbt Core 1.x) path; on dbt Core the CLI skips
|
|
90
|
+
`--generate-info-schema`/`--static-analysis strict` with a warning instead of sending a flag
|
|
91
|
+
dbt Core would reject.
|
|
92
|
+
|
|
70
93
|
## Non-Interactive Mode (CI/CD)
|
|
71
94
|
|
|
72
95
|
The `download` subcommand lets you pull framework config in CI/CD pipelines without interactive prompts:
|
|
@@ -97,9 +97,13 @@ It uses your Snowflake connection from `~/.snowflake/connections.toml` to authen
|
|
|
97
97
|
|
|
98
98
|
| Tool | Description |
|
|
99
99
|
|------|-------------|
|
|
100
|
-
| `lint_sql` | Lint a single SQL file
|
|
101
|
-
| `fix_sql` | Auto-fix linting issues in a SQL file |
|
|
102
|
-
| `lint_project` | Lint all models in the project (optionally auto-fix) |
|
|
100
|
+
| `lint_sql` | Lint a single SQL file — SQLFluff (dbt Core 1.x) or `dbt lint` (dbt 2.x), per the project's `dbt_engine` |
|
|
101
|
+
| `fix_sql` | Auto-fix linting issues in a SQL file — SQLFluff `fix` or `dbt lint --fix`, per `dbt_engine` |
|
|
102
|
+
| `lint_project` | Lint all models in the project (optionally auto-fix) — same engine selection as above |
|
|
103
|
+
|
|
104
|
+
All three read the project's `dbt_engine` setting from `.datasecops.yml` and run the same
|
|
105
|
+
tool the CLI's `datasecops lint` would use, so results match what `lint`/`lint --fix` produce
|
|
106
|
+
locally.
|
|
103
107
|
|
|
104
108
|
### Source Control Tools
|
|
105
109
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "datasecops-cli"
|
|
7
|
-
version = "0.7.
|
|
7
|
+
version = "0.7.0b9"
|
|
8
8
|
description = "DataSecOps Framework CLI for Snowflake Native App"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -20,7 +20,7 @@ dependencies = [
|
|
|
20
20
|
|
|
21
21
|
[project.optional-dependencies]
|
|
22
22
|
test = ["pytest>=7.0", "pytest-cov>=4.0"]
|
|
23
|
-
mcp = ["mcp>=1.0"]
|
|
23
|
+
mcp = ["mcp>=1.0,<2"]
|
|
24
24
|
|
|
25
25
|
[tool.hatch.build.targets.wheel]
|
|
26
26
|
packages = ["src/datasecops_cli", "src/datasecops_mcp", "src/datasecops_model"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.7.0b9"
|
|
@@ -32,52 +32,50 @@ class DevelopmentMenu:
|
|
|
32
32
|
if option == 1:
|
|
33
33
|
self._run_menu()
|
|
34
34
|
elif option == 2:
|
|
35
|
-
self.
|
|
35
|
+
self._build_menu()
|
|
36
36
|
elif option == 3:
|
|
37
|
-
self.
|
|
37
|
+
self._test_menu()
|
|
38
38
|
elif option == 4:
|
|
39
|
+
self._lint_menu()
|
|
40
|
+
elif option == 5:
|
|
39
41
|
display_action_header("dbt docs")
|
|
40
42
|
self.dbt.docs_generate()
|
|
41
43
|
if get_input_true_false("Serve docs?"):
|
|
42
44
|
self.dbt.docs_serve()
|
|
43
45
|
complete_action()
|
|
44
|
-
elif option ==
|
|
46
|
+
elif option == 6:
|
|
45
47
|
display_action_header("dbt seed")
|
|
46
48
|
self.dbt.seed()
|
|
47
49
|
complete_action()
|
|
48
|
-
elif option ==
|
|
50
|
+
elif option == 7:
|
|
49
51
|
display_action_header("dbt deps")
|
|
50
52
|
self.dbt.deps()
|
|
51
53
|
complete_action()
|
|
52
|
-
elif option == 7:
|
|
53
|
-
display_action_header("dbt parse")
|
|
54
|
-
self.dbt.parse()
|
|
55
|
-
complete_action()
|
|
56
54
|
elif option == 8:
|
|
57
|
-
|
|
58
|
-
self.dbt.compile()
|
|
59
|
-
complete_action()
|
|
55
|
+
self._parse_menu()
|
|
60
56
|
elif option == 9:
|
|
57
|
+
self._compile_menu()
|
|
58
|
+
elif option == 10:
|
|
61
59
|
display_action_header("dbt snapshot")
|
|
62
60
|
self.dbt.snapshot()
|
|
63
61
|
complete_action()
|
|
64
|
-
elif option ==
|
|
62
|
+
elif option == 11:
|
|
65
63
|
display_action_header("dbt source freshness")
|
|
66
64
|
self.dbt.source_freshness()
|
|
67
65
|
complete_action()
|
|
68
|
-
elif option ==
|
|
66
|
+
elif option == 12:
|
|
69
67
|
display_action_header("dbt clean")
|
|
70
68
|
self.dbt.clean()
|
|
71
69
|
complete_action()
|
|
72
|
-
elif option ==
|
|
70
|
+
elif option == 13:
|
|
73
71
|
display_action_header("dbt debug")
|
|
74
72
|
self.dbt.debug()
|
|
75
73
|
complete_action()
|
|
76
|
-
elif option ==
|
|
74
|
+
elif option == 14:
|
|
77
75
|
display_action_header("dbt list")
|
|
78
76
|
self.dbt.list_models()
|
|
79
77
|
complete_action()
|
|
80
|
-
elif option ==
|
|
78
|
+
elif option == 15:
|
|
81
79
|
self._autofix_menu()
|
|
82
80
|
self._menu()
|
|
83
81
|
option = get_input_number("Choose an option: ")
|
|
@@ -86,21 +84,45 @@ class DevelopmentMenu:
|
|
|
86
84
|
clear()
|
|
87
85
|
section_header("Development Menu", self.profile_name, self.git.get_current_branch() if self.git else None)
|
|
88
86
|
menu_option(1, "run - Run dbt models")
|
|
89
|
-
menu_option(2, "
|
|
90
|
-
menu_option(3, "
|
|
91
|
-
menu_option(4, "
|
|
92
|
-
menu_option(5, "
|
|
93
|
-
menu_option(6, "
|
|
94
|
-
menu_option(7, "
|
|
95
|
-
menu_option(8, "
|
|
96
|
-
menu_option(9, "
|
|
97
|
-
menu_option(10, "
|
|
98
|
-
menu_option(11, "
|
|
99
|
-
menu_option(12, "
|
|
100
|
-
menu_option(13, "
|
|
101
|
-
menu_option(14, "
|
|
87
|
+
menu_option(2, "build - Run models, test, snapshot & seed together (DAG order)")
|
|
88
|
+
menu_option(3, "test - Run dbt tests")
|
|
89
|
+
menu_option(4, "lint - Lint SQL files")
|
|
90
|
+
menu_option(5, "docs - Generate & serve dbt docs")
|
|
91
|
+
menu_option(6, "seed - Load seed data")
|
|
92
|
+
menu_option(7, "deps - Install dbt packages")
|
|
93
|
+
menu_option(8, "parse - Parse dbt project")
|
|
94
|
+
menu_option(9, "compile - Compile dbt models")
|
|
95
|
+
menu_option(10, "snapshot - Run dbt snapshots")
|
|
96
|
+
menu_option(11, "freshness - Check source freshness")
|
|
97
|
+
menu_option(12, "clean - Clean dbt target")
|
|
98
|
+
menu_option(13, "debug - Debug dbt connection")
|
|
99
|
+
menu_option(14, "list - List dbt resources")
|
|
100
|
+
menu_option(15, "autofix - dbt autofix (deprecations, packages, jobs)")
|
|
102
101
|
menu_option(0, "back - Return to main menu")
|
|
103
102
|
|
|
103
|
+
def _prompt_run_build_flags(self) -> dict:
|
|
104
|
+
"""Shared y/n prompts for the extra run/build flags (--empty, --generate-info-schema,
|
|
105
|
+
--static-analysis strict). The latter two require the dbt2 engine."""
|
|
106
|
+
empty = get_input_true_false(
|
|
107
|
+
"Run with zero-row refs/sources (--empty)? This still executes against the "
|
|
108
|
+
"warehouse and materializes table models with empty/reduced data, replacing "
|
|
109
|
+
"their current contents — it validates dependencies cheaply, it is NOT a "
|
|
110
|
+
"no-write dry run.", "n")
|
|
111
|
+
generate_info_schema = False
|
|
112
|
+
static_analysis_strict = False
|
|
113
|
+
if self.dbt.engine == "dbt2":
|
|
114
|
+
generate_info_schema = get_input_true_false(
|
|
115
|
+
"Write the dbt Information Schema for querying project metadata "
|
|
116
|
+
"(--generate-info-schema, dbt2 only)?", "n")
|
|
117
|
+
static_analysis_strict = get_input_true_false(
|
|
118
|
+
"Infer column types & column-level lineage (--static-analysis strict, dbt2 only)?",
|
|
119
|
+
"n")
|
|
120
|
+
return {
|
|
121
|
+
"empty": empty,
|
|
122
|
+
"generate_info_schema": generate_info_schema,
|
|
123
|
+
"static_analysis_strict": static_analysis_strict,
|
|
124
|
+
}
|
|
125
|
+
|
|
104
126
|
def _run_menu(self) -> None:
|
|
105
127
|
clear()
|
|
106
128
|
display_action_header("dbt Run Options")
|
|
@@ -113,14 +135,17 @@ class DevelopmentMenu:
|
|
|
113
135
|
option = get_input_number("Choose an option: ")
|
|
114
136
|
if option == 1:
|
|
115
137
|
full_refresh = get_input_true_false("Full refresh?", "n")
|
|
116
|
-
self.
|
|
138
|
+
flags = self._prompt_run_build_flags()
|
|
139
|
+
self.dbt.run(full_refresh=full_refresh, **flags)
|
|
117
140
|
elif option == 2:
|
|
118
141
|
full_refresh = get_input_true_false("Full refresh?", "n")
|
|
119
|
-
self.
|
|
142
|
+
flags = self._prompt_run_build_flags()
|
|
143
|
+
self.dbt.run(modified_only=True, full_refresh=full_refresh, **flags)
|
|
120
144
|
elif option == 3:
|
|
121
145
|
select = get_input_string("Enter model selector (e.g. my_model, my_model+, tag:nightly, path:models/...): ")
|
|
122
146
|
if select != "0":
|
|
123
|
-
self.
|
|
147
|
+
flags = self._prompt_run_build_flags()
|
|
148
|
+
self.dbt.run(select=select, **flags)
|
|
124
149
|
elif option == 4:
|
|
125
150
|
macro = get_input_string("Enter macro name: ")
|
|
126
151
|
if macro != "0":
|
|
@@ -129,6 +154,30 @@ class DevelopmentMenu:
|
|
|
129
154
|
elif option == 5:
|
|
130
155
|
self.dbt.retry()
|
|
131
156
|
complete_action()
|
|
157
|
+
|
|
158
|
+
def _build_menu(self) -> None:
|
|
159
|
+
clear()
|
|
160
|
+
display_action_header("dbt Build Options")
|
|
161
|
+
info_line("dbt build runs models, tests, snapshots & seeds together, in DAG order.")
|
|
162
|
+
menu_option(1, "full build - Build all resources")
|
|
163
|
+
menu_option(2, "modified - Build modified models only (state:modified+)")
|
|
164
|
+
menu_option(3, "specific - Build specific resource(s)")
|
|
165
|
+
menu_option(0, "back - Return to development menu")
|
|
166
|
+
option = get_input_number("Choose an option: ")
|
|
167
|
+
if option == 1:
|
|
168
|
+
full_refresh = get_input_true_false("Full refresh?", "n")
|
|
169
|
+
flags = self._prompt_run_build_flags()
|
|
170
|
+
self.dbt.build(full_refresh=full_refresh, **flags)
|
|
171
|
+
elif option == 2:
|
|
172
|
+
full_refresh = get_input_true_false("Full refresh?", "n")
|
|
173
|
+
flags = self._prompt_run_build_flags()
|
|
174
|
+
self.dbt.build(modified_only=True, full_refresh=full_refresh, **flags)
|
|
175
|
+
elif option == 3:
|
|
176
|
+
select = get_input_string("Enter resource selector (e.g. my_model, tag:nightly, resource_type:function): ")
|
|
177
|
+
if select != "0":
|
|
178
|
+
flags = self._prompt_run_build_flags()
|
|
179
|
+
self.dbt.build(select=select, **flags)
|
|
180
|
+
complete_action()
|
|
132
181
|
|
|
133
182
|
def _test_menu(self) -> None:
|
|
134
183
|
clear()
|
|
@@ -153,6 +202,57 @@ class DevelopmentMenu:
|
|
|
153
202
|
if select != "0":
|
|
154
203
|
self.dbt.test(select=select)
|
|
155
204
|
complete_action()
|
|
205
|
+
|
|
206
|
+
def _parse_menu(self) -> None:
|
|
207
|
+
clear()
|
|
208
|
+
display_action_header("dbt Parse Options")
|
|
209
|
+
menu_option(1, "standard - Parse & validate the project (fast, no warehouse connection)")
|
|
210
|
+
menu_option(0, "back - Return to development menu")
|
|
211
|
+
option = get_input_number("Choose an option: ")
|
|
212
|
+
if option == 1:
|
|
213
|
+
no_partial_parse = get_input_true_false(
|
|
214
|
+
"Force a full re-parse instead of only recently changed files (--no-partial-parse)?", "n")
|
|
215
|
+
generate_info_schema = False
|
|
216
|
+
if self.dbt.engine == "dbt2":
|
|
217
|
+
generate_info_schema = get_input_true_false(
|
|
218
|
+
"Write the dbt Information Schema for querying project metadata "
|
|
219
|
+
"(--generate-info-schema, dbt2 only)?", "n")
|
|
220
|
+
self.dbt.parse(no_partial_parse=no_partial_parse, generate_info_schema=generate_info_schema)
|
|
221
|
+
complete_action()
|
|
222
|
+
|
|
223
|
+
def _compile_menu(self) -> None:
|
|
224
|
+
clear()
|
|
225
|
+
display_action_header("dbt Compile Options")
|
|
226
|
+
menu_option(1, "full - Compile all models")
|
|
227
|
+
menu_option(2, "specific - Compile specific model(s) (--select)")
|
|
228
|
+
menu_option(3, "inline - Compile an ad-hoc dbt-SQL query (--inline)")
|
|
229
|
+
menu_option(0, "back - Return to development menu")
|
|
230
|
+
option = get_input_number("Choose an option: ")
|
|
231
|
+
select = None
|
|
232
|
+
inline = None
|
|
233
|
+
if option == 2:
|
|
234
|
+
select = get_input_string("Enter model selector (e.g. my_model, resource_type:test): ")
|
|
235
|
+
if select == "0":
|
|
236
|
+
complete_action()
|
|
237
|
+
return
|
|
238
|
+
elif option == 3:
|
|
239
|
+
inline = get_input_string("Enter an ad-hoc dbt-SQL query (e.g. select * from {{ ref('my_model') }}): ")
|
|
240
|
+
if inline == "0":
|
|
241
|
+
complete_action()
|
|
242
|
+
return
|
|
243
|
+
elif option not in (1,):
|
|
244
|
+
complete_action()
|
|
245
|
+
return
|
|
246
|
+
no_introspect = get_input_true_false(
|
|
247
|
+
"Disable introspective warehouse queries — error instead of running one (--no-introspect)?", "n")
|
|
248
|
+
generate_info_schema = False
|
|
249
|
+
if self.dbt.engine == "dbt2":
|
|
250
|
+
generate_info_schema = get_input_true_false(
|
|
251
|
+
"Write the dbt Information Schema for querying project metadata "
|
|
252
|
+
"(--generate-info-schema, dbt2 only)?", "n")
|
|
253
|
+
self.dbt.compile(select=select, inline=inline, no_introspect=no_introspect,
|
|
254
|
+
generate_info_schema=generate_info_schema)
|
|
255
|
+
complete_action()
|
|
156
256
|
|
|
157
257
|
def _ensure_sqlfluff_config(self) -> bool:
|
|
158
258
|
"""Download .sqlfluff from the framework if it doesn't exist locally, and ensure correct
|
|
@@ -195,7 +295,8 @@ class DevelopmentMenu:
|
|
|
195
295
|
|
|
196
296
|
def _lint_menu(self) -> None:
|
|
197
297
|
clear()
|
|
198
|
-
|
|
298
|
+
is_dbt2 = self.linting.dbt_engine == "dbt2"
|
|
299
|
+
lint_label = "dbt lint" if is_dbt2 else "SQLFluff"
|
|
199
300
|
display_action_header(f"{lint_label} Linting Options")
|
|
200
301
|
menu_option(1, "find modified - Lint modified SQL files")
|
|
201
302
|
menu_option(2, "fix modified - Fix modified SQL files")
|
|
@@ -203,9 +304,12 @@ class DevelopmentMenu:
|
|
|
203
304
|
menu_option(4, "fix all - Fix all SQL files")
|
|
204
305
|
menu_option(5, "specific - Lint specific file")
|
|
205
306
|
menu_option(6, "refresh config- Re-download .sqlfluff from framework")
|
|
307
|
+
if is_dbt2:
|
|
308
|
+
menu_option(7, "changed - Lint only git-changed files (dbt lint --changed)")
|
|
309
|
+
menu_option(8, "format - Auto-format SQL files (dbt format/fmt)")
|
|
206
310
|
menu_option(0, "back - Return to development menu")
|
|
207
311
|
option = get_input_number("Choose an option: ")
|
|
208
|
-
if option in (1, 2, 3, 4, 5) and not self._ensure_sqlfluff_config():
|
|
312
|
+
if option in (1, 2, 3, 4, 5, 7, 8) and not self._ensure_sqlfluff_config():
|
|
209
313
|
complete_action()
|
|
210
314
|
return
|
|
211
315
|
if option == 1:
|
|
@@ -223,7 +327,20 @@ class DevelopmentMenu:
|
|
|
223
327
|
if name != "0":
|
|
224
328
|
path = name if name.endswith(".sql") else self.linting.resolve_model_path(name)
|
|
225
329
|
if path:
|
|
226
|
-
|
|
330
|
+
rules = exclude_rules = jinja_render_mode = None
|
|
331
|
+
if is_dbt2:
|
|
332
|
+
rules = get_input_string(
|
|
333
|
+
"Rule codes to enable, comma-separated (--rules, blank for config default): ",
|
|
334
|
+
allow_empty=True) or None
|
|
335
|
+
exclude_rules = get_input_string(
|
|
336
|
+
"Rule codes to disable, comma-separated (--exclude-rules, blank to skip): ",
|
|
337
|
+
allow_empty=True) or None
|
|
338
|
+
jinja_render_mode = get_input_string(
|
|
339
|
+
"Jinja render mode — symbolic/rendered/turbo (--jinja-render-mode, blank for default): ",
|
|
340
|
+
allow_empty=True) or None
|
|
341
|
+
self.linting.lint_file(file_path=path, fix=False, rules=rules,
|
|
342
|
+
exclude_rules=exclude_rules,
|
|
343
|
+
jinja_render_mode=jinja_render_mode)
|
|
227
344
|
else:
|
|
228
345
|
error_line(f"Could not find model '{name}' in models/ directory")
|
|
229
346
|
elif option == 6:
|
|
@@ -231,6 +348,27 @@ class DevelopmentMenu:
|
|
|
231
348
|
error_line("Download service not available")
|
|
232
349
|
else:
|
|
233
350
|
self.downloads.download_sqlfluff_config(profiles_dir=self.profiles_dir, dbt_project_dir=self.linting.project_dir)
|
|
351
|
+
elif option == 7 and is_dbt2:
|
|
352
|
+
fix = get_input_true_false("Also auto-fix the issues found?", "n")
|
|
353
|
+
self.linting.lint_changed(fix=fix)
|
|
354
|
+
elif option == 8 and is_dbt2:
|
|
355
|
+
name = get_input_string(
|
|
356
|
+
"Enter model name or file path to format, or leave blank for the whole project "
|
|
357
|
+
"('0' to cancel): ",
|
|
358
|
+
allow_empty=True)
|
|
359
|
+
if name == "0":
|
|
360
|
+
complete_action()
|
|
361
|
+
return
|
|
362
|
+
path = None
|
|
363
|
+
if name:
|
|
364
|
+
path = name if name.endswith(".sql") else self.linting.resolve_model_path(name)
|
|
365
|
+
if not path:
|
|
366
|
+
error_line(f"Could not find model '{name}' in models/ directory")
|
|
367
|
+
complete_action()
|
|
368
|
+
return
|
|
369
|
+
check = get_input_true_false(
|
|
370
|
+
"Dry run only — report formatting issues without writing changes (--check)?", "n")
|
|
371
|
+
self.linting.format_file(file_path=path, check=check)
|
|
234
372
|
complete_action()
|
|
235
373
|
|
|
236
374
|
def _autofix_menu(self) -> None:
|
|
@@ -5,7 +5,7 @@ from typing import Optional
|
|
|
5
5
|
|
|
6
6
|
import yaml
|
|
7
7
|
|
|
8
|
-
from datasecops_cli.utilities.display import info_line, error_line, success_line
|
|
8
|
+
from datasecops_cli.utilities.display import info_line, error_line, success_line, warning_line
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class DbtRunner:
|
|
@@ -48,11 +48,48 @@ class DbtRunner:
|
|
|
48
48
|
success_line(f"dbt {command} completed successfully")
|
|
49
49
|
return result
|
|
50
50
|
|
|
51
|
+
def _apply_modified_selector(self, args: list[str], select: str, exclude: str) -> None:
|
|
52
|
+
"""Append the state:modified+ selector if a baseline manifest.json exists at the
|
|
53
|
+
project root; otherwise warn explicitly and fall back to the normal selector
|
|
54
|
+
instead of silently building/running the whole project."""
|
|
55
|
+
if (self.project_dir / "manifest.json").exists():
|
|
56
|
+
args += ["--select", "state:modified+", "--state", str(self.project_dir)]
|
|
57
|
+
return
|
|
58
|
+
warning_line(
|
|
59
|
+
"No baseline manifest.json found — can't detect modified resources. "
|
|
60
|
+
"Falling back to the normal selector (run a full run/build first to create one)."
|
|
61
|
+
)
|
|
62
|
+
if select:
|
|
63
|
+
args += ["--select", select]
|
|
64
|
+
elif self.project_name:
|
|
65
|
+
args += ["--select", self.project_name]
|
|
66
|
+
|
|
67
|
+
def _append_info_schema_flags(self, args: list[str], generate_info_schema: bool,
|
|
68
|
+
static_analysis_strict: bool, command: str) -> None:
|
|
69
|
+
"""--generate-info-schema and --static-analysis strict are dbt2-only; warn and
|
|
70
|
+
skip them on dbt Core instead of sending a flag dbt Core will reject."""
|
|
71
|
+
if not (generate_info_schema or static_analysis_strict):
|
|
72
|
+
return
|
|
73
|
+
if self.engine != "dbt2":
|
|
74
|
+
warning_line(
|
|
75
|
+
f"--generate-info-schema/--static-analysis require the dbt2 engine — "
|
|
76
|
+
f"skipping for this `dbt {command}`."
|
|
77
|
+
)
|
|
78
|
+
return
|
|
79
|
+
if generate_info_schema:
|
|
80
|
+
args.append("--generate-info-schema")
|
|
81
|
+
if static_analysis_strict:
|
|
82
|
+
# Independent of --generate-info-schema: without it, the info schema (if also
|
|
83
|
+
# requested) only has YAML-declared columns and no column-level lineage.
|
|
84
|
+
args += ["--static-analysis", "strict"]
|
|
85
|
+
|
|
51
86
|
def run(self, select: str = None, exclude: str = None, full_refresh: bool = False,
|
|
52
|
-
modified_only: bool = False
|
|
87
|
+
modified_only: bool = False, empty: bool = False,
|
|
88
|
+
generate_info_schema: bool = False,
|
|
89
|
+
static_analysis_strict: bool = False) -> subprocess.CompletedProcess:
|
|
53
90
|
args = [f"--target={self.target}"]
|
|
54
|
-
if modified_only
|
|
55
|
-
args
|
|
91
|
+
if modified_only:
|
|
92
|
+
self._apply_modified_selector(args, select, exclude)
|
|
56
93
|
elif select:
|
|
57
94
|
args += ["--select", select]
|
|
58
95
|
elif self.project_name:
|
|
@@ -61,20 +98,39 @@ class DbtRunner:
|
|
|
61
98
|
args += ["--exclude", exclude]
|
|
62
99
|
if full_refresh:
|
|
63
100
|
args.append("--full-refresh")
|
|
101
|
+
if empty:
|
|
102
|
+
# NOTE: not a no-write dry run — dbt still executes each model's SQL against
|
|
103
|
+
# the warehouse with refs/sources limited to zero rows, so table models are
|
|
104
|
+
# materialized with empty/reduced data, replacing their current contents.
|
|
105
|
+
# Use it to validate dependencies cheaply, not to preview a run safely.
|
|
106
|
+
args.append("--empty")
|
|
107
|
+
self._append_info_schema_flags(args, generate_info_schema, static_analysis_strict, "run")
|
|
64
108
|
result = self._run_command("run", args)
|
|
65
|
-
|
|
109
|
+
if result.returncode == 0:
|
|
110
|
+
self._copy_manifest()
|
|
66
111
|
return result
|
|
67
112
|
|
|
68
|
-
def build(self, select: str = None, exclude: str = None
|
|
113
|
+
def build(self, select: str = None, exclude: str = None, full_refresh: bool = False,
|
|
114
|
+
modified_only: bool = False, empty: bool = False,
|
|
115
|
+
generate_info_schema: bool = False,
|
|
116
|
+
static_analysis_strict: bool = False) -> subprocess.CompletedProcess:
|
|
69
117
|
args = [f"--target={self.target}"]
|
|
70
|
-
if
|
|
118
|
+
if modified_only:
|
|
119
|
+
self._apply_modified_selector(args, select, exclude)
|
|
120
|
+
elif select:
|
|
71
121
|
args += ["--select", select]
|
|
72
122
|
elif self.project_name:
|
|
73
123
|
args += ["--select", self.project_name]
|
|
74
124
|
if exclude:
|
|
75
125
|
args += ["--exclude", exclude]
|
|
126
|
+
if full_refresh:
|
|
127
|
+
args.append("--full-refresh")
|
|
128
|
+
if empty:
|
|
129
|
+
args.append("--empty")
|
|
130
|
+
self._append_info_schema_flags(args, generate_info_schema, static_analysis_strict, "build")
|
|
76
131
|
result = self._run_command("build", args)
|
|
77
|
-
|
|
132
|
+
if result.returncode == 0:
|
|
133
|
+
self._copy_manifest()
|
|
78
134
|
return result
|
|
79
135
|
|
|
80
136
|
def test(self, select: str = None) -> subprocess.CompletedProcess:
|
|
@@ -85,12 +141,21 @@ class DbtRunner:
|
|
|
85
141
|
args += ["--select", self.project_name]
|
|
86
142
|
return self._run_command("test", args)
|
|
87
143
|
|
|
88
|
-
def compile(self, select: str = None
|
|
144
|
+
def compile(self, select: str = None, inline: str = None, no_introspect: bool = False,
|
|
145
|
+
generate_info_schema: bool = False) -> subprocess.CompletedProcess:
|
|
89
146
|
args = [f"--target={self.target}"]
|
|
90
|
-
if
|
|
147
|
+
if inline:
|
|
148
|
+
# Compile an arbitrary ad-hoc dbt-SQL query instead of a project node.
|
|
149
|
+
args += ["--inline", inline]
|
|
150
|
+
elif select:
|
|
91
151
|
args += ["--select", select]
|
|
92
152
|
elif self.project_name:
|
|
93
153
|
args += ["--select", self.project_name]
|
|
154
|
+
if no_introspect:
|
|
155
|
+
# Disable introspective queries against the warehouse; dbt errors instead
|
|
156
|
+
# of running one if a resource's definition requires it.
|
|
157
|
+
args.append("--no-introspect")
|
|
158
|
+
self._append_info_schema_flags(args, generate_info_schema, False, "compile")
|
|
94
159
|
return self._run_command("compile", args)
|
|
95
160
|
|
|
96
161
|
def deps(self) -> subprocess.CompletedProcess:
|
|
@@ -158,11 +223,19 @@ class DbtRunner:
|
|
|
158
223
|
|
|
159
224
|
def retry(self) -> subprocess.CompletedProcess:
|
|
160
225
|
result = self._run_command("retry", [f"--target={self.target}"])
|
|
161
|
-
|
|
226
|
+
if result.returncode == 0:
|
|
227
|
+
self._copy_manifest()
|
|
162
228
|
return result
|
|
163
229
|
|
|
164
|
-
def parse(self
|
|
165
|
-
|
|
230
|
+
def parse(self, no_partial_parse: bool = False,
|
|
231
|
+
generate_info_schema: bool = False) -> subprocess.CompletedProcess:
|
|
232
|
+
args = []
|
|
233
|
+
if no_partial_parse:
|
|
234
|
+
# Force a full re-parse of the project instead of only recently
|
|
235
|
+
# changed files.
|
|
236
|
+
args.append("--no-partial-parse")
|
|
237
|
+
self._append_info_schema_flags(args, generate_info_schema, False, "parse")
|
|
238
|
+
return self._run_command("parse", args)
|
|
166
239
|
|
|
167
240
|
def run_operation(self, macro: str, args_str: str = None) -> subprocess.CompletedProcess:
|
|
168
241
|
cmd_args = [f"--target={self.target}"]
|