Skip to content

Commit 82d2423

Browse files
author
jamiesjc
committed
Fix base properties scope for subflows when generating YAML files.
1 parent bfbc6d0 commit 82d2423

File tree

8 files changed

+76
-1
lines changed

8 files changed

+76
-1
lines changed

CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,4 @@ The following were contributed by Chris Li.
154154

155155
The following were contributed by Jamie Sun. Thanks, Jamie!
156156
* `Add conditional workflow feature`
157+
* `Fix base properties scope for subflows when generating YAML files`

VERSIONS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ the License.
1717
Note that the LinkedIn build system occasionally requires that we skip a
1818
version bump, so you will see a few skipped version numbers in the list below.
1919

20+
0.14.27
21+
* Fix base properties scope for subflows when generating YAML files
22+
2023
0.14.26
2124
* Bump version to match li-hadoop-plugin MP
2225

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
org.gradle.daemon=true
2-
version=0.14.26
2+
version=0.14.27
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
nodes:
2+
- name: embeddedFlow
3+
type: noop
4+
dependsOn:
5+
- embeddedFlow1
6+
- name: embeddedFlow1
7+
type: flow
8+
nodes:
9+
- name: embeddedFlow1
10+
type: noop
11+
dependsOn:
12+
- shellEcho
13+
- name: shellEcho
14+
type: command
15+
config:
16+
command: echo "This is an echoed text from embeddedFlow1."
17+
user.to.proxy: foo
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
azkaban-flow-version: 2.0
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
:hadoop-plugin-test:test_embeddedFlowWithBaseProperties
2+
Running test for the file positive/embeddedFlowWithBaseProperties.gradle
3+
Hadoop DSL static checker PASSED
4+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
buildscript {
2+
repositories {
3+
jcenter()
4+
}
5+
dependencies {
6+
classpath files("${project.pluginTestDir}/hadoop-plugin-${project.version}.jar", "${project.pluginTestDir}/hadoop-plugin-${project.version}-SNAPSHOT.jar")
7+
// Must manually specify snakeyaml for testing, not required for users
8+
classpath 'org.yaml:snakeyaml:1.18'
9+
}
10+
}
11+
12+
apply plugin: com.linkedin.gradle.hadoop.HadoopPlugin
13+
14+
// Test an embedded flow with base properties set in the job for Flow 2.0
15+
16+
hadoop {
17+
buildPath "jobs/embeddedFlowWithBaseProperties"
18+
cleanPath false
19+
20+
generateYamlOutput true
21+
22+
workflow('embeddedFlow') {
23+
propertySet('common') {
24+
set properties: ['user.to.proxy' : 'foo']
25+
}
26+
27+
workflow('embeddedFlow1') {
28+
commandJob('shellEcho') {
29+
baseProperties 'common'
30+
uses 'echo "This is an echoed text from embeddedFlow1."'
31+
}
32+
targets 'shellEcho'
33+
}
34+
35+
targets 'embeddedFlow1'
36+
}
37+
}

hadoop-plugin/src/main/groovy/com/linkedin/gradle/azkaban/AzkabanDslYamlCompiler.groovy

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,14 @@ class AzkabanDslYamlCompiler extends BaseCompiler {
234234
* @return Map representing workflow to be output in yaml file.
235235
*/
236236
Map yamlizeWorkflow(Workflow workflow, boolean isSubflow) {
237+
// Save the last scope information
238+
NamedScope oldParentScope = this.parentScope;
239+
String oldParentDirectory = this.parentDirectory;
240+
241+
// Set the new parent scope information
242+
this.parentScope = workflow.scope;
243+
this.parentDirectory = "${this.parentDirectory}/${workflow.name}";
244+
237245
Map yamlizedWorkflow = [:];
238246

239247
// Add workflow name if subflow
@@ -266,6 +274,10 @@ class AzkabanDslYamlCompiler extends BaseCompiler {
266274
yamlizedWorkflow["nodes"] = nodes;
267275
}
268276

277+
// Restore the last parent scope
278+
this.parentScope = oldParentScope;
279+
this.parentDirectory = oldParentDirectory;
280+
269281
return yamlizedWorkflow;
270282
}
271283

0 commit comments

Comments
 (0)