Skip to main content

A self-hosted interactive Python training platform

Project description

PyShala

A self-hosted interactive Python training platform for delivering custom lessons with live code execution and automated feedback.

Features

  • Interactive Lessons: Write and run Python code directly in the browser
  • Automated Testing: Instant feedback with pass/fail results for each test case
  • Custom Content: Create your own lessons using simple YAML files
  • Data File Support: Lessons can include CSV, JSON, and other data files
  • Self-Hosted: Deploy on your own infrastructure
  • No External Dependencies: Code execution runs locally (no Docker required)

Quick Start

Installation

pip install pyshala

Command Line

# Run with default lessons directory (./lessons)
pyshala

# Run with custom lessons path
pyshala ./my_lessons

# Run with custom port
pyshala ./my_lessons --port 8080

# See all options
pyshala --help

CLI Options:

Option Default Description
lessons_path ./lessons Path to lessons directory
--host 0.0.0.0 Host address to bind
--port, -p 3000 Frontend port
--backend-port 8000 Backend API port
--max-execution-time 10.0 Max code execution time (seconds)
--python-path Current interpreter Python interpreter for execution
--loglevel info Logging level (debug/info/warning/error)
--app-name Learn Python Application name displayed in the UI
--app-description (see below) Description displayed on home page
--version, -v Show version and exit

Python API

from pyshala import PyShala

# Create and run the app with your lessons
app = PyShala(lessons_path="./my_lessons")
app.run()

Open your browser at http://localhost:3000

Configuration Options:

from pyshala import PyShala

app = PyShala(
    lessons_path="./lessons",      # Path to lesson YAML files
    host="0.0.0.0",                # Host address
    port=3000,                     # Frontend port
    backend_port=8000,             # Backend API port
    max_execution_time=10.0,       # Max code execution time (seconds)
    python_path="/usr/bin/python3", # Python interpreter for execution
    loglevel="info",               # Logging level
)
app.run()

Alternative: Using create_app

from pyshala import create_app

app = create_app(lessons_path="./my_lessons", port=8080)
app.run()

Creating Lessons

Lessons are defined using YAML files organized into modules. For more information about writing lessons, see LESSONS.md.

Directory Structure

lessons/
├── python_basics/           # Module directory
│   ├── module.yaml          # Module metadata
│   ├── 01_hello_world.yaml  # Lesson file
│   ├── 02_variables.yaml
│   └── sales_data.csv       # Data file for lessons
└── control_flow/
    ├── module.yaml
    └── 01_if_statements.yaml

Module Configuration (module.yaml)

name: "Python Basics"
description: "Learn the fundamentals of Python programming"
order: 1

lessons:
  - 01_hello_world.yaml
  - 02_variables.yaml

Lesson Configuration

title: "Hello, World!"
description: "Write your first Python program"
order: 0

instructions: |
  # Hello, World!

  Use the `print()` function to display text.

  ## Your Task
  Print "Hello, World!"

starter_code: |
  # Write your code here

test_cases:
  - description: "Prints greeting"
    stdin: ""
    expected_output: "Hello, World!"

# Optional: include data files
data_files:
  - name: data.csv
    path: data.csv

Test Case Options

Field Description
stdin Input provided to the program
expected_output Expected stdout output
description Test description shown to learner
hidden If true, test details hidden from learner

Development

Setup

git clone https://github.com/dkedar7/pyshala.git
cd pyshala
pip install -e ".[dev]"

Running Directly with Reflex

reflex run

Running Tests

pytest tests/ -v

Building the Package

python -m build

Tech Stack

  • Frontend/Backend: Reflex (Python)
  • Code Editor: Monaco Editor via reflex-monaco
  • Code Execution: Local Python subprocess (sandboxed)

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyshala-0.1.0.tar.gz (30.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyshala-0.1.0-py3-none-any.whl (36.7 kB view details)

Uploaded Python 3

File details

Details for the file pyshala-0.1.0.tar.gz.

File metadata

  • Download URL: pyshala-0.1.0.tar.gz
  • Upload date:
  • Size: 30.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.8

File hashes

Hashes for pyshala-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b588fde1d09ce10720ffa061f0d316a26b498e0043f70dc436166e6724ecf1ef
MD5 c2cfdf130f6df59423bc443c06f50c74
BLAKE2b-256 988ed34b0f610847c01377658db019955a6aa1361009c4e12023eb38450c1910

See more details on using hashes here.

File details

Details for the file pyshala-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyshala-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 36.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.8

File hashes

Hashes for pyshala-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 146ac8bb83d27466ad5ec21190cca074ac1f51c6081e941f12b07742aada8879
MD5 e83f96bb7509610e520f979cfad86611
BLAKE2b-256 0582fb8a4a09c462b1ce5e40894df6d2b2180b58100ef598a53130eae46cebfd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page