All Products
Search
Document Center

DataWorks:Code review

Last Updated:Aug 14, 2023

You can enable the forcible code review feature only for workspaces. After you enable the forcible code review feature for a workspace, the node code that is committed by developers in the workspace can be deployed only after the node code passes the code review. You can specify the nodes for which you want to initiate code review based on the priority of the baseline to which the nodes belong. For example, you can initiate code review for nodes that belong to a baseline that is assigned a higher priority. This way, the nodes can run as expected and do not block other nodes. This topic describes how to use the forcible code review feature.

Prerequisites

Background information

If multiple nodes are run in parallel in DataWorks, nodes that are assigned higher priorities can preferentially use resources. If the nodes that are assigned higher priorities fail to run due to invalid node code, the nodes occupy computing resources for an extended period of time. As a result, resources are wasted and other nodes may be blocked from running. To resolve this issue, we recommend that you add the nodes that are assigned higher priorities to a specific baseline and enable the forcible code review feature for the baseline. This way, a code reviewer can control the code quality of the nodes, and prevent node execution errors that occur due to invalid node code.

The following table describes the impacts of the forcible code review feature on the node commit and deployment processes.

Status of forcible code review

Description

Impact

Disabled

When you commit a node, DataWorks notifies the specified code reviewer of node changes.

Note

All members in the workspace, regardless of their roles, can be configured as the code reviewer.

The node commit and deployment processes are not affected. The node can be normally committed and deployed.

Enabled

When you commit a node, a qualified user must be specified to review the code of the node to control the code quality.

Note

If you delete a node, code review is not triggered when you commit the node.

The node commit and deployment processes are blocked and code review is performed on the node.

  • If the node code passes the code review, the node can be committed and deployed.

  • If the node code fails to pass the code review, the node cannot be committed or deployed. You must handle the issues in the code and proceed to the processes after the node code passes the code review.

Limits

  • Only users of DataWorks Professional Edition or a more advanced edition can use the forcible code review feature.

  • Only users who are assigned the Workspace Manager role can determine whether to enable the forcible code review feature in a workspace.

  • You cannot initiate code review for some special nodes. For example, you cannot initiate code review for a combined node such as a do-while node or a for-each node, or a non-Python resource file.

Procedure

The following table describes the procedure for using the forcible code review feature.

Step

Execution role

Description

Enable the forcible code review feature and configure the parameters

Workspace Manager

Users that are assigned the Workspace Manager role can enable the forcible code review feature, specify code reviewers, and specify the code review scope based on their business requirements. The forcible code review feature takes effect only after the feature is enabled.

Note

After the forcible code review feature is enabled, the node commit and deployment processes are blocked.

Initiate code review for nodes

Developer

Code review is triggered when a developer commits a node. After the developer specifies a code reviewer, the system generates a code review ticket.

Note

In a workspace in standard mode, a developer can select multiple nodes and initiate code review for the nodes at a time on the Deploy page. For more information, see Deploy nodes.

View and process code review tickets

  • Code review initiator

  • Code reviewer

On the Code Review page, a code review initiator can view the nodes for which they initiated code review, and code reviewers can view and process the nodes whose code they need to review.

Enable the forcible code review feature and configure the parameters

  1. Log on to the DataWorks console. In the left-side navigation pane, choose Data Modeling and Development > DataStudio. On the page that appears, select the desired workspace from the drop-down list and click Go to DataStudio.

  2. Go to the Security Settings and Others tab.

    1. In the lower-left corner of the DataStudio page, click the Settings icon icon. The Settings page appears.

    2. Click the Security Settings and Others tab.

  3. Enable the forcible code review feature and configure the parameters.

    In the Code Review section, you can turn on Force to review code and configure the parameters: Code reviewers and Baseline scopes for code review. Configure the parameters for forcible code review

    Parameter

    Description

    Force to review code

    Specifies whether to enable the forcible code review feature for specific nodes in the current workspace. If you turn on the switch, code review is triggered when you commit the nodes.

    • On: You must specify a code reviewer when you commit specific nodes in the current workspace. The node code can be deployed only after the code passes the code review. If the forcible code review feature is enabled, the node commit and deployment processes are blocked.

      Note

      You can configure the Code reviewers parameter and Baseline scopes for code review parameter only after you turn on Force to review code.

    • Off: The code of the nodes that you commit in the current workspace can be deployed without the need for code review. You can specify a code reviewer when you select the nodes that you want to commit. After you commit the nodes, the specified code reviewer is only notified of changes to the nodes and the node commit and deployment processes are not blocked.

    Code reviewers

    The users who are available for code review when you commit the nodes.

    • Any Developer Role: If you select this option, all users who are assigned the Development role in the current workspace are available for code review when you commit nodes. When you commit nodes, you must select a specific user to review the node code.

    • Specify development role users: If you select this option, you must specify a specific user as the code reviewer in this step. By default, the specified user is the code reviewer for nodes in the current workspace.

    Note
    • You can select only a user who is assigned the Development role in the current workspace as a code reviewer.

    • DataWorks allows you to configure one or more code reviewers. If you select Any Developer Role in this step and configure multiple code reviewers when you commit nodes, the node code passes the code review after any of the code reviewers approves the code. If you select Specify development role users and configure multiple code reviewers in this step, the node code passes the code review only after all code reviewers approve the code.

    Baseline scopes for code review

    The scope of nodes on which you want to perform code review when you commit the nodes.

    You can determine the nodes on which you want to perform code review based on the priority of the baseline to which the nodes belong.

    • If you set this parameter to Non-baseline tasks, code review is performed on newly created nodes in the current workspace.

    • If you set this parameter to baseline tasks of one or more specific levels, code review is performed on the nodes that belong to the baselines of specific priorities in the current workspace.

    • A larger value of the baseline task level indicates a higher priority. Nodes in a baseline have a higher priority than the priority of nodes that are not in a baseline.

    For more information about how to control the priorities of nodes by using a baseline, see Overview.

Initiate code review for nodes

DataWorks allows developers to specify one or more code reviewers when the developers commit nodes. The following table describes the code review process for workspaces in different modes.

Note
  • If you initiate code review for a node again when the previous code review is being performed for the code, the previous code review result becomes invalid.

  • If you delete a node, code review is not triggered when you commit the node.

Workspace mode

Code review process

Code review entry

Standard mode

If the forcible code review feature is enabled, the node commit and deployment processes are blocked until the node code passes the code review. After the node code passes the code review, the node is committed and you can deploy the node on the Deploy page.

  • Initiate code review for a single node

    • You can initiate code review for a single node in the dialog box that appears when you commit the node.

    • You can click the Code review icon in the top toolbar on the node configuration tab when you commit a single node to initiate code review for the node.

  • Initiate code review for multiple nodes at a time

    • You can initiate code review for multiple nodes at a time in the dialog box that appears when you commit the workflow to which the nodes belong.

    • Go to the Deploy page and click Create Package. On the Create Package page, initiate code review for multiple nodes at a time.

      Note

      For more information about how to deploy nodes on the Create Package page, see Deploy nodes.

Basic mode

If the forcible code review feature is enabled and you click Only Initiate Code Review in the dialog box that appears when you commit the node, you must click Submit again to commit the node to the production environment after the node code passes the code review.

  • Initiate code review for a single node

    You can initiate code review for a single node in the dialog box that appears when you commit the node.

  • Initiate code review for multiple nodes at a time

    You can initiate code review for multiple nodes at a time in the dialog box that appears when you commit the workflow to which the nodes belong.

View and process code review tickets

  1. Go to the Code Review page.

    You can go to the Code Review page by using one of the following methods:

    • In the upper-left corner of the DataStudio page, click the All icon and choose All Products > Data Development And Task Operation > Code Review.

    • On the configuration tab of a node, click the Code review icon in the top toolbar.

  2. View and process code review tickets.

    On the Code Review page, you can view the nodes for which you initiated code review and the nodes whose code needs to be reviewed by you. You can review the code of the nodes based on your business scenario. View code review tickets

    Area

    Description

    1

    You can perform the following operations in this area:

    • A code reviewer can view and process the nodes whose code they need to review on the Review by Me tab.

    • A code review initiator can view the nodes for which they initiated code review on the Submitted by Me tab.

    2

    In this area, you can search for nodes that meet the specified filter conditions such as the code review status, node name, node type, code review initiator, and node commit time.

    3

    In this area, you can view the basic information such as the version and code review status of a node. You can also view the details of a node and process the node.

    You can perform the following operations:

    • Version comparison: allows you to learn node changes based on a comparison of node code between different versions.

    • Processing of code review tickets:

      • Write a comment: allows you to add a comment on the node version.

      • Pass: triggers the code review checker to check the code of a node. After the node code passes the code review, the code review initiator can deploy the node on the Deploy page.

        Note

        For more information about how to deploy a node, see Deploy nodes.

      • Do not pass: A node is processed based on whether the Force to review code switch is turned on in the current workspace. If the switch is turned on, the node commit and deployment processes are blocked. If the switch is turned off, the node can be committed and deployed.

      • Abandoned: The current code review process is abandoned. After the code review process is abandoned, the node of the current version can continue to be committed and deployed.

      • Reopen: The abandoned code review process is reopened.