Create a Project

A SleePyPhases project is a Python package (importable by name) combined with a project.yaml configuration file. The phases CLI generates the skeleton for you.

Scaffold with phases create

phases create --type sleep-study

The wizard asks for your project name, which phases to include, and what data each phase produces. It generates:

myproject/
├── project.yaml
└── myproject/
    ├── __init__.py
    ├── phases/
    │   └── Init.py
    ├── SignalPreprocessing.py
    ├── PreManipulation.py
    └── DataManipulation.py

Generated project.yaml

name: myproject
plugins:
  - pyPhasesRecordloader
  - pyPhasesML
  - SleePyPhases
phases:
  - name: Init
config: {}

Generated Init.py

The Init phase wires your custom subclasses into the SleePyPhases framework before any other phase runs:

from pyPhases import Phase
from SleePyPhases import SignalPreprocessing as SP, PreManipulation as PM, DataManipulation as DM
from myproject.SignalPreprocessing import SignalPreprocessing
from myproject.PreManipulation import PreManipulation
from myproject.DataManipulation import DataManipulation

class Init(Phase):
    def prepareConfig(self):
        SP.setClass(SignalPreprocessing)
        PM.setClass(PreManipulation)
        DM.setClass(DataManipulation)

prepareConfig() runs before any phase executes. Use it to register classes that the framework will instantiate dynamically.

Running phases

# Run a specific phase
phases run Training

The CLI resolves phase dependencies automatically. If Training depends on BuildDataset, it runs BuildDataset first.

Alternative: flat / notebook approach

For interactive exploration, skip project.yaml and use DefaultProject directly:

from SleePyPhases import SleePyPhasesProject
from pyPhasesML import Model

project = SleePyPhasesProject.create(
  configFiles="config.yaml", 
  plugins=["pyPhasesRecordloaderSleepEDF"],
  projectFile=None
)
project.setConfig("useLoader", "sleepedf")
project.setConfig("sleepedf-path", "/data/sleepedf")

recordIds = project.getData("allDBRecordIds", list) # loads record sleep-edf record ids
metadata = project.getData("metadata", list) # loads all metadata for all records
modelState = project.getData("modelState", Model) # starts the training, if model state doesn't exist yet

This creates an in-memory project with no file system scaffolding. All getData / registerData calls work identically, just run phase main methods directly instead of via the CLI or get the generated artefacts using getData. For a complete list of available artefacts, see Data Artifacts.

Next step

Load data — configure which dataset to load