You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Current »

The Shared Snippets repository enables you to enhance your custom applications by integrating shared code snippets, which can significantly speed up the development process by providing reusable code blocks.

Content of this guide

This guide introduces you to the concept of shared snippets and shows you how to incorporate them into your custom applications within the EPISODES Platform.

For further details about the Shared Snippets repository, visit the official Git repository: Shared Snippets Repository.

Introduction to Shared Snippets

Shared snippets are reusable code blocks that can be easily integrated into your custom applications within the EPISODES Platform. These snippets are designed to perform common tasks, such as data processing, plotting, or file management, helping you focus on developing unique aspects of your application without reinventing the wheel.

Shared snippets are maintained in a dedicated Git repository, which you can access and clone directly

How to Access Shared Snippets

Note: To integrate these snippets seamlessly, make sure you have an active account in the Application Workbench. If you need help setting up your account, see Creating Application Workbench Account.

If you haven't created an application yet, it might be helpful to start with the Creating New Application page for guidance on setting up your application.

  1. Access the Repository: Log in to the Application Workbench first. To explore the available snippets, visit the Shared Snippets Repository.
    1. TODO add screenshot
  2. Browse the Available Snippets: The repository contains categorized folders with snippets, each accompanied by a brief description and usage instructions.
    1. TODO add screenshot
  3. Clone or Download: You can download or copy individual snippets directly from Gitea. Optionally you can clone the entire repository to get access to all snippets
    1. TODO add screenshot

Integrating Snippets into Your Application

To use a shared snippet in your application, simply follow these steps:

  1. Copy the Snippet Code: Locate the relevant snippet on Gitea or in your cloned repository and copy the entire file or just the needed code block.

  2. Add to Your Script: Paste the snippet directly into your application script or another relevant file, and make any necessary adjustments to paths or parameters.

  3. Test Your Application: Run your application locally or within the EPISODES Platform to verify everything works smoothly.

Example: Processing a Catalog File in MATLAB using Snippets

Scenario:
A user wants to process a catalog file in MATLAB using snippets from the shared repository. The snippets extractColumns and eliminateEmptyValues will be used to extract the 'Time' and 'E' columns and clean the data.

Steps to Integrate:

  1. Locate Snippets:
    Find extractColumns.m and eliminateEmptyValues.m snippets in the matlab/catalog directory of the Shared Snippets Repository.

  2. Incorporate Code:

    • Download files extractColumns.m and eliminateEmptyValues.m into the folder with your MATLAB script.
      • TODO add screenshot 
    • The main script could look like this:
    • function [V1, V2] = processCatalogData(catalog, dx)
      
          % Extract 'Time' and 'E' columns from the catalog using `extractColumns.m` snippet
          [T, E] = extractColumns(catalog, 'Time', 'E');
      
          % Eliminate empty values from the extracted columns using `eliminateEmptyValues.m` snippet
          [T, E] = eliminateEmptyValues(T, E);
      
          % Process the cleaned data using a custom function
          [V1, V2] = yourFunction(T, E, dx);
      end

      Replace the placeholder function yourFunction(T, E, dx) with a custom processing function.

  3. Modify the Configuration:
    Ensure that your application's configuration file (e.g., appDefinition.json) is updated to reflect any changes in data handling, input/output specifications, or dependencies that these snippets might introduce.

  4. Test and Validate:
    Run your application on the EPISODES Platform to ensure correct functionality. Adjust configurations if necessary.

Additional Notes:

The snippets extractColumns.m and eliminateEmptyValues.m are designed to handle common data preparation tasks. The first one extracts specific columns from a structured catalog, while the second one removes empty or invalid values from the data.
For a complete guide on editing and testing your application code, see Editing the Application Code.

Common Issues and Troubleshooting

  • Snippet Compatibility: Ensure that the programming language and dependencies of the snippet match those of your application environment.
  • Configuration Errors: Double-check the appDefinition.json to ensure that all inputs, outputs, and dependencies are correctly defined.
  • Testing Failures: Use detailed logging to diagnose where the integration might be failing. Review error messages for specific guidance.
  • No labels