This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Invoke Tasks (Recommended):
invoke --list- Show all available development tasksinvoke dev-setup- Set up complete development environment with uvinvoke venv-create- Create virtual environment with uvinvoke uv-sync- Sync dependencies using uvinvoke uv-lock- Update uv.lock fileinvoke check- Run all quality checks (format, lint, test)invoke format- Format code with ruffinvoke format --check- Check code formatting without changesinvoke lint- Run linting with ruffinvoke lint --fix- Run linting with auto-fixinvoke test- Run tests with pytestinvoke test --verbose- Run tests with verbose outputinvoke test --coverage- Run tests with coverage reportinvoke build- Build source and wheel distributionsinvoke build --clean- Clean build artifacts and rebuildinvoke clean- Clean build artifacts and cachesinvoke install- Install package in development modeinvoke release-check- Run comprehensive pre-release checksinvoke test-docker- Run full test suite in Docker (CI environment)
uv Virtual Environment Management:
uv venv- Create virtual environmentuv sync- Install dependencies from pyproject.tomluv sync --dev- Install with development dependenciesuv add <package>- Add runtime dependencyuv add --dev <package>- Add development dependencyuv remove <package>- Remove dependencyuv lock- Update dependency lock fileuv pip install -e .- Install package in development modesource .venv/bin/activate- Activate virtual environment
Direct Commands:
pytest -v- Run all tests (executed in Docker container)docker exec sosnotebook_sos-notebook_1 bash -c 'cd test && pytest -v'- Full test run in CI environment
Code Quality:
pre-commit run --all-files- Run code formatting and linting (ruff)ruff check- Run lintingruff check --fix- Run linting with auto-fixruff format- Format coderuff format --check- Check code formatting
Development Environment:
- Uses Docker for testing - see
development/docker-compose.yml docker-compose build --no-cache- Rebuild test imagesdocker network create sosnet- Create Docker network for testing
Build System:
- Uses modern
pyproject.tomlconfiguration (PEP 517/518) python -m build- Build source and wheel distributionspython -m build --sdist- Build source distribution onlypython -m build --wheel- Build wheel distribution onlypip install -e .- Install in development mode- Package entry points defined in pyproject.toml for SoS converters
- Old
setup.pykept assetup.py.oldfor reference
SoS Notebook is a Jupyter kernel that enables multi-language workflows within a single notebook. The architecture consists of several key components:
Core Kernel System:
kernel.py- MainSoS_Kernelclass extendingIPythonKernel, handles cell execution and communicationsubkernel.py-Subkernelsclass manages multiple language kernels (R, Bash, Python, etc.)comm_manager.py-SoSCommManagerhandles inter-kernel communication and data exchange
Language Integration:
- Language modules (sos-bash, sos-r, etc.) provide language-specific data type understanding
magics.py- SoS-specific Jupyter magic commands for workflow controlcompleter.py- Tab completion for SoS syntax and cross-language variables
Workflow Execution:
step_executor.py- Executes individual workflow stepsworkflow_executor.py- Orchestrates complete workflows, includesNotebookLoggingHandler- Supports both interactive execution and batch workflow processing
Conversion System:
converter.py- Multiple converters for different formats:ScriptToNotebookConverter(sos-ipynb)NotebookToScriptConverter(ipynb-sos)NotebookToHTMLConverter(ipynb-html)NotebookToPDFConverter(ipynb-pdf)NotebookToMarkdownConverter(ipynb-md)
Testing Strategy:
- Integration tests in Docker containers simulate real Jupyter environment
- Tests cover frontend interaction, magic commands, conversions, and workflows
- Sample notebooks in
test/directory provide test scenarios
Key Dependencies:
- Requires Python ≥3.7, built on jupyter ecosystem (jupyter_client, ipykernel, nbformat)
- Core SoS package (sos>=0.22.0) provides workflow engine
- pandas/numpy for data handling, psutil for system monitoring
Data Exchange: The system enables seamless data transfer between kernels through SoS variable system, supporting dataframes, matrices, and other structured data types across R, Python, Bash, and other supported languages.