<?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 Re: How do I pass kwargs to wheel method? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-do-i-pass-kwargs-to-wheel-method/m-p/12307#M7128</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for you answer.&lt;/P&gt;&lt;P&gt;Yes, what you say is correct, we must use argparse to get the keyword arguments.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Though, doing argparse outside of the entry point method didn't work for me.&lt;/P&gt;&lt;P&gt;I had to do it inside the method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have no idea why? I will try it again in an hour, for now I was happy to be able to get it working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will select your answer. &lt;/P&gt;&lt;P&gt;I will comment back here if it can be down outside of the entry method.&lt;/P&gt;</description>
    <pubDate>Wed, 27 Jul 2022 12:54:16 GMT</pubDate>
    <dc:creator>ACK</dc:creator>
    <dc:date>2022-07-27T12:54:16Z</dc:date>
    <item>
      <title>How do I pass kwargs to wheel method?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-pass-kwargs-to-wheel-method/m-p/12305#M7126</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a method named main it takes **kwargs as a parameter. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;def main(**kwargs):
    parameterOne = kwargs["param-one"]
    parameterTwo = kwargs["param-two"]
    parameterThree = kwargs["param-optional-one"] if "param-optional-one" in kwargs else None
    parameterFour = kwargs["param-optional-two"] if "param-optional-two" in kwargs else None&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have declared it as an entry_point in setup&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;entry_points={
        'console_scripts': [
            'main=ETL.V1:main'
        ]
    },&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am passing keyword arguments in task&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;"entry_point": "main",
                    "named_parameters": {
                        "param-one": "test",
                        "param-two": "test two"
                    }&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;when I run the job it goes into main method, but fails on the very first line&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;KeyError: 'param-one'
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
&amp;lt;command--1&amp;gt; in &amp;lt;module&amp;gt;
     16 if entry:
     17   # Load and execute the entrypoint, assumes no parameters
---&amp;gt; 18   entry[0].load()()
     19 else:
     20   import ETL.V1
&amp;nbsp;
/databricks/python/lib/python3.8/site-packages/ETL/V1.py in main(**kwargs)
      8     for i, v in kwargs.items():
      9         print("    ", i, ": ", v)
---&amp;gt; 10     parameterOne = kwargs['param-one']
     11     parameterTwo = kwargs['param-two']
&amp;nbsp;
KeyError: 'param-one'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The keyword arguments are not being passed or I am doing something wrong?&lt;/P&gt;&lt;P&gt;I tried to see if anything is in kwargs, however that didn't print anything in the task output just the error above was displayed. So, I can't really tell if anything is in kwargs or not.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jul 2022 08:12:36 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-pass-kwargs-to-wheel-method/m-p/12305#M7126</guid>
      <dc:creator>ACK</dc:creator>
      <dc:date>2022-07-27T08:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass kwargs to wheel method?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-pass-kwargs-to-wheel-method/m-p/12306#M7127</link>
      <description>&lt;P&gt;it is command-line parameters so it is like &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;---param-one=test&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;you can test it with ArgumentParser&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;from argparse import ArgumentParser
&amp;nbsp;
parser = ArgumentParser()
parser.add_argument("--param-one", dest="parameterOne")
&amp;nbsp;
args = parser.parse_args()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jul 2022 10:41:17 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-pass-kwargs-to-wheel-method/m-p/12306#M7127</guid>
      <dc:creator>Hubert-Dudek</dc:creator>
      <dc:date>2022-07-27T10:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass kwargs to wheel method?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-pass-kwargs-to-wheel-method/m-p/12307#M7128</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for you answer.&lt;/P&gt;&lt;P&gt;Yes, what you say is correct, we must use argparse to get the keyword arguments.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Though, doing argparse outside of the entry point method didn't work for me.&lt;/P&gt;&lt;P&gt;I had to do it inside the method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have no idea why? I will try it again in an hour, for now I was happy to be able to get it working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will select your answer. &lt;/P&gt;&lt;P&gt;I will comment back here if it can be down outside of the entry method.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jul 2022 12:54:16 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-pass-kwargs-to-wheel-method/m-p/12307#M7128</guid>
      <dc:creator>ACK</dc:creator>
      <dc:date>2022-07-27T12:54:16Z</dc:date>
    </item>
  </channel>
</rss>

