Canvas Source Control Features

This page covers how Zerve integrates Git-based source control directly into the canvas environment, including committing code, viewing history and managing branches.

Getting Started with Canvas Source Control

Once your Git provider is connected, you will now have access to Git source control features in the Zerve application.

Step 1: Select Repository in Canvas's Source Control

Within Canvas's source control, users can choose the respective repository to which the code developed in the environment will be committed. To save the canvas to a new repository - make sure to create the repository in your Git account to select it from the canvas.

  1. Access Source Control: Navigate to the source control feature within Canvas.

  2. Locate and Choose Repository and Branch for the Canvas: Look for the option that allows users to choose the repository. Note: Depending on which Git platform your are using, the repository selection will be slightly different.

    1. Github: Select the Repository and Branch.

    2. Bitbucket: Select the Workspace, Repository and Branch.

    3. Azure Devops: Select the Organization, Project, Repository and Branch.

  3. Set Branch Path: Set the branch path for the canvas. This is the directory in the branch that this particular canvas will be saved to. The default branch path is the ID of the canvas.

Step 2: Initial Canvas Commit

The first step in canvas source management in a repository is the initial commit of the first version of the canvas.

  1. Commit Message: Before to commit the code, there is Message section to add commit message pertaining to commit.

  2. Commit Code: Once the commit message is added, the user can proceed with committing the code developed within the Canvas environment to that chosen repository.

  3. View Commit History: There is a separate section under source control to check the commit history. After the initial commit, you should see the commit message listed at the top of the commit history.

Committing a canvas

Step 3: View Commit and Pushed Code

After committing the code in the development environment. The committed code will have been pushed to the repository as .py modules or any other specified format. The files are as follows:

  1. Canvas.yaml: This file consists of details such as canvas and its layers such as id, global imports, layers, compute type, memory, edges (links between blocks).

  2. Development (Folder): This folder contains Python (.py) files comprising Canvas code, accompanied by a "layer.yaml" file containing details similar to those found in "canvas.yaml". Notably, the content within this folder is confined to the specifics of this layer exclusively. Subsequently, .text file consists of contents of any prompt or variable passed in bedrock prompt.

Committed code in repository

Additional Source Management Features

Compare Branches

Zerve natively integrates GitHub diff views to compare branches for code review. This is available at a block level and can be used to compare different branches. Here's how to utilize this feature:

  1. Choosing a commit history: Choose a commit from the history list.

  2. Diffs viewer: In the diffs viewer, select the current state and click on "apply."

  3. Change comparison: The changes compared to the previous commit will be displayed in the third step. Additionally, blocks where changes were made will be highlighted.

Diff Commits in History

Restore Old Commits

Zerve provides an option to restore previously committed code to a new canvas. Note: Restoring an old commit does not impact the canvas from which the commit was made.

  1. Choosing a commit history: Choose a commit from the history list.

  2. Restore the Comment: Open the chosen commit in the commit history list and click Restore. You will be redirected to a new canvas that is a duplicate of the commit you selected.

Branches for Canvas Changes

To make changes to a canvas that can be managed by source control, the recommended approach is to create a branch, add your changes on the branch canvas, create a pull request and ultimately merge the changes from your branch back into the main canvas branch.

Step 1: Create a Branch for the Canvas

Click the Create Branch button under the repository selection section for the canvas in Source Control.

Create new branch

Enter a name for the branch in the pop-up modal.

Name the branch

You will be redirected to a new branch canvas to make your changes.

Step 2: Create a Pull Request for the Branch

After the branch changes are complete, a Pull Request should be created so that other users in your organization or co-workers can review your changes.

Click the Create Pull Request button to be redirected to your Git platform where you will create a new pull request.

Open Pull Request

Step 3: Merge Pull Request

Once a pull request has been approved, the next step is to merge the pull request in the Git platform UI. This will merge your changes back into the branch for the main canvas.

Step 4: Pull Changes to Main Canvas

In order to see the changes made in the branch reflected in the main canvas, you must now pull the main canvas branch.

Pull latest changes

Include Repositories in Block Execution

In a Zerve canvas, you can include and import code from Git Repositories in block execution.

Step 1: Setup Include Repositories

Once a Git integration has been installed in your Zerve account, you can include code from repositories in block execution for a Canvas. To include code from a repository, set up the included repo by clicking the Include Repository link.

Include a repository for canvas blocks

Step 2: Include Repository in Block Code

The included repository code can now be imported in blocks for execution. Note: If the imported repository has hyphens(-), they must be replaced by underscore(_) when being referenced in an import statement.

Call functions in included repo code

Last updated