Create a Spark on MaxCompute task
This topic describes how to create a Spark on MaxCompute task in Dataphin.
Background
You must upload JAR and Python files to resource management before you can reference them in a Spark on MaxCompute task. For detailed instructions, see Upload and reference resources.
Prerequisites
Spark tasks are enabled for your compute engine. For more information, see Security Settings.
Procedure
-
In the top navigation bar of the Dataphin homepage, choose R&D > Data Development.
-
On the Develop page, select a Project from the top navigation bar. If you are using Dev-Prod mode, you must also select an environment.
-
In the left-side navigation pane, choose Data Processing > Compute Task. In the Compute Task list, click the
icon and select Spark on MaxCompute. -
In the Create Spark on MaxCompute Task dialog box, configure the following parameters.
Parameter
Description
Task name
Enter a name for the offline compute task.
The name can be up to 256 characters long and cannot contain the following characters: vertical bar (|), forward slash (/), backslash (\), colon (:), question mark (?), angle brackets (<>), asterisk (*), or double quotation mark (").
Scheduling type
Select the scheduling type for the task. Scheduling Type includes the following:
-
Scheduled Task: The task runs automatically on a schedule.
-
Manual Task: You must trigger the task manually.
Select directory
Select the directory where you want to store the task.
If the directory does not exist, you can create one by clicking New Folder:
-
Above the compute task list, click the
icon to open the New Folder dialog box. -
In the New Folder dialog box, enter a Name for the folder and select a parent Directory as needed.
-
Click OK.
Use template
Turn on the Use Template switch to use a code template. When enabled, you must also select a Template and a Template Version.
Using a code template helps streamline data development. The code in a template task is read-only. You only need to configure the template parameters. To create a template, see Create an offline compute template.
Spark version
Select the Spark version for the task. The default version is Spark 3.1.1. You can choose Spark 3.1.1, Spark 2.4.5, or Spark 2.3.0. When you submit the job, the corresponding Spark client for the selected version is used.
Description
Enter a brief description of the task, up to 1,000 characters.
-
-
Click OK.
-
(Optional) On the toolbar above the code editor on the Spark on MaxCompute task tab, click Version to switch the Spark version for the task.
-
In the code editor, write the code for the Spark on MaxCompute compute task. After you finish, click Run in the toolbar above the code editor. The following is a code example.
@resource_reference{"spark.py"} spark-submit --deploy-mode cluster --conf spark.hadoop.odps.task.major.version=cupid_v2 --conf spark.hadoop.odps.runtime.end.point=http://service.cn.maxcompute.aliyun-inc.com/api --conf spark.hadoop.odps.end.point=http://service.cn.maxcompute.aliyun.com/api --master yarn spark.pyNoteThe
resource_reference{}directive references a JAR or Python resource package. -
Click Properties in the right sidebar of the page, and in the Properties panel, configure information for the task, such as Basic Information, Runtime Resources, Runtime Parameters, Scheduling Properties (for periodic tasks), Scheduling Dependencies (for periodic tasks), Runtime Configuration, and Resource Configuration.
-
Basic information
This section defines basic information for the task, such as its name, owner, and description. For more information, see Configure basic information for a task.
-
Running resources
This setting specifies the CPU and memory resources allocated to run the compute task. The default is 0.3 cores and 2,048 MB. For more information, see Configure running resources for an offline task.
-
Running parameters
If your task uses parameter variables, you can assign values to them in the properties. This allows the variables to be automatically replaced with their corresponding values when the node is scheduled. For more information, see Configure offline task running parameters.
-
Scheduling properties (for scheduled tasks)
If the task is a Scheduled Task, you must configure its scheduling properties in addition to its Basic information. For more information, see Configure scheduling properties for an offline task.
-
Scheduling dependencies (for scheduled tasks)
If the task is a Scheduled Task, you must configure its scheduling dependencies in addition to its Basic information. For more information, see Configure scheduling dependencies for an offline task.
-
Runtime configuration
You can configure task-level settings for run timeouts and retry policies based on your business needs. If you do not configure them, the task inherits the default tenant-level settings. For more information, see Configure running settings for a compute task.
-
Resource configuration
You can configure a scheduling resource group for the compute task. The task uses the resource quota of this group when it is scheduled. For more information, see Configure resources for a compute task.
-
-
On the current task tab, save and submit the task.
-
Click the
icon in the toolbar to save your code. -
Click the
icon in the toolbar to submit your code.
-
-
On the Submission Details page, confirm the Submitted Content and the precheck results, and enter any remarks. For more information, see Submission guide for offline compute tasks.
-
After you confirm the details, click OK and Submit.
Next steps
-
If you are using Dev-Prod mode, after submitting the task, you must publish the task to the production environment from the release list. For more information, see Manage Release Tasks.
-
If you are using Basic mode, the task is submitted directly to the production environment. You can then view the task in the O&M Center. For more information, see Manage Integration and Compute Tasks and Manage manual tasks.