In DataWorks, you can enable mandatory code review at the workspace level. Once enabled, a reviewer must approve node code that a Developer commits before deployment. You can also specify the baseline scope for code review to ensure the code quality of high-priority tasks and prevent deployment failures from blocking other tasks. This topic describes how to use the code review feature.
Prerequisites
-
DataWorks Professional Edition or a more advanced edition is activated. For a comparison of features among different DataWorks editions, see DataWorks editions. To activate DataWorks, see Billing.
-
You have the Workspace Administrator role. For more information, see Users, roles, and permissions.
-
You have created a node for data development. For more information, see Data development in DataStudio (legacy).
Background information
When multiple tasks run concurrently in DataWorks, high-priority tasks receive resource precedence. We recommend that you enforce code review for high-priority tasks. This prevents non-compliant code from causing failures that can waste resources and block other tasks. By adding these tasks to the mandatory code review scope, reviewers can verify code quality and prevent deploying errors to the production environment.
The following table describes how enabling mandatory code review affects the node commit and deployment process.
|
Mandatory code review status |
Description |
Impact on operations |
|
Disabled |
When you commit a node, you can optionally specify reviewers to notify them of the change. Note
You can use this method to notify any member of the workspace about node changes, regardless of their role. |
This setting does not affect the node's commit and deployment process. You can commit and deploy the node normally. |
|
Enabled |
When you commit a node, you must select a qualified reviewer to perform a code review and ensure code quality. Note
Committing a node deletion does not trigger a code review. |
This action blocks the node's commit and deployment process, pending a code review.
|
Limitations
-
The code review feature is available only in DataWorks Professional Edition or a more advanced edition.
-
Only users with the Workspace Administrator role can enable or disable code review for a workspace.
-
Code review is not supported for certain node types, such as composite nodes (for example, for-each and loop nodes) and non-Python resource files.
Workflow
The following table describes the workflow for using mandatory code review.
|
Step |
Role |
Description |
|
Workspace Administrator |
The Workspace Administrator enables mandatory code review and configures reviewers and the review scope based on business needs. The feature takes effect only after it is enabled. Note
Enabling mandatory code review blocks the commit and deployment process for affected nodes. |
|
|
Developer |
A Developer triggers a code review when committing a node. After a reviewer is selected, the system generates a code review ticket. Note
In a workspace in standard mode, Developers can initiate code reviews in batches on the Deploy page. For more information, see Deploy nodes. |
|
|
The node submitter and code reviewers can view and manage initiated and pending reviews from the Code Review page. |
Enable and configure mandatory code review
-
Log on to the DataWorks console. In the target region, click in the left-side navigation pane. Select a workspace from the drop-down list and click Go to Data Development.
-
Go to the Security Settings and Others page.
-
On the DataStudio page, click the
icon in the lower-left corner to go to the Configure page. -
Click the Security Settings and Others tab on the Configure page to go to the Security Settings and Others page.
-
-
Enable and configure mandatory code review.
In the Code Review section, turn on Force to review code, and then configure the reviewers and baseline scope.
Parameter
Description
Force to review code
Enforces code review for nodes within the specified scope in the current workspace.
-
Open: Code for nodes in this workspace requires mandatory code review before deployment. You must specify reviewers, and you can deploy the code only after it passes the review. This action blocks the node's commit and deployment process.
NoteYou can configure Code reviewers and Baseline scopes for code review only after you turn on Force to review code.
-
Close: You can deploy code for nodes in this workspace without a code review. You can still optionally select reviewers when you commit a node, but this only serves as a notification and does not block the deployment process.
Code reviewers
Sets the policy for selecting reviewers when a node is committed.
-
Any Developer Role: After a code review is initiated, any user with the Developer role in the workspace can approve the change. The user who commits the node selects the specific reviewer.
-
Specify development role users: After a code review is initiated, only the specified users with the Developer role can approve the change. DataWorks selects the reviewers configured here by default when you commit a node.
Note-
You can select only users with the Developer role in the current workspace as reviewers.
-
If you configure multiple reviewers, the approval logic depends on the policy that you choose.
Baseline scopes for code review
Defines which nodes require a code review upon submission.
You can select the nodes that require mandatory code review based on their baseline priority. The logic is as follows:
-
If you set the review scope to non-baseline tasks, newly created tasks in the workspace require approval.
-
If you set the review scope to tasks of a specific baseline level, nodes on that baseline require approval upon submission.
-
A higher baseline number indicates a higher priority. Baseline tasks have a higher priority than non-baseline tasks.
For more information about how baselines control task priority, see Smart Baseline overview.
-
Initiate a code review
When committing a node, a Developer can specify one or more reviewers. The code review process varies depending on the workspace mode, as shown in the following table.
-
If a new review is initiated for a node that already has a review in progress, DataWorks automatically invalidates the previous review.
-
Committing a node deletion does not trigger a code review.
|
Workspace mode |
Review process |
Code review entry points |
|
Standard mode |
If mandatory code review is enabled, the commit and deployment process is blocked until the review passes. Once approved, the node is committed, and you can proceed to the Deploy page to deploy it. |
|
|
Simple mode |
If mandatory code review is enabled, select Only Initiate Code Review when you commit a node. After the review passes, you must commit the node again to deploy the node code to the production environment. |
|
View and approve code review tickets
-
Go to the Code Review page.
You can go to the Code Review page in one of the following ways:
-
In the upper-left corner of the DataStudio page, click the
icon and choose . -
On the edit page of the target node, click the
Code Review icon in the toolbar.
-
-
View and process the code review ticket.
On the Code Review page, you can view the list of reviews that you have initiated or that are assigned to you, and process them as needed.
Area
Description
1 (Tabs)
In this area, you can perform the following actions:
-
Reviewers can view and process their assigned review tasks on the Review by Me tab.
-
Submitters can view the review tasks they have initiated on the Submitted by Me tab.
2
In this area, you can filter code review tickets by criteria such as review status, ticket name, type, submitter, and submission time.
3
In this area, you can view basic information about a code review ticket, such as its version and review status, or open its details to process the review.
Key actions include:
-
Version comparison: Compare code differences between node versions to quickly understand changes.
-
Reviewer actions on a ticket:
-
Write a comment: Add a comment to the node version.
-
Passed: This action triggers the code review checker. After the check passes, the submitter can deploy the task from the Deploy page.
NoteFor more information about how to deploy a task, see Deploy nodes.
-
Not through: The outcome depends on whether mandatory code review is enabled. If enabled, it blocks the commit and deployment. If disabled, you can still commit and deploy the node.
-
Abandoned: Abandons the current review process. After the process is abandoned, you can commit and deploy the node version.
-
Reopen: If you need to re-review a discarded review process, you can use Reopen.
-
-