cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Databricks Asset Bundles: issue with python_file path in spark_python_task

ext07_rvoort
New Contributor II

Hi,

I am trying to run a python file which is stored in src folder. However, I am getting the following error: Error: cannot update job: Invalid python file reference: src/get_git_credentials.py. Please visit the Databricks user guide for supported python references

Here is my task definition:

resources:
  jobs:
    clicksend_elt:
      name: clicksend_elt
      schedule:
        quartz_cron_expression: 0 0 9-18 ? * MON-FRI *
        timezone_id: Europe/Luxembourg
        pause_status: ${var.clicksend_schedule_status}
      tasks:
        - task_key: get_git_credentials
          job_cluster_key: clicksend_job_cluster
          email_notifications: {}
          run_if: ALL_SUCCESS
          spark_python_task:
            python_file: src/get_git_credentials.py

And the absolute path of the file I am trying to run is (my DAB project being data_lakehouse):

ext07_rvoort_2-1759997838194.png

In the databricks.yml file I include resources with:

include:
  - resources/*.yml

How should I input the path of the file? Somehow the only was that it works is by providing the absolute path:

python_file: "${workspace.root_path}/files/src/get_git_credentials.py"

 

1 ACCEPTED SOLUTION

Accepted Solutions

ext07_rvoort
New Contributor II

Hi @szymon_dybczak,

Thanks for you reply. The issue is related to the fact if am also providing git_source parameters in this job (even though the source parameter of my task is set to WORKSPACE). When I comment the git_source part, specifying the path in a relative way works: python_file: ./../src/get_git_credentials.py

On this page I found this: "The job git_source field and task source field set to GIT are not recommended for bundles, because local relative paths may not point to the same content in the Git repository. Bundles expect that a deployed job has the same files as the local copy from where it was deployed." 

Instead, clone the repository locally and set up your bundle project within this repository, so that the source for tasks are the workspace."

I would like to configure this git_source parameters only for the task that requires it but it seems like it can only be defined at job level. 

View solution in original post

2 REPLIES 2

szymon_dybczak
Esteemed Contributor III

Hi @ext07_rvoort ,

Could you try specify it in relative way:

python_file: ../src/get_git_credentials.py

So, in my setup I have following directory structure:

root folder:
  - databricks.yml file
  - src/
  - resources/job.yml

And then to refer in job.yml to source files that reside in src in need to provide path in following way:

../src/ingestion/extraction.py

ext07_rvoort
New Contributor II

Hi @szymon_dybczak,

Thanks for you reply. The issue is related to the fact if am also providing git_source parameters in this job (even though the source parameter of my task is set to WORKSPACE). When I comment the git_source part, specifying the path in a relative way works: python_file: ./../src/get_git_credentials.py

On this page I found this: "The job git_source field and task source field set to GIT are not recommended for bundles, because local relative paths may not point to the same content in the Git repository. Bundles expect that a deployed job has the same files as the local copy from where it was deployed." 

Instead, clone the repository locally and set up your bundle project within this repository, so that the source for tasks are the workspace."

I would like to configure this git_source parameters only for the task that requires it but it seems like it can only be defined at job level. 

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local communityโ€”sign up today to get started!

Sign Up Now