Initial commit — gin-config strict-pattern coding standard

Code-style guide and reference patterns for DL/CV research at the
ЛИСАД laboratory (NADEZHDA / SOFIA CVGL projects).

Files:
- Стандарт написания кода для DL CV исследований (CVGL).md
- Правила написания Python-кода (Gin-Config Strict Pattern).md
- REQUIREMENTS_GIN_STYLE.md
- Gin-Config Strict Pattern Reference Examples.md
- Переход от argparse и dataclass к gin-config.md
- gin-parse.md
- Рекомендуемые gin-config категории.md
- config_loader_reference.py
- README.md (this commit)
- .gitignore (Python artifacts)
This commit is contained in:
2026-04-27 17:12:38 +03:00
commit 3278322a17
10 changed files with 1970 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
---
paths:
  - "**/*.py"
---
# Правила написания Python-кода (Gin-Config Strict Pattern)
## Окружение
- Python 3.10+, PyTorch 2.x
- `from __future__ import annotations` — первая строка каждого файла
- Код, переменные, комментарии — на **английском языке**
## Типизация и документация
- Strict type hints на всех аргументах и return types
- Google-style docstrings на всех публичных классах и функциях
## Конфигурация: gin-config (не argparse, не dataclass)
- `@gin.configurable` только на классах
- Все параметры со значениями по умолчанию в `__init__`
- Загрузка: `get_<name>_cfg(path2cfg)``gin.parse_config_file()` → return instance
- Передача конфигов **явно** через аргументы (не через глобальный gin state)
- Формат .gin: плоский (`ClassName.param = value`), без макросов
## DL/CV практики
- VRAM: sequential model loading, `del model` + `gc.collect()` + `empty_cache()` после использования
- Reproducibility: `torch.manual_seed(42)`, `np.random.seed(42)`
- Atomic writes: temp file + `os.replace()` для .npy/.json
- Inference: `@torch.inference_mode()`, результат на `.cpu()`
## Структура
- `in/config_files/` — .gin файлы (1 файл = 1 конфиг-класс)
- `src/conf/` — конфиг-классы + get_*_cfg() загрузчики
- `src/augmentor/` или `src/` — бизнес-логика (dataset, models, inference, io_utils)
Полный стандарт: skill `/code-style`