Skip to main content
Version: v3.1 print this page

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.

Introduction

Creating a Code Template

To create a new code template:

  1. Click the Create Template button in the top-right corner
  2. 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
  3. Configure the Template Code:
    • Upload the script that you want to use as a code template so that you can attach it to resources
  4. Click Save to create the code template

Create code template

System Code Templates

The following system code templates are available by default:

Template NameDescription
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 SyncSystem 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.

View Code Template

Updating a Code Template

To modify an existing code template:

  1. Modify the Template Code
  2. Click Save to update the code template

Update code template

danger
  • 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:

  1. Navigate to the appropriate section (ETL Jobs)
  2. Click Create New and select From Template
  3. Choose the desired resource template (e.g., Python shell job or Spark job)
  4. Customize the parameters and placeholders
  5. In the Script Editor, users have two options: either select the code template or write their own script
  6. Save and execute as needed

Using Code Template

info

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:

  1. Click the delete icon (trash) in the Actions column
  2. A confirmation dialog will appear
  3. Click Delete Code Template to confirm

Delete code template

Best Practices

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