Updated on 2026-11-12 GMT+08:00

MRS Spark Python

Functions

The MRS Spark Python node is used to execute a predefined Spark Python job on MRS.

For details about how to use the MRS Spark Python operator, see Developing an MRS Spark Python Job.

Terms

  • Program arguments are generally the --conf configuration passed to Spark Driver or the options of Spark Submit.
  • Script arguments/Main class arguments are the arguments passed to the Python script (sys.argv or argparse). In the node configuration, execution program arguments refer to the arguments directly passed to the Python code.

    Parameter Type

    Example Content

    Object

    Parsing Mode

    Program argument (Spark Conf)

    --conf spark.executor.memory=8g

    Spark engine

    Parsed by Spark Submit and used to configure cluster resources

    Script argument (Script Args)

    Abbreviated URL (the default NameNode address of the cluster):
    hdfs:///input hdfs:///output
    Or:
    Full URL:
    hdfs://host:port/path

    Python script

    Transferred to sys.argv and parsed by Python code

    Optimal application scenarios:

    • Resource adjustment (memory, CPUs, and shuffle partitions): Program Parameter or a dedicated resource configuration box on the console
    • Service logic parameters (input path, output path, and filter criteria): Execution Program Parameter

Parameters

Table 1, Table 2, and Table 3 describe the parameters of the MRS Spark Python node.

Table 1 Parameters of MRS Spark Python nodes

Parameter

Mandatory

Description

Node Name

Yes

Name of the job node

The node name must contain 1 to 128 characters, including only letters, digits, and the following special characters: _-/.<>

NOTE:

The node name cannot contain other characters or more characters than allowed. If the node name does not meet requirements, the MRS job will fail to be submitted.

By default, the node name is the same as that of the selected script. If you want the node name to be different from the script name, disable this function by referring to Disabling Auto Node Name Change.

Job Name

Yes

MRS Spark job name

The job name can contain a maximum of 64 characters. Only letters, digits, hyphens (-), and underscores (_) are allowed.

The system can automatically enter an MRS job name in Job name_Node name format.

MRS Cluster Name

Yes

Select an MRS cluster that supports Spark Python. Only a specific version of MRS supports Spark Python. Test the cluster first to ensure that it supports Spark Python.

To create an MRS cluster, use either of the following methods:
  • Click . On the Clusters page, create an MRS cluster.
  • Go to the MRS console to create an MRS cluster.

For details about how to create a cluster, see Buying a Custom Cluster in MapReduce Service (MRS) Usage Guide.

MRS Resource Queue

No

Select a created MRS resource queue.

NOTE:

Select a queue you configured in the queue permissions of DataArts Security. If you set multiple resource queues for this node, the resource queue you select here has the highest priority.

Script Type

Yes

  • Offline
  • Online
    NOTE:

    Offline scripts: Python code files (.py) have been uploaded to the file system (such as HDFS or OBS) of the MRS cluster or uploaded to the resource management system of DataArts Studio as resource packages (JAR/PyFile). When a job runs, the Spark engine loads and executes code files from these storage locations.

    Online scripts: Python code is directly written on the job configuration page of DataArts Studio (usually a text editing area, that is, script development) When a job is submitted, DataArts Studio temporarily packs or uploads the code to the cluster and executes it.

SQL Script

Yes

This parameter is available only when Script Type is set to Online.

Select a Spark Python script.

NOTE:

A script can transfer a maximum of 50 parameters to a job node. A parameter name can contain no more than 64 characters, and a parameter value can contain no more than 256 characters.

Program Parameter

No

This parameter is available only when Script Type is set to Online.

Configure optimization parameters such as threads, memory, and vCPUs for the job to optimize resource usage and improve job execution performance. This configuration is unavailable for an MRS Spark proxy connection.

Example: Adjust Spark execution resources (most commonly used).

If the job is running slowly or an out of memory (OOM) error occurs, you can adjust the memory and number of CPUs by setting program parameters.

Example parameters:

--conf spark.executor.memory=8g
--conf spark.executor.cores=4
--conf spark.driver.memory=4g
--conf spark.sql.shuffle.partitions=200

Descriptions:

spark.executor.memory=8g: 8 GB of memory is allocated to each executor.

spark.executor.cores=4: Four CPUs are allocated to each executor.

spark.driver.memory=4g: 4 GB of memory is allocated to the driver node.

spark.sql.shuffle.partitions=200: The number of partitions in the shuffle phase is set to 200.

NOTE:

This parameter is mandatory if the cluster version is MRS 1.8.7 or later than MRS 2.0.1.

For details about the program parameters of MRS Spark jobs, see Running a Spark Job in the MapReduce Service User Guide.

Parameter

Yes

This parameter is available only when Script Type is set to Offline.

Enter parameters. Press Enter between parameters. Example:

--master

yarn

--deploy-mode

cluster

--num-executors

6

Execution Program Parameter

No

This parameter is available only when Script Type is set to Online.

Execution program parameters refer to the parameters directly passed to the Python code.

Enter the execution program parameters for MRS Spark Python.

Example:

DataArts Studio allows you to use system variables in parameters, such as ${bizdate} (indicating the business date) and ${ds} (indicating the scheduling date).

Configure execution program parameters in DataArts Studio:
hdfs:///data/raw/${bizdate} hdfs:///data/clean/${bizdate}

Parameter description:

When the job runs on May 27, 2024, ${bizdate} will be automatically replaced with 2024-05-27.

The following parameters are passed to the Python script:

hdfs:///data/raw/2024-05-27 hdfs:///data/clean/2024-05-27

A complete example is as follows:

Assume that you want to run the user_analysis.py script to analyze user behavior.

Main file: hdfs:///user/dayu/scripts/user_analysis.py

Program parameters (Spark configuration)

--conf spark.executor.memory=8g
--conf spark.sql.shuffle.partitions=200

Execution program parameters (Python script parameters):

--input hdfs:///data/ods/user_behavior/${bizdate} --output hdfs:///data/dws/user_analysis/${bizdate} --date ${bizdate}

Spark uses executors with 8 GB of memory and passes parameters such as --input, hdfs://..., --output, hdfs://..., --date, and 2024-05-27 to the Python script.

Use spaces to separate execution program parameters. To prevent parameters from being saved as plaintext, add an at sign (@) before parameters.

NOTE:

Do not enter sensitive information, such as the AK, SK, password, and authorization information.

Attribute

No

Enter parameters in the key=value format. Use Enter to separate multiple parameters.

Table 2 Advanced parameters

Parameter

Mandatory

Description

Max. Node Execution Duration

Yes

Execution timeout interval for the node. If retry is configured and the execution is not complete within the timeout interval, the node will be executed again.

Retry upon Failure

Yes

Whether to re-execute a node if it fails to be executed. Possible values:

  • Yes: The node will be re-executed, and the following parameters must be configured:
    • Retry upon Timeout
    • Maximum Retries
    • Retry Interval (seconds)
  • No: The node will not be re-executed. This is the default setting.
    NOTE:

    If retry is configured for a job node and the timeout duration is configured, the system allows you to retry a node when the node execution times out.

    If a node is not re-executed when it fails upon timeout, you can go to the Default Configuration page to modify this policy.

    Retry upon Timeout is displayed only when Retry upon Failure is set to Yes.

Policy for Handling Subsequent Nodes If the Current Node Fails

Yes

Operation that will be performed if the node fails to be executed. Possible values:

  • Suspend execution plans of the subsequent nodes: stops running subsequent nodes. The job instance status is Failed.
  • End the current job execution plan: stops running the current job. The job instance status is Failed.
  • Go to the next node: ignores the execution failure of the current node. The job instance status is Failure ignored.
  • Suspend the current job execution plan: If the current job instance is in abnormal state, the subsequent nodes of this node and the subsequent job instances that depend on the current job are in waiting state.

Enable Dry Run

No

If you select this option, the node will not be executed, and a success message will be returned.

Task Groups

No

Select a task group. If you select a task group, you can control the maximum number of concurrent nodes in the task group in a fine-grained manner in scenarios where a job contains multiple nodes, a data patching task is ongoing, or a job is rerunning.

Table 3 Lineage

Parameter

Description

Input

Add

Click Add. In the Type drop-down list, select the type to be created. The value can be DWS, OBS, CSS, HIVE, DLI, or CUSTOM.

OK

Click OK to save the parameter settings.

Cancel

Click Cancel to cancel the parameter settings.

Modify

Click to modify the parameter settings. After the modification, save the settings.

Delete

Click to delete the parameter settings.

View Details

Click to view details about the table created based on the input lineage.

Output

Add

Click Add. In the Type drop-down list, select the type to be created. The value can be DWS, OBS, CSS, HIVE, DLI, or CUSTOM.

OK

Click OK to save the parameter settings.

Cancel

Click Cancel to cancel the parameter settings.

Modify

Click to modify the parameter settings. After the modification, save the settings.

Delete

Click to delete the parameter settings.

View Details

Click to view details about the table created based on the output lineage.