title: Running local python code with arguments in Databricks via dbx utility
body: <p>I am trying to execute a local PySpark script on a Databricks cluster via dbx utility to test how passing arguments to python works in Databricks when developing locally. However, the test arguments I am passing are not being read for some reason. Could someone help?
  Following this guide, but it is a bit unclear and lacks good examples.
  <a href="https://dbx.readthedocs.io/en/latest/quickstart.html" rel="nofollow noreferrer">https://dbx.readthedocs.io/en/latest/quickstart.html</a>
  Found this, but it also not clear: <a href="https://stackoverflow.com/questions/68685689/how-can-i-pass-and-than-get-the-passed-arguments-in-databricks-job">How can I pass and than get the passed arguments in databricks job</a></p>
  <p>Databricks manuals are very much not clear in this area.</p>
  <p>My PySpark script:</p>
  <pre><code>import sys
  
  n = len(sys.argv)
  print(&quot;Total arguments passed:&quot;, n)
  
  print(&quot;Script name&quot;, sys.argv[0])
  
  print(&quot;\nArguments passed:&quot;, end=&quot; &quot;)
  for i in range(1, n):
      print(sys.argv[i], end=&quot; &quot;)
  </code></pre>
  <p>dbx deployment.json:</p>
  <pre><code>{
    &quot;default&quot;: {
      &quot;jobs&quot;: [
        {
          &quot;name&quot;: &quot;parameter-test&quot;,
          &quot;spark_python_task&quot;: {
              &quot;python_file&quot;: &quot;parameter-test.py&quot;
          },
          &quot;parameters&quot;: [
            &quot;test-argument-1&quot;,
            &quot;test-argument-2&quot;
          ]
        }
      ]
    }
  }
  </code></pre>
  <p>dbx execute command:</p>
  <pre><code>dbx execute\
    --cluster-id=&lt;reducted&gt;\
    --job=parameter-test\
    --deployment-file=conf/deployment.json\
    --no-rebuild\
    --no-package
  </code></pre>
  <p>Output:</p>
  <pre><code>(parameter-test) user@735 parameter-test % /bin/zsh /Users/user/g-drive/git/parameter-test/parameter-test.sh
  [dbx][2022-07-26 10:34:33.864] Using profile provided from the project file
  [dbx][2022-07-26 10:34:33.866] Found auth config from provider ProfileEnvConfigProvider, verifying it
  [dbx][2022-07-26 10:34:33.866] Found auth config from provider ProfileEnvConfigProvider, verification successful
  [dbx][2022-07-26 10:34:33.866] Profile DEFAULT will be used for deployment
  [dbx][2022-07-26 10:34:35.897] Executing job: parameter-test in environment default on cluster None (id: 0513-204842-7b2r325u)
  [dbx][2022-07-26 10:34:35.897] No rebuild will be done, please ensure that the package distribution is in dist folder
  [dbx][2022-07-26 10:34:35.897] Using the provided deployment file conf/deployment.json
  [dbx][2022-07-26 10:34:35.899] Preparing interactive cluster to accept jobs
  [dbx][2022-07-26 10:34:35.997] Cluster is ready
  [dbx][2022-07-26 10:34:35.998] Preparing execution context
  [dbx][2022-07-26 10:34:36.534] Existing context is active, using it
  [dbx][2022-07-26 10:34:36.992] Requirements file requirements.txt is not provided, following the execution without any additional packages
  [dbx][2022-07-26 10:34:36.992] Package was disabled via --no-package, only the code from entrypoint will be used
  [dbx][2022-07-26 10:34:37.161] Processing parameters
  [dbx][2022-07-26 10:34:37.449] Processing parameters - done
  [dbx][2022-07-26 10:34:37.449] Starting entrypoint file execution
  [dbx][2022-07-26 10:34:37.767] Command successfully executed
  Total arguments passed: 1
  Script name python
  
  Arguments passed:
  [dbx][2022-07-26 10:34:37.768] Command execution finished
  (parameter-test) user@735 parameter-test % 
  </code></pre>
  <p>Please help :)</p>