Skip to content

Commit 008b72a

Browse files
authored
pipelines: add generate command (#4251)
## Changes Add `databricks pipelines generate` command that generates DAB resources from SDP YAML. `generate` command is tailored to `lakeflow-pipelines` template where `src` folder contains pipeline folders, for example: ``` ├── databricks.yml ├── pyproject.toml ├── README.md ├── resources │   ├── my_pipeline.pipeline.yml │   └── my_pipeline.job.yml └── src └── my_pipeline ├── spark-pipeline.yml └── transformations ├── example_python_materialized_view.py └── example_sql_materialized_view.sql ``` ### Usage ``` $ databricks pipelines generate src/my_pipeline ``` Where `src/my_pipeline/sdp-pipeline.yml`: ```yaml name: My Pipeline storage: file:///Users/foo/bar/baz libraries: - glob: include: transformations/** ``` Produces `resources/my_pipeline.pipeline.yml`: ```yaml resources: pipelines: my_pipeline: name: My Pipeline catalog: ${var.catalog} schema: ${var.schema} root_path: ../src/my_pipeline serverless: true libraries: - glob: include: ../src/my_pipeline/transformations/** environment: dependencies: - --editable ${workspace.file_path} ``` ## Why It allows creating DAB YAML for Spark Declarative Pipelines ## Tests Acceptance and unit tests
1 parent 6d99db8 commit 008b72a

File tree

27 files changed

+661
-0
lines changed

27 files changed

+661
-0
lines changed

acceptance/pipelines/databricks-cli-help/output.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Available Commands
2222
deploy Deploy pipelines
2323
destroy Destroy a pipelines project
2424
dry-run Validate correctness of the pipeline's graph
25+
generate Generate pipeline configuration
2526
history Retrieve past runs for a pipeline
2627
init Initialize a new pipelines project
2728
logs Retrieve events for a pipeline

acceptance/pipelines/generate/bad-path/out.test.toml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
>>> errcode [CLI] pipelines generate --existing-pipeline-dir /tmp/foo
3+
Error: please make sure the directory is located in side 'src/' (for example 'src/my_pipeline'), got: [path]
4+
5+
Exit code: 1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export ENABLE_PIPELINES_CLI=1
2+
3+
trace errcode $CLI pipelines generate --existing-pipeline-dir /tmp/foo
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# printed paths are different on Windows
2+
3+
[[Repls]]
4+
Old = "got: .*"
5+
New = "got: [path]"

acceptance/pipelines/generate/discover-spark-pipeline-yml/out.test.toml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Generated pipeline configuration: resources/my_pipeline.pipeline.yml
2+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
resources:
2+
pipelines:
3+
my_pipeline:
4+
name: My Pipeline
5+
catalog: ${var.catalog}
6+
schema: ${var.schema}
7+
root_path: ../src/my_pipeline
8+
serverless: true
9+
libraries:
10+
- glob:
11+
include: ../src/my_pipeline/transformations/**
12+
environment:
13+
dependencies:
14+
- --editable ${workspace.file_path}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export ENABLE_PIPELINES_CLI=1
2+
3+
$CLI pipelines generate --existing-pipeline-dir src/my_pipeline
4+
5+
mv resources output/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: My Pipeline
2+
storage: file:///Users/foo/bar/baz
3+
libraries:
4+
- glob:
5+
include: transformations/**

0 commit comments

Comments
 (0)