Skip to content

ef-lab/ethopy_control

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Ethopy Control

Documentation License: MIT

A Flask-based application for managing laboratory experiments and device control.

πŸ‘‰ Documentation

Quick Start

  1. Clone the repository:
git clone github.com/ef-lab/ethopy_control
cd ethopy_control
  1. Create and activate virtual environment:
python3 -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. Install dependencies:
# Using pip (standard installation)
pip install .
  1. Complete setup and database initialization:
# Single command setup - handles environment and database setup
python3 app_setup.py

This interactive script will:

  • Create .env file if it doesn't exist (prompts for database, SSH, and admin credentials)
  • Generate secure SECRET_KEY automatically
  • Validate your configuration and test database connectivity
  • Inspect your existing database structure
  • Create the Users table if it doesn't exist
  • Verify that required tables (#control, #task) exist
  • Create an admin user if no users exist
  • Provide detailed diagnostics if any issues occur

What you'll be prompted for:

  • Database credentials (host, username, password)
  • SSH configuration (optional, for remote reboot functionality)
  • Authentication preferences (local vs LDAP)
  • Admin user configuration

⚠️ Security Notes:

  • Never commit .env files to version control
  • Store credentials securely (password manager recommended)
  1. Run the development server:
python3 main.py

The application will be available at http://localhost:5000.

Project Structure

ethopy_control/
β”œβ”€β”€ main.py                   # Primary application entry point
β”œβ”€β”€ app.py                    # Flask application definition and routes
β”œβ”€β”€ app_setup.py             # Interactive setup with validation
β”œβ”€β”€ models.py                # Database models (User, ControlTable, Task)
β”œβ”€β”€ pyproject.toml          # Python project configuration and dependencies
β”‚
β”œβ”€β”€ utils/                   # Utility modules
β”‚   β”œβ”€β”€ __init__.py         # Package initialization
β”‚   β”œβ”€β”€ init_db.py          # Centralized database initialization
β”‚   β”œβ”€β”€ config.py           # Configuration management and validation
β”‚   └── setup_env.py        # Environment variable template generation
β”‚
β”œβ”€β”€ templates/              # Jinja2 HTML templates
β”‚   β”œβ”€β”€ base.html          # Base template with navigation
β”‚   β”œβ”€β”€ index.html         # Main control table interface
β”‚   β”œβ”€β”€ login.html         # Authentication page
β”‚   β”œβ”€β”€ tasks.html         # Task management interface
β”‚   └── activity_monitor.html # Activity monitoring dashboard
β”‚
β”œβ”€β”€ static/                # Static web assets
β”‚   β”œβ”€β”€ css/              # Stylesheets
β”‚   β”œβ”€β”€ js/               # JavaScript files
β”‚   β”‚   └── table.js      # DataTables implementation
β”‚   └── favicon.ico       # Site favicon
β”‚
β”œβ”€β”€ real_time_plot/        # Real-time data visualization
β”‚   β”œβ”€β”€ get_activity.py    # Database activity queries
β”‚   └── real_time_events.py # Dash-based real-time plotting
β”‚
β”œβ”€β”€ tests/                 # Test suite
β”‚   β”œβ”€β”€ conftest.py       # pytest configuration
β”‚   β”œβ”€β”€ test_api.py       # API endpoint tests
β”‚   └── test_models.py    # Database model tests
β”‚
└── docs/                 # Documentation
    β”œβ”€β”€ setup.md          # This setup guide
    └── mkdocs.yml        # Documentation configuration

User Interface

Control Table Interface

Control Table

Task Management Interface

Task Management

Real-time Data Visualization

Real-time Plot

Core Features

1. Control Table Management

  • Real-time status monitoring of lab setups
  • Bulk operations for updating multiple setups
  • User assignment and access control
  • Remote reboot capability via SSH

2. Task Management

  • CRUD operations for experimental tasks
  • Task assignment to specific setups
  • Task history and tracking

3. Real-time Data Visualization

  • Live event plotting using Dash and Plotly
  • Lick port and proximity sensor data visualization
  • Configurable time windows (30s, 60s, 5min, all)
  • Multi-setup monitoring

4. User Management & Authentication

  • Local authentication: Database-stored user accounts
  • Role-based access: Admin and regular users
  • Session management with Flask sessions

Documentation

# Build documentation
mkdocs build

# Serve documentation locally
mkdocs serve

Package Management

This project uses modern Python packaging with pyproject.toml:

  • For users: Use pip install .
  • For developers: Use pip install -e .[dev]
  • For documentation: Use pip install -e .[docs]
  • For testing only: Use pip install -e .[test]

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes following the code style guidelines
  4. Submit a pull request

Code Style Guidelines

  • Use Ruff for code formatting (line length: 88)
  • Follow PEP 8 naming conventions
  • Add type hints for function parameters and return values
  • Write docstrings for public functions and classes
  • Keep imports organized (standard library, third-party, local)
  • Use pytest for testing with descriptive test names

πŸ“š Documentation

Package Installation

For End Users

# Clone the repository
git clone <repository-url>
cd ethopy_control

# Install using modern packaging
pip install .

For Developers

# Clone the repository
git clone https://github.com/ef-lab/ethopy_control
cd ethopy_control

# Install in development mode with all tools
pip install -e .[dev]

# Or install with specific dependency groups
pip install -e .[test]     # Testing dependencies only
pip install -e .[docs]     # Documentation dependencies only

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.