Scripts

Scripts in Galago provide a powerful way to automate complex tasks and extend the platform’s functionality using Python. They allow you to create custom automation workflows, data processing routines, and integration with external systems.

Table of Contents

  1. Overview
  2. Working with Scripts
    1. Script Features
    2. Example Script
  3. Best Practices

Overview

Working with Scripts

Creating Scripts

1
Navigate to the Scripts page
2
Click "New Script"
3
Write your Python code in the editor
4
Save and test the script

Script Features

Python Environment

Access to a full Python 3 environment with standard libraries and modules.

Package Support

Use external Python packages to extend functionality (numpy, pandas, etc.).

Scheduled Execution

Run scripts on a schedule or trigger them from protocols and other events.

Example Script


  from tools.toolbox.variables import get_all_variables
  print(get_all_variables())
  

Best Practices

Code Organization

  • Use clear, descriptive function and variable names
  • Add comprehensive comments to explain complex logic
  • Follow PEP 8 style guide for consistent formatting
  • Implement proper error handling and logging
  • Break complex scripts into smaller, reusable functions

Testing and Deployment

  • Test scripts in development environment before production
  • Use version control to track changes
  • Document dependencies and requirements
  • Monitor script performance and resource usage
  • Implement timeouts for long-running operations

Warning: Scripts have full access to the Galago API and can modify system state. Always test scripts thoroughly before running them in a production environment.

Tip: You can use the galago.log() function to write to the Galago log system, making it easier to debug and monitor your scripts.