DatabricksStep Class
Creates an Azure ML Pipeline step to add a DataBricks notebook, Python script, or JAR as a node.
For an example of using DatabricksStep, see the notebook https://aka.ms/pl-databricks.
Create an Azure ML Pipeline step to add a DataBricks notebook, Python script, or JAR as a node.
For an example of using DatabricksStep, see the notebook https://aka.ms/pl-databricks.
:param python_script_name:[Required] The name of a Python script relative to source_directory
.
If the script takes inputs and outputs, those will be passed to the script as parameters.
If python_script_name
is specified then source_directory
must be too.
Specify exactly one of notebook_path
, python_script_path
, python_script_name
,
or main_class_name
.
If you specify a DataReference object as input with data_reference_name=input1 and a PipelineData object as output with name=output1, then the inputs and outputs will be passed to the script as parameters. This is how they will look like and you will need to parse the arguments in your script to access the paths of each input and output: "-input1","wasbs://[email protected]/test","-output1", "wasbs://[email protected]/b3e26de1-87a4-494d-a20f-1988d22b81a2/output1"
In addition, the following parameters will be available within the script:
- AZUREML_RUN_TOKEN: The AML token for authenticating with Azure Machine Learning.
- AZUREML_RUN_TOKEN_EXPIRY: The AML token expiry time.
- AZUREML_RUN_ID: Azure Machine Learning Run ID for this run.
- AZUREML_ARM_SUBSCRIPTION: Azure subscription for your AML workspace.
- AZUREML_ARM_RESOURCEGROUP: Azure resource group for your Azure Machine Learning workspace.
- AZUREML_ARM_WORKSPACE_NAME: Name of your Azure Machine Learning workspace.
- AZUREML_ARM_PROJECT_NAME: Name of your Azure Machine Learning experiment.
- AZUREML_SERVICE_ENDPOINT: The endpoint URL for AML services.
- AZUREML_WORKSPACE_ID: ID of your Azure Machine Learning workspace.
- AZUREML_EXPERIMENT_ID: ID of your Azure Machine Learning experiment.
- AZUREML_SCRIPT_DIRECTORY_NAME: Directory path in DBFS where source_directory has been copied.
(This parameter is only populated when `python_script_name` is used. See more details below.)
When you are executing a Python script from your local machine on Databricks using DatabricksStep
parameters source_directory
and python_script_name
, your source_directory is copied over to DBFS
and the directory path on DBFS is passed as a parameter to your script when it begins execution.
This parameter is labelled as –AZUREML_SCRIPT_DIRECTORY_NAME. You need to prefix it with the
string "dbfs:/" or "/dbfs/" to access the directory in DBFS.
- Inheritance
-
azureml.pipeline.core._databricks_step_base._DatabricksStepBaseDatabricksStep
Constructor
DatabricksStep(name, inputs=None, outputs=None, existing_cluster_id=None, spark_version=None, node_type=None, instance_pool_id=None, num_workers=None, min_workers=None, max_workers=None, spark_env_variables=None, spark_conf=None, init_scripts=None, cluster_log_dbfs_path=None, notebook_path=None, notebook_params=None, python_script_path=None, python_script_params=None, main_class_name=None, jar_params=None, python_script_name=None, source_directory=None, hash_paths=None, run_name=None, timeout_seconds=None, runconfig=None, maven_libraries=None, pypi_libraries=None, egg_libraries=None, jar_libraries=None, rcran_libraries=None, compute_target=None, allow_reuse=True, version=None, permit_cluster_restart=None)
Parameters
Name | Description |
---|---|
name
Required
|
[Required] The name of the step. |
inputs
|
A list of input connections for data consumed by this step. Fetch this inside the notebook using dbutils.widgets.get("input_name"). Can be DataReference or PipelineData. DataReference represents an existing piece of data on a datastore. Essentially this is a path on a datastore. DatabricksStep supports datastores that encapsulates DBFS, Azure blob, or ADLS v1. PipelineData represents intermediate data produced by another step in a pipeline. Default value: None
|
outputs
|
A list of output port definitions for outputs produced by this step. Fetch this inside the notebook using dbutils.widgets.get("output_name"). Should be PipelineData. Default value: None
|
existing_cluster_id
|
A cluster ID of an existing interactive cluster on the Databricks workspace. If you are passing this parameter, you cannot pass any of the following parameters which are used to create a new cluster:
Note: For creating a new job cluster, you will need to pass the above parameters. You can pass these parameters directly or you can pass them as part of the RunConfiguration object using the runconfig parameter. Passing these parameters directly and through RunConfiguration results in an error. Default value: None
|
spark_version
|
The version of spark for the Databricks run cluster, for example: "10.4.x-scala2.12".
For more information, see the description for the Default value: None
|
node_type
|
[Required] The Azure VM node types for the Databricks run cluster,
for example: "Standard_D3_v2". Specify either Default value: None
|
instance_pool_id
|
[Required] The instance pool ID to which the cluster needs to be attached to.
Specify either Default value: None
|
num_workers
|
[Required] The static number of workers for the Databricks run cluster.
You must specify either Default value: None
|
min_workers
|
[Required] The min number of workers to use for auto-scaling the Databricks run cluster.
You must specify either Default value: None
|
max_workers
|
[Required] The max number of workers to use for auto-scaling the Databricks run cluster.
You must specify either Default value: None
|
spark_env_variables
|
The spark environment variables for the Databricks run cluster.
For more information, see the description for the Default value: None
|
spark_conf
|
The spark configuration for the Databricks run cluster.
For more information, see the description for the Default value: None
|
init_scripts
|
[str]
Deprecated. Databricks announced the init script stored in DBFS will stop work after Dec 1, 2023. To mitigate the issue, please 1) use global init scripts in databricks following https://learn.microsoft.com/azure/databricks/init-scripts/global 2) comment out the line of init_scripts in your AzureML databricks step. Default value: None
|
cluster_log_dbfs_path
|
The DBFS paths where clusters logs are to be delivered. Default value: None
|
notebook_path
|
[Required] The path to the notebook in the Databricks instance. This class allows four ways of specifying the code to execute on the Databricks cluster.
Specify exactly one of Default value: None
|
notebook_params
|
A dictionary of parameters to pass to the notebook. Default value: None
|
python_script_path
|
[Required] The path to the python script in the DBFS.
Specify exactly one of Default value: None
|
python_script_params
|
Parameters for the Python script. Default value: None
|
main_class_name
|
[Required] The name of the entry point in a JAR module.
Specify exactly one of Default value: None
|
jar_params
|
Parameters for the JAR module. Default value: None
|
python_script_name
|
[Required] The name of a Python script relative to Specify exactly one of If you specify a DataReference object as input with data_reference_name=input1 and a PipelineData object as output with name=output1, then the inputs and outputs will be passed to the script as parameters. This is how they will look like and you will need to parse the arguments in your script to access the paths of each input and output: "-input1","wasbs://[email protected]/test","-output1", "wasbs://[email protected]/b3e26de1-87a4-494d-a20f-1988d22b81a2/output1" In addition, the following parameters will be available within the script:
When you are executing a Python script from your local machine on Databricks using DatabricksStep
parameters Default value: None
|
source_directory
|
The folder that contains the script and other files.
If Default value: None
|
hash_paths
|
[str]
DEPRECATED: no longer needed. A list of paths to hash when checking for changes to the step contents. If there
are no changes detected, the pipeline will reuse the step contents from a previous run. By default,
the contents of Default value: None
|
run_name
|
The name in Databricks for this run. Default value: None
|
timeout_seconds
|
The timeout for the Databricks run. Default value: None
|
runconfig
|
The runconfig to use. Note: You can pass as many libraries as you like as dependencies to your job
using the following parameters: Default value: None
|
maven_libraries
|
Maven libraries to use for the Databricks run. Default value: None
|
pypi_libraries
|
PyPi libraries to use for the Databricks run. Default value: None
|
egg_libraries
|
Egg libraries to use for the Databricks run. Default value: None
|
jar_libraries
|
Jar libraries to use for the Databricks run. Default value: None
|
rcran_libraries
|
RCran libraries to use for the Databricks run. Default value: None
|
compute_target
|
[Required] An Azure Databricks compute. Before you can use DatabricksStep to execute your scripts or notebooks on an Azure Databricks workspace, you need to add the Azure Databricks workspace as a compute target to your Azure Machine Learning workspace. Default value: None
|
allow_reuse
|
Indicates whether the step should reuse previous results when re-run with the same settings. Reuse is enabled by default. If the step contents (scripts/dependencies) as well as inputs and parameters remain unchanged, the output from the previous run of this step is reused. When reusing the step, instead of submitting the job to compute, the results from the previous run are immediately made available to any subsequent steps. If you use Azure Machine Learning datasets as inputs, reuse is determined by whether the dataset's definition has changed, not by whether the underlying data has changed. Default value: True
|
version
|
An optional version tag to denote a change in functionality for the step. Default value: None
|
permit_cluster_restart
|
if existing_cluster_id is specified, this parameter tells whether cluster can be restarted on behalf of user. Default value: None
|
name
Required
|
[Required] The name of the step. |
inputs
Required
|
List of input connections for data consumed by this step. Fetch this inside the notebook using dbutils.widgets.get("input_name"). Can be DataReference or PipelineData. DataReference represents an existing piece of data on a datastore. Essentially this is a path on a datastore. DatabricksStep supports datastores that encapsulates DBFS, Azure blob or ADLS v1. PipelineData represents intermediate data produced by another step in a pipeline. |
outputs
Required
|
list[Union[OutputPortBinding, <xref:azureml.pipeline.core.pipeline_output_dataset.PipelineOutputDataset>, PipelineData]]
A list of output port definitions for outputs produced by this step. Fetch this inside the notebook using dbutils.widgets.get("output_name"). Should be PipelineData. |
existing_cluster_id
Required
|
A cluster ID of an existing interactive cluster on the Databricks workspace. If you are passing this parameter, you cannot pass any of the following parameters which are used to create a new cluster:
Note: For creating a new job cluster, you will need to pass the above parameters. You can pass these parameters directly or you can pass them as part of the RunConfiguration object using the runconfig parameter. Passing these parameters directly and through RunConfiguration results in an error. |
spark_version
Required
|
The version of spark for the Databricks run cluster, for example: "10.4.x-scala2.12".
For more information, see the description for the |
node_type
Required
|
[Required] The Azure VM node types for the Databricks run cluster,
for example: "Standard_D3_v2". Specify either |
instance_pool_id
Required
|
[Required] The instance pool ID to which the cluster needs to be attached to.
Specify either |
num_workers
Required
|
[Required] The static number of workers for the Databricks run cluster.
You must specify either For more information, see the description for the |
min_workers
Required
|
[Required] The min number of workers to use for auto-scaling the Databricks run cluster.
You must specify either For more information, see the description for the |
max_workers
Required
|
[Required] The max number of workers to use for auto-scaling the Databricks run cluster.
You must specify either For more information, see the description for the |
spark_env_variables
Required
|
The spark environment variables for the Databricks run cluster.
For more information, see the description for the |
spark_conf
Required
|
The spark configuration for the Databricks run cluster.
For more information, see the description for the |
init_scripts
Required
|
[str]
Deprecated. Databricks announced the init script stored in DBFS will stop work after Dec 1, 2023. To mitigate the issue, please 1) use global init scripts in databricks following https://learn.microsoft.com/azure/databricks/init-scripts/global 2) comment out the line of init_scripts in your AzureML databricks step. |
cluster_log_dbfs_path
Required
|
The DBFS paths where clusters logs are to be delivered. |
notebook_path
Required
|
[Required] The path to the notebook in the Databricks instance. This class allows four ways of specifying the code to execute on the Databricks cluster.
Specify exactly one of |
notebook_params
Required
|
A dictionary of parameters to pass to the notebook. |
python_script_path
Required
|
[Required] The path to the python script in the DBFS.
Specify exactly one of |
python_script_params
Required
|
Parameters for the Python script. |
main_class_name
Required
|
[Required] The name of the entry point in a JAR module.
Specify exactly one of |
jar_params
Required
|
Parameters for the JAR module. |
source_directory
Required
|
The folder that contains the script and other files.
If |
hash_paths
Required
|
[str]
DEPRECATED: no longer needed. A list of paths to hash when checking for changes to the step contents. If there
are no changes detected, the pipeline will reuse the step contents from a previous run. By default,
the contents of |
run_name
Required
|
The name in Databricks for this run. |
timeout_seconds
Required
|
The timeout for the Databricks run. |
runconfig
Required
|
The runconfig to use. Note: You can pass as many libraries as you like as dependencies to your job
using the following parameters: |
maven_libraries
Required
|
list[<xref:azureml.core.runconfig.MavenLibrary>]
Maven libraries to use for the Databricks run.
For more information on the specification of Maven libraries,
see |
pypi_libraries
Required
|
list[<xref:azureml.core.runconfig.PyPiLibrary>]
PyPi libraries to use for the Databricks run.
For more information on the specification of PyPi libraries,
see |
egg_libraries
Required
|
list[<xref:azureml.core.runconfig.EggLibrary>]
Egg libraries to use for the Databricks run.
For more information on the specification of Egg libraries,
see |
jar_libraries
Required
|
list[<xref:azureml.core.runconfig.JarLibrary>]
Jar libraries to use for the Databricks run.
For more information on the specification of Jar libraries,
see |
rcran_libraries
Required
|
list[<xref:azureml.core.runconfig.RCranLibrary>]
RCran libraries to use for the Databricks run.
For more information on the specification of RCran libraries,
see |
compute_target
Required
|
[Required] Azure Databricks compute. Before you can use DatabricksStep to execute your scripts or notebooks on an Azure Databricks workspace, you need to add the Azure Databricks workspace as a compute target to your Azure Machine Learning workspace. |
allow_reuse
Required
|
Indicates whether the step should reuse previous results when re-run with the same settings. Reuse is enabled by default. If the step contents (scripts/dependencies) as well as inputs and parameters remain unchanged, the output from the previous run of this step is reused. When reusing the step, instead of submitting the job to compute, the results from the previous run are immediately made available to any subsequent steps. If you use Azure Machine Learning datasets as inputs, reuse is determined by whether the dataset's definition has changed, not by whether the underlying data has changed. |
version
Required
|
An optional version tag to denote a change in functionality for the step. |
permit_cluster_restart
Required
|
if existing_cluster_id is specified, this parameter tells whether cluster can be restarted on behalf of user. |
Methods
create_node |
Create a node from the Databricks step and add it to the specified graph. This method is not intended to be used directly. When a pipeline is instantiated with this step, Azure ML automatically passes the parameters required through this method so that step can be added to a pipeline graph that represents the workflow. |
create_node
Create a node from the Databricks step and add it to the specified graph.
This method is not intended to be used directly. When a pipeline is instantiated with this step, Azure ML automatically passes the parameters required through this method so that step can be added to a pipeline graph that represents the workflow.
create_node(graph, default_datastore, context)
Parameters
Name | Description |
---|---|
graph
Required
|
The graph object to add the node to. |
default_datastore
Required
|
The default datastore. |
context
Required
|
<xref:azureml.pipeline.core._GraphContext>
The graph context. |
Returns
Type | Description |
---|---|
The created node. |