Skip to content

Commit 74b4c29

Browse files
authored
pipelines: Add auto-selection for single pipeline in pipelines run and dry-run commands (#3243)
### **Changes** Enhanced `pipelines run` and `dry-run` commands to automatically select a pipeline when only one pipeline exists in the bundle and no arguments are specified. **Key changes in `cmd/pipelines/utils.go`:** - Modified `resolveRunArgument` function to auto-select pipeline when `len(args) == 0` and only one runnable resource (pipeline) exists - Maintains existing behavior for multiple resources (prompts for selection) and explicit arguments - Based on existing `resolveRunArgument` from `cmd/bundle/run.go` but tailored for pipeline workflows ### **Tests** Tests added to auto-select the single pipeline in the resources file in the tests Kept tests to still run both with and without specifying KEY (with and without auto-selection) Follow-up for pipeline open auto-selection: #3258
1 parent 78c0234 commit 74b4c29

File tree

15 files changed

+75
-29
lines changed

15 files changed

+75
-29
lines changed

acceptance/pipelines/dry-run/dry-run-pipeline/output.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ Updating deployment state...
66
Deployment complete!
77

88
=== Dry running pipeline, should have validate_only set to true
9+
>>> [PIPELINES] dry-run
10+
Update URL: [DATABRICKS_URL]/#joblist/pipelines/[UUID]/updates/[UUID]
11+
12+
{
13+
"body": {
14+
"validate_only": true
15+
},
16+
"method": "POST",
17+
"path": "/api/2.0/pipelines/[UUID]/updates"
18+
}
19+
20+
=== Dry running pipeline with KEY, expect same output as without KEY
921
>>> [PIPELINES] dry-run my_pipeline
1022
Update URL: [DATABRICKS_URL]/#joblist/pipelines/[UUID]/updates/[UUID]
1123

acceptance/pipelines/dry-run/dry-run-pipeline/script

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@ print_requests() {
66
trace $PIPELINES deploy
77
rm out.requests.txt
88
title "Dry running pipeline, should have validate_only set to true"
9+
trace $PIPELINES dry-run
10+
print_requests
11+
12+
title "Dry running pipeline with KEY, expect same output as without KEY"
913
trace $PIPELINES dry-run my_pipeline
1014
print_requests

acceptance/pipelines/dry-run/no-wait/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Updating deployment state...
66
Deployment complete!
77

88
=== Dry running pipeline with --no-wait flag
9-
>>> [PIPELINES] dry-run my_pipeline --no-wait
9+
>>> [PIPELINES] dry-run --no-wait
1010
Update URL: [DATABRICKS_URL]/#joblist/pipelines/[UUID]/updates/[UUID]
1111

1212
<EOL>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
trace $PIPELINES deploy
22
title "Dry running pipeline with --no-wait flag"
3-
trace $PIPELINES dry-run my_pipeline --no-wait
3+
trace $PIPELINES dry-run --no-wait
44
# This printf is here to fix the whitespace linter error (ensures exactly one newline at end)
55
printf "<EOL>\n"

acceptance/pipelines/dry-run/restart/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Updating deployment state...
66
Deployment complete!
77

88
=== Dry running pipeline with --restart flag, should stop the current pipeline and start a new run
9-
>>> [PIPELINES] dry-run my_pipeline --restart
9+
>>> [PIPELINES] dry-run --restart
1010
Update URL: [DATABRICKS_URL]/#joblist/pipelines/[UUID]/updates/[UUID]
1111

1212

acceptance/pipelines/dry-run/restart/script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ trace $PIPELINES deploy
77
rm out.requests.txt
88

99
title "Dry running pipeline with --restart flag, should stop the current pipeline and start a new run"
10-
trace $PIPELINES dry-run my_pipeline --restart
10+
trace $PIPELINES dry-run --restart
1111
trace print_requests

acceptance/pipelines/run/no-wait/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Updating deployment state...
66
Deployment complete!
77

88
=== test --no-wait flag
9-
>>> [PIPELINES] run my_pipeline --no-wait
9+
>>> [PIPELINES] run --no-wait
1010
Update URL: [DATABRICKS_URL]/#joblist/pipelines/[UUID]/updates/[UUID]
1111

1212
<EOL>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
trace $PIPELINES deploy
22
title "test --no-wait flag"
3-
trace $PIPELINES run my_pipeline --no-wait
3+
trace $PIPELINES run --no-wait
44
# This printf is here to fix the whitespace linter error (ensures exactly one newline at end)
55
printf "<EOL>\n"

acceptance/pipelines/run/refresh-flags/output.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Updating deployment state...
66
Deployment complete!
77

88
=== Running pipeline with --refresh-all flag
9-
>>> [PIPELINES] run my_pipeline --refresh-all
9+
>>> [PIPELINES] run --refresh-all
1010
Update URL: [DATABRICKS_URL]/#joblist/pipelines/[UUID]/updates/[UUID]
1111

1212

@@ -18,7 +18,7 @@ Update URL: [DATABRICKS_URL]/#joblist/pipelines/[UUID]/updates/[UUID]
1818
}
1919

2020
=== Running pipeline with --refresh flag and specific tables
21-
>>> [PIPELINES] run my_pipeline --refresh table1,table2
21+
>>> [PIPELINES] run --refresh table1,table2
2222
Update URL: [DATABRICKS_URL]/#joblist/pipelines/[UUID]/updates/[UUID]
2323

2424

@@ -35,7 +35,7 @@ Update URL: [DATABRICKS_URL]/#joblist/pipelines/[UUID]/updates/[UUID]
3535
}
3636

3737
=== Running pipeline with --full-refresh-all flag
38-
>>> [PIPELINES] run my_pipeline --full-refresh-all
38+
>>> [PIPELINES] run --full-refresh-all
3939
Update URL: [DATABRICKS_URL]/#joblist/pipelines/[UUID]/updates/[UUID]
4040

4141

@@ -49,7 +49,7 @@ Update URL: [DATABRICKS_URL]/#joblist/pipelines/[UUID]/updates/[UUID]
4949
}
5050

5151
=== Running pipeline with --full-refresh flag and specific tables
52-
>>> [PIPELINES] run my_pipeline --full-refresh table1,table2
52+
>>> [PIPELINES] run --full-refresh table1,table2
5353
Update URL: [DATABRICKS_URL]/#joblist/pipelines/[UUID]/updates/[UUID]
5454

5555

acceptance/pipelines/run/refresh-flags/script

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ rm out.requests.txt
88

99
title "Running pipeline with --refresh-all flag"
1010
# Should perform a full graph update (empty refresh_selection and full_refresh_selection implies refresh_all)
11-
trace $PIPELINES run my_pipeline --refresh-all
11+
trace $PIPELINES run --refresh-all
1212
trace print_requests
1313

1414
title "Running pipeline with --refresh flag and specific tables"
1515
# Should refresh only the specified tables
16-
trace $PIPELINES run my_pipeline --refresh table1,table2
16+
trace $PIPELINES run --refresh table1,table2
1717
trace print_requests
1818

1919
title "Running pipeline with --full-refresh-all flag"
2020
# Should have full refresh set to true
21-
trace $PIPELINES run my_pipeline --full-refresh-all
21+
trace $PIPELINES run --full-refresh-all
2222
trace print_requests
2323

2424
title "Running pipeline with --full-refresh flag and specific tables"
2525
# Should reset and recompute only the specified tables
26-
trace $PIPELINES run my_pipeline --full-refresh table1,table2
26+
trace $PIPELINES run --full-refresh table1,table2
2727
trace print_requests

0 commit comments

Comments
 (0)