mssparkutils.notebook.exit() doesn't seem to work correctly in pipeline

TerriblyVexed 51 Reputation points
2021-11-29T23:50:16.207+00:00

I have the following Spark Notebook

CDMList = []
DBList = []

%%pyspark

from notebookutils import mssparkutils

set1 = set(CDMList)
set2 = set(DBList)

missing = list(sorted(set1 - set2))
#print(missing)
mssparkutils.notebook.exit(missing)

When I run it by itself it works.

ExitValue: ['LocalAccountCoverage', 'LocalAccountSubject', 'LocalActivityDefinitionObservationRequirement']

I am calling it in a pipeline in Synapse. The Output has exitValue of "[]" when it should have the above. Just to be sure I added a Set variable activity and put in the following:

@activity('CompareLists').output.status.Output.result.exitValue

It sets it to "[]" as well.

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,042 questions
0 comments No comments
{count} votes

Accepted answer
  1. PRADEEPCHEEKATLA 90,246 Reputation points
    2021-12-01T12:29:11.437+00:00

    Hello @TerriblyVexed ,

    To pass parameters, please make sure the cell has marked to parameter cell as shown below.

    154147-image.png

    Try to split the code into two cells and first cell should be marked as toggle parameter cell and modify the code as shown below:

    Cell1:[Marked as parameters]

    CDMList = ''  
    DBList = ''  
    

    Cell2:

    from notebookutils import mssparkutils  
    set1 = set(CDMList.split(','))  
    set2 = set(DBList.split(','))  
    missing = list(sorted(set1 - set2))  
    #print(missing)  
    mssparkutils.notebook.exit(missing)  
    

    154153-image.png

    Try to remove the single quotes in the parameters.

    Note: If you use the parameters with the single quotes the excepted output: "exitValue": "[\"'LocalAccountCoverage'\", \"'LocalAccountSubject'\", \"'LocalActivityDefinitionObservationRequirement'\"]",

    154172-image.png

    Now you will see the excepted output as shown below:

    154117-image.png

    Hope this will help. Please let us know if any further queries.


    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of [Q&A Volunteer Moderators][50}
    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. PRADEEPCHEEKATLA 90,246 Reputation points
    2021-11-30T11:14:05.943+00:00

    Hello @TerriblyVexed ,

    Thanks for the question and using MS Q&A platform.

    Your question is not clear enough, because if you look at the Spark Notebook provided above don't have any values in CDMList and DBList and not sure how the it returns the ExitValue: ['LocalAccountCoverage', 'LocalAccountSubject', 'LocalActivityDefinitionObservationRequirement'].

    Created a Notebook6 with empty values in CDMList and DBList returns output is Null.

    153639-image.png

    Pipeline associated with Notebook6 which has empty values returns @activity('Notebook1').output.status.Output.result.exitValue is Null.

    153656-image.png

    Created a Notebook7 with values in CDMList returns output is ['LocalAccountCoverage', 'LocalAccountSubject', 'LocalActivityDefinitionObservationRequirement']

    153684-image.png

    Pipeline associated with Notebook7 with values in CDMList returnss @activity('Notebook1').output.status.Output.result.exitValue is ['LocalAccountCoverage', 'LocalAccountSubject', 'LocalActivityDefinitionObservationRequirement']

    153733-image.png

    Hope this will help. Please let us know if any further queries.

    ------------------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.