Code Templates
Amorphic Code Templates provide a quick way to create boilerplate code and parameterized scripts that can be attached to resources. They help streamline the code creation process by offering ready-to-use code structures that can be customized as needed.
Creating a Code Template
To create a new code template:
- Click the Create Template button in the top-right corner
- Fill in the Code Template Details:
- Template Name: Enter a unique name
- Description: Add a description of the template's purpose
- Parameters: Parameters needed for your script to execute if needed
- Configure the Template Code:
- Upload the script that you want to use as a code template so that you can attach it to resources
- Click Save to create the code template
System Code Templates
The following system code templates are available by default:
Template Name | Description |
---|---|
AS400 Advanced Data Sync (CDC + Partitions) | System code template for AS400 Advanced Data Sync (CDC + Partitions) - processes data synchronization and change data capture operations |
AS400 Standard Data Sync (CDC) | System code template for AS400 Standard Data Sync (CDC) - processes data synchronization and change data capture operations |
MariaDB Standard Data Sync (CDC) | System code template for MariaDB Standard Data Sync (CDC) - processes data synchronization and change data capture operations |
Source to Target DB Schema Sync | System code template for Source to Target DB Schema Sync - processes data synchronization and change data capture operations |
View Code Template
When viewing a code template, you can see the following details:
- Template Name
- Description
- Status
- Template Code
- Complete code structure for the template
- Contains placeholders and parameters for customization
It also displays the actions to refresh, edit, share, and delete the code template. These actions are only applicable for user-created templates; users cannot edit or delete system-generated code templates.
Updating a Code Template
To modify an existing code template:
- Modify the Template Code
- Click Save to update the code template
- System code templates cannot be edited or deleted
- Only user-created templates can be modified or removed
- Be cautious when deleting templates as this action cannot be undone
Using Code Templates
To use a code template:
- Navigate to the appropriate section (ETL Jobs)
- Click Create New and select From Template
- Choose the desired resource template (e.g., Python shell job or Spark job)
- Customize the parameters and placeholders
- In the Script Editor, users have two options: either select the code template or write their own script
- Save and execute as needed
With this job creation process, the job creation is a one-step process and the job will go to the registered status.
Deleting a Code Template
To remove a code template:
- Click the delete icon (trash) in the Actions column
- A confirmation dialog will appear
- Click Delete Code Template to confirm
Best Practices
- Use clear, descriptive names for code templates
- Include comprehensive comments and documentation within the code
- Use meaningful variable names and placeholders
- Test the template by creating code from it after making changes
- Follow coding standards and conventions for the selected language
- Include error handling and logging in your templates
- Make templates reusable and parameterized
- Document any dependencies or requirements