Forum Discussion
Nested notebooks calls: Cannot identify Lakehouse files from child notebook
- 1 year ago
Hi All,
Thank you for the suggestions. I did more exploration based on all the recommendations and got this worked.
The changes made
1. Made use of notebookutils to do nested notebook calls and lakehouse file operations.
2. File path was changed to Relative path for Spark starting from File/ in all notebookutils methods.
3. Changed file related operations with spark commands like
spark.read.format("xml").option("rowTag","data").load(filepath)
df.write.format("parquet").load(save file)
Hi prathijp ,
Thanks for using Microsoft Fabric Community,
Thanks for the update.
Just a quick clarification on the usage of notebookutils.notebook.run(): when passing parameters, please make sure to provide them as a single dictionary object. The syntax you're currently using is interpreted incorrectly and can result in empty values being passed to the child notebook, which leads to the IllegalArgumentException you're seeing.
Corrected syntax:
notebookutils.notebook.run(
NB_xmlToParquet,
300,
{
"xml_data_path": dataRef,
"xml_struct": dataParseCodeRef,
"saveParsedFile": saveParsedFile
}
)
Also, ensure that you're reading the parameters in the child notebook using:
xml_data_path = notebookutils.notebook.get_context().notebook_param("xml_data_path")
This should help ensure the file path is passed and recognized correctly during execution.
Let us know if you’re still seeing issues after updating the syntax.
Also thanks to ObungiNiels for your valuable response.
Hope this helps. Please reach out for further assistance.
If this post helps, then please consider to Accept as the solution to help the other members find it more quickly and a kudos would be appreciated.
Thank you.
Thank you for the reply.
I tried using the below to retrieve the parameters.
xml_data_pathRef: Files/Landing/CTC_SM.xml[Errno 2] No such file or directory: 'Files/Landing/CTC_SM.xml' ---------------------------------------------------------------------------FileNotFoundError Traceback (most recent call last)Cell In[5], line 13 10 saveParsedFile = saveParquetFile.replace(removeFolderHeader,"") 12 if xml_struct == "xml_struct_01": ---> 13 xml_struct_01(xml_data_pathRef,saveParsedFile) Cell In[4], line 11, in xml_struct_01(xml_data_pathRef, saveParsedFile) 7 notebookutils.fs.head(xml_data_pathRef, 3000) 8 # Read the XML file content ---> 11 with open(xml_data_pathRef, "r", encoding="utf-8") as file: 12 xml_data = file.read() 14 # Parse XML 15 #root = ET.fromstring(xml_data)