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 Snippets Repository.
2. Browse the Available Snippets: The repository contains categorized folders with snippets, each accompanied by a brief description and usage instructions.
Figure 1. Snippets Repository View
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
Figure 2. Snippet file download view
Integrating Snippets into Your Application
To use a shared snippet in your application, simply follow these steps:
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.
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.
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:
Locate Snippets:
FindextractColumns.m
andeliminateEmptyValues.m
snippets in thematlab/catalog
directory of the Shared Snippets Repository.Incorporate Code:
- Download files
extractColumns.m
andeliminateEmptyValues.m
into the folder with your MATLAB script.
- Download files
extractColumns.m
and eliminateEmptyValues.m
code snippets
- 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.
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.Test and Validate:
Run your application on the EPISODES Platform to ensure correct functionality. Adjust configurations if necessary.
Additional Notes:
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.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.