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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyshala-0.1.1.tar.gz.
File metadata
- Download URL: pyshala-0.1.1.tar.gz
- Upload date:
- Size: 35.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f11e0666a95d32799dbb226da5baafe98d375d4206efee721696671adfa04aa
|
|
| MD5 |
50649a47dac38e26922eb2a4db14bf9c
|
|
| BLAKE2b-256 |
dbda5402ee5f5c45301df15319fea5c21cfac59b8a2bfabefa6a3d814eb64c1e
|
File details
Details for the file pyshala-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pyshala-0.1.1-py3-none-any.whl
- Upload date:
- Size: 42.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d720799d75d21911be7afa08267f6edc39cd2f944046d60c9e751a1913051b42
|
|
| MD5 |
e6683208d91a2e52d340127e9003e782
|
|
| BLAKE2b-256 |
133ec3c3c77d2e155b21c6ff48844706e4c93e855949d9ce465c29f3189fbb55
|