<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Converting a text widget to a list in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/converting-a-text-widget-to-a-list/m-p/17353#M11380</link>
    <description>&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Been working on some parallel notebook code, which I have ported to python from the example on the DB website and added some exception handling and that works fine. What I would like to do is paramterise the input but am not succeeding as the function does not seem to accept that what I am passing in is a list, even though if I check the type of the variable it is indeed a list&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;from concurrent.futures import ThreadPoolExecutor
class NotebookData:
    
    def __init__(self, path, timeout, parameters=None, retry=0):
        self.path = path
        self.timeout = timeout
        self.parameters = parameters
        self.retry = retry
        
    def submitNotebook(notebook):
        print("Running notebook %s" % notebook.path)
        try:
            if (notebook.parameters):
                return dbutils.notebook.run(notebook.path, notebook.timeout, notebook.parameters)
            else:
                return dbutils.notebook.run(notebook.path, notebook.timeout)
        except Exception:
            if notebook.retry &amp;lt; 1:
                raise
            print("Retrying notebook %s" % notebook.path)
            notebook.retry = notebook.retry - 1
            submitNotebook(notebook)
            
    def parallelNotebooks(notebooks, numInParallel):
# If you create too many notebooks in parallel the driver may crash when you submit all of the jobs at once. 
# This code limits the number of parallel notebooks.
        with ThreadPoolExecutor(max_workers=numInParallel) as ec:
            return [ec.submit(NotebookData.submitNotebook, notebook) for notebook in notebooks]
        
notebooks = noteBookConfig
         #[NotebookData("Sub1", 1200), NotebookData("Sub2", 1200, retry=2)]
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
print (type(notebooks))
print(notebooks)
res = NotebookData.parallelNotebooks(notebooks, 2)
result = [f.result(timeout=3600) for f in res] # This is a blocking call.
print(result)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The commented out line (31) is the format of the list, noteBookConfig is the list I am passing in. That is created like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import pandas as pd
dbutils.widgets.text("configs", "", "Notebook Config")
&amp;nbsp;
noteBookConfig= dbutils.widgets.get("configs")
noteBookConfig = list(noteBookConfig.split(" "))
print (noteBookConfig)
print (type(noteBookConfig))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any help greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Jun 2022 14:20:41 GMT</pubDate>
    <dc:creator>labromb</dc:creator>
    <dc:date>2022-06-17T14:20:41Z</dc:date>
    <item>
      <title>Converting a text widget to a list</title>
      <link>https://community.databricks.com/t5/data-engineering/converting-a-text-widget-to-a-list/m-p/17353#M11380</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Been working on some parallel notebook code, which I have ported to python from the example on the DB website and added some exception handling and that works fine. What I would like to do is paramterise the input but am not succeeding as the function does not seem to accept that what I am passing in is a list, even though if I check the type of the variable it is indeed a list&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;from concurrent.futures import ThreadPoolExecutor
class NotebookData:
    
    def __init__(self, path, timeout, parameters=None, retry=0):
        self.path = path
        self.timeout = timeout
        self.parameters = parameters
        self.retry = retry
        
    def submitNotebook(notebook):
        print("Running notebook %s" % notebook.path)
        try:
            if (notebook.parameters):
                return dbutils.notebook.run(notebook.path, notebook.timeout, notebook.parameters)
            else:
                return dbutils.notebook.run(notebook.path, notebook.timeout)
        except Exception:
            if notebook.retry &amp;lt; 1:
                raise
            print("Retrying notebook %s" % notebook.path)
            notebook.retry = notebook.retry - 1
            submitNotebook(notebook)
            
    def parallelNotebooks(notebooks, numInParallel):
# If you create too many notebooks in parallel the driver may crash when you submit all of the jobs at once. 
# This code limits the number of parallel notebooks.
        with ThreadPoolExecutor(max_workers=numInParallel) as ec:
            return [ec.submit(NotebookData.submitNotebook, notebook) for notebook in notebooks]
        
notebooks = noteBookConfig
         #[NotebookData("Sub1", 1200), NotebookData("Sub2", 1200, retry=2)]
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
print (type(notebooks))
print(notebooks)
res = NotebookData.parallelNotebooks(notebooks, 2)
result = [f.result(timeout=3600) for f in res] # This is a blocking call.
print(result)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The commented out line (31) is the format of the list, noteBookConfig is the list I am passing in. That is created like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import pandas as pd
dbutils.widgets.text("configs", "", "Notebook Config")
&amp;nbsp;
noteBookConfig= dbutils.widgets.get("configs")
noteBookConfig = list(noteBookConfig.split(" "))
print (noteBookConfig)
print (type(noteBookConfig))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any help greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2022 14:20:41 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/converting-a-text-widget-to-a-list/m-p/17353#M11380</guid>
      <dc:creator>labromb</dc:creator>
      <dc:date>2022-06-17T14:20:41Z</dc:date>
    </item>
  </channel>
</rss>

