Forum Discussion
Referencing notebook exit value as a variable in a data pipeline
- 2 years ago
For my own implementation the delimited string just wasnt flexible enough - so here's a version using a JSON object as the notebook return value:
Notebook pyspark:
lResult={"numUpdated":10,"message":"success","fruit":["apple","orange","grapes"]} mssparkutils.notebook.exit(str(lResult))Expression for varMessageStr:
Anonymous(activity('Test Notebook').output.result.exitValue).messageExpression for varNumUpdatedInt:
INT(json(activity('Test Notebook').output.result.exitValue).numUpdated)Expression for varFruitArray:
Anonymous(activity('Test Notebook').output.result.exitValue).fruit
I also struggled, until I tried ignoring the expression builder syntax errors and just ran my pipeline. I was able to get the following to work by using a delimited string as the notebook return value.
Notebook pyspark:
lResult="returnValueOne=25|returnValueTwo=abc|returnValueThree=19"
mssparkutils.notebook.exit(str(lResult))
Expression for varAllReturnValuesArray
@split(activity('Test Notebook').output.result.exitValue,'|')
Expression for varReturnValueOneString
@last(split(first(split(activity('Test Notebook').output.result.exitValue,'|')),'='))
Expression for varReturnValueTwoString
@last(split(split(activity('Test Notebook').output.result.exitValue,'|')[1],'='))
For my own implementation the delimited string just wasnt flexible enough - so here's a version using a JSON object as the notebook return value:
Notebook pyspark:
lResult={"numUpdated":10,"message":"success","fruit":["apple","orange","grapes"]}
mssparkutils.notebook.exit(str(lResult))
Expression for varMessageStr:
Anonymous(activity('Test Notebook').output.result.exitValue).message
Expression for varNumUpdatedInt:
INT(json(activity('Test Notebook').output.result.exitValue).numUpdated)
Expression for varFruitArray:
Anonymous(activity('Test Notebook').output.result.exitValue).fruit