Skip to content

Commit 1c8b6aa

Browse files
Merge pull request #34 from ncj-dneg/ncj-dneg-establish-coding-standards
Separate engine and interface packages
2 parents bedd9aa + b124d91 commit 1c8b6aa

154 files changed

Lines changed: 33006 additions & 18389 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/quality.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Code quality
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
quality:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-python@v5
13+
with:
14+
python-version: "3.12"
15+
- name: Install quality tools
16+
run: python -m pip install -r requirements-dev.txt
17+
- name: Check formatting and lint
18+
run: ruff check .
19+
- name: Check type hints
20+
run: mypy .
21+
- name: Check Python file sizes
22+
run: python tools/check_code_standards.py
23+
- name: Check package dependency boundaries
24+
run: python tools/check_dependency_boundaries.py

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "engine"]
2+
path = engine
3+
url = https://github.com/drunkenbot-ai/engine.git

README.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ creating tokenizers, training small GPT-style language models, benchmarking
1616
checkpoints, exporting model artifacts, and testing local GGUF models in a
1717
streamed Markdown chat interface.
1818

19+
The source is split into the non-Qt `engine/` package and the Qt desktop
20+
`interface/` package. Historical `llm_trainer/` import paths remain available
21+
for compatibility; new application and test code should use the canonical
22+
packages. The dependency direction is one-way: `engine/` never imports
23+
`interface/`, and `interface/` never imports `llm_trainer/`.
24+
1925

2026
For development, use Python 3.12 or newer. Distribution builds include a
2127
private Python runtime and do not require Python on the user's machine.
@@ -74,22 +80,29 @@ license data, logs, and machine identifier under the user's
7480

7581
## First backend commands
7682

77-
Prepare text/PDF/JSONL files:
83+
The non-Qt command-line engine is available directly:
84+
85+
```powershell
86+
python -m engine.cli --help
87+
```
88+
89+
`python -m llm_trainer.cli` remains a compatibility alias for existing
90+
automation. Prepare text/PDF/JSONL files:
7891

7992
```powershell
80-
python -m llm_trainer.cli prepare --input_dir .\examples\tiny_corpus --output_dir .\runs\tiny_data --context_length 16
93+
python -m engine.cli prepare --input_dir .\examples\tiny_corpus --output_dir .\runs\tiny_data --context_length 16
8194
```
8295

8396
Prepare programming PDFs plus source files in code-aware mode:
8497

8598
```powershell
86-
python -m llm_trainer.cli prepare --input_dir .\examples\tiny_corpus --output_dir .\runs\code_data --context_length 128 --code_training_mode
99+
python -m engine.cli prepare --input_dir .\examples\tiny_corpus --output_dir .\runs\code_data --context_length 128 --code_training_mode
87100
```
88101

89102
For large corpora, enable faster preview/build scanning:
90103

91104
```powershell
92-
python -m llm_trainer.cli prepare --input_dir .\my_big_data --output_dir .\runs\big_data --fast_scan_mode
105+
python -m engine.cli prepare --input_dir .\my_big_data --output_dir .\runs\big_data --fast_scan_mode
93106
```
94107

95108
`--fast_scan_mode` uses cheaper file fingerprints and cached preview statistics,
@@ -98,7 +111,7 @@ which is significantly faster on very large datasets.
98111
To reduce false duplicate matches in fast mode, add strict verification:
99112

100113
```powershell
101-
python -m llm_trainer.cli prepare --input_dir .\my_big_data --output_dir .\runs\big_data --fast_scan_mode --strict_duplicate_verification --fast_scan_sample_bytes 65536
114+
python -m engine.cli prepare --input_dir .\my_big_data --output_dir .\runs\big_data --fast_scan_mode --strict_duplicate_verification --fast_scan_sample_bytes 65536
102115
```
103116

104117
`--strict_duplicate_verification` only runs full SHA-256 hashing on suspected
@@ -111,7 +124,7 @@ tries to extract code-like blocks from PDFs/text.
111124
Train a very small smoke-test model:
112125

113126
```powershell
114-
python -m llm_trainer.cli train --data_dir .\runs\tiny_data --output_dir .\runs\tiny_model --epochs 1 --batch_size 2 --context_length 16 --embedding_size 32 --head_count 4 --layer_count 2 --device cpu --no_resume
127+
python -m engine.cli train --data_dir .\runs\tiny_data --output_dir .\runs\tiny_model --epochs 1 --batch_size 2 --context_length 16 --embedding_size 32 --head_count 4 --layer_count 2 --device cpu --no_resume
115128
```
116129

117130
Training saves checkpoints in the model folder and can resume from the latest
@@ -163,13 +176,19 @@ contains a real Hugging Face-compatible `hf_model` directory.
163176
For MicroGPT checkpoints, use the HF-style package export first:
164177

165178
```bash
166-
python -m llm_trainer.cli export-hf --model_dir runs/model
179+
python -m engine.cli export-hf --model_dir runs/model
167180
```
168181

169182
That creates `runs/model/hf_model` with config, weights, tokenizer metadata,
170183
lineage, and a README. It is portable MicroGPT packaging, not a claim that the
171184
checkpoint is already a llama.cpp-supported Llama/Mistral/Gemma model.
172185

186+
Before submitting changes, run the package-boundary check:
187+
188+
```powershell
189+
python tools/check_dependency_boundaries.py
190+
```
191+
173192
## Current IDE Features
174193

175194
- Dataset Blueprint with dynamic bundled corpus discovery.

UserGuide.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,14 @@ their own private Python runtime and do not require Python to be installed
3737
system-wide.
3838

3939
For installer builds, see [build.md](build.md). The installer excludes the
40-
bundled `llm_trainer/default_data` training corpus; projects receive only the
40+
bundled `engine/default_data` training corpus; projects receive only the
4141
training data that you explicitly copy or add.
4242

43+
The application code is organized into `engine/` (non-Qt data, training, and
44+
worker services) and `interface/` (the Qt desktop UI). Existing
45+
`llm_trainer.*` imports and `python -m llm_trainer.cli` remain compatibility
46+
aliases, but new code should import from the canonical packages.
47+
4348
The app has five main work areas:
4449

4550
- `IN`: prepare datasets.

build.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ python packager.py --gpu
3939
```
4040

4141
The packager creates a private runtime, installs the pinned dependencies,
42-
builds the launcher bundle, copies application assets and fonts, runs Inno
43-
Setup, and writes the installer to `packaging/artifacts/`.
42+
builds the launcher bundle, copies `engine/` and `interface/` directly along
43+
with application assets and fonts, runs Inno Setup, and writes the installer to
44+
`packaging/artifacts/`. The historical `llm_trainer/` compatibility package is
45+
kept in the source tree but is not the primary packaged application path.
4446

4547
The CUDA build detects the NVIDIA driver using `nvidia-smi`. It selects the
4648
supported PyTorch wheel index and falls back to CPU when no compatible driver
@@ -62,6 +64,10 @@ The installer includes the private Python runtime, application code, third
6264
party packages, fonts, logo images, and other application assets. Training corpus data is not bundled; users download or select it through the
6365
Dataset Sources page after installation.
6466

67+
Run `python tools/check_dependency_boundaries.py` before packaging to verify
68+
that the non-Qt engine does not import the desktop interface and that new
69+
interface code does not depend on the legacy package.
70+
6571
Build intermediates and installers are written under `packaging/` and are
6672
ignored by Git.
6773

engine

Submodule engine added at 8799615

interface/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"""PySide6 desktop interface for Micro Trainer."""
2+

0 commit comments

Comments
 (0)