Files
style_code_lisad/Правила написания Python-кода (Gin-Config Strict Pattern).md
Pikaliov 3278322a17 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)
2026-04-27 17:12:38 +03:00

71 lines
1.8 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
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`