ghostconfig 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ghostconfig-0.1.0/.cursor/rules/python-file-structure.mdc +68 -0
- ghostconfig-0.1.0/.cursor/rules/python-imports.mdc +41 -0
- ghostconfig-0.1.0/.cursor/rules/python-naming.mdc +68 -0
- ghostconfig-0.1.0/.cursor/rules/python-tests.mdc +68 -0
- ghostconfig-0.1.0/.gitignore +218 -0
- ghostconfig-0.1.0/EXAMPLES.md +387 -0
- ghostconfig-0.1.0/LICENSE +21 -0
- ghostconfig-0.1.0/PKG-INFO +173 -0
- ghostconfig-0.1.0/README.md +135 -0
- ghostconfig-0.1.0/examples/configs/augmentations.json +17 -0
- ghostconfig-0.1.0/examples/configs/training.yaml +16 -0
- ghostconfig-0.1.0/examples/example_01.py +25 -0
- ghostconfig-0.1.0/examples/example_02.py +44 -0
- ghostconfig-0.1.0/examples/example_03.py +32 -0
- ghostconfig-0.1.0/examples/example_04.py +38 -0
- ghostconfig-0.1.0/examples/example_05.py +23 -0
- ghostconfig-0.1.0/examples/example_06.py +55 -0
- ghostconfig-0.1.0/ghostconfig/__init__.py +3 -0
- ghostconfig-0.1.0/ghostconfig/ghost_config.py +155 -0
- ghostconfig-0.1.0/ghostconfig/suggestions.py +51 -0
- ghostconfig-0.1.0/ghostconfig/tracker.py +22 -0
- ghostconfig-0.1.0/pyproject.toml +39 -0
- ghostconfig-0.1.0/render_examples.py +98 -0
- ghostconfig-0.1.0/tests/test_ghost_conf.py +463 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Python file structure and declaration order
|
|
3
|
+
globs: **/*.py
|
|
4
|
+
alwaysApply: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# File Structure: Top-Down Readability
|
|
8
|
+
|
|
9
|
+
Structure Python files so a reader sees the **main idea first**. Put the primary entry point, class, or function at the top, and helpers below. This mirrors how you'd explain the code to someone — start with the high-level concept, then reveal the details.
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
# ✅ GOOD — main idea first, helpers below
|
|
13
|
+
|
|
14
|
+
def process_data(path: str):
|
|
15
|
+
data = load_data(path)
|
|
16
|
+
result = compute_results(data)
|
|
17
|
+
print(result)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def load_data(path: str):
|
|
21
|
+
...
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def compute_results(data):
|
|
25
|
+
...
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
# ❌ BAD — reader must scroll to the bottom to understand the purpose
|
|
30
|
+
|
|
31
|
+
def load_data(path: str):
|
|
32
|
+
...
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def compute_results(data):
|
|
36
|
+
...
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def process_data(path: str):
|
|
40
|
+
data = load_data(path)
|
|
41
|
+
result = compute_results(data)
|
|
42
|
+
print(result)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Ordering Rules
|
|
46
|
+
|
|
47
|
+
1. **Imports** — standard library, third-party, local (as usual)
|
|
48
|
+
2. **Constants / module-level config**
|
|
49
|
+
3. **Primary class or function** — the main concept of this file
|
|
50
|
+
4. **Supporting classes and functions** — in order of first use from above
|
|
51
|
+
5. **`if __name__ == "__main__"` block** — at the very bottom
|
|
52
|
+
|
|
53
|
+
## Classes
|
|
54
|
+
|
|
55
|
+
The same principle applies within a class: put the most important public methods first, then private/helper methods below.
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
class Trainer:
|
|
59
|
+
def train(self): # ← main idea
|
|
60
|
+
self._load_data()
|
|
61
|
+
self._run_loop()
|
|
62
|
+
|
|
63
|
+
def _load_data(self): # ← helpers below
|
|
64
|
+
...
|
|
65
|
+
|
|
66
|
+
def _run_loop(self):
|
|
67
|
+
...
|
|
68
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Python import style — import modules, not names
|
|
3
|
+
globs: **/*.py
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Import Style: Import Modules, Not Names
|
|
8
|
+
|
|
9
|
+
Import at the module level, then reference names through the module. This makes it immediately clear where any class or function comes from when reading the code.
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
# ❌ BAD — names imported directly, origin is lost at the call site
|
|
13
|
+
from src.tokenizer import Tokenizer
|
|
14
|
+
from src.model import VisionEncoder, TextDecoder
|
|
15
|
+
from src.dataset import ImageCaptionDataset
|
|
16
|
+
|
|
17
|
+
tokenizer = Tokenizer(config)
|
|
18
|
+
encoder = VisionEncoder(config)
|
|
19
|
+
|
|
20
|
+
# ✅ GOOD — module imported, origin is visible at the call site
|
|
21
|
+
from src import tokenizer as tokenizer_module
|
|
22
|
+
from src import model as model_module
|
|
23
|
+
from src import dataset as dataset_module
|
|
24
|
+
|
|
25
|
+
tokenizer = tokenizer_module.Tokenizer(config)
|
|
26
|
+
encoder = model_module.VisionEncoder(config)
|
|
27
|
+
dataset = dataset_module.ImageCaptionDataset(config)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Exceptions
|
|
31
|
+
|
|
32
|
+
Standard library and well-known third-party modules where the source is universally understood may be imported directly:
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
# These are fine
|
|
36
|
+
import torch
|
|
37
|
+
import numpy as np
|
|
38
|
+
import lightning as L
|
|
39
|
+
import pathlib
|
|
40
|
+
import dataclasses
|
|
41
|
+
```
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Python naming conventions — full words, no abbreviations
|
|
3
|
+
globs: **/*.py
|
|
4
|
+
alwaysApply: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Naming Conventions: Prefer Full Words
|
|
8
|
+
|
|
9
|
+
Use long, descriptive names. A reader should understand what a variable holds or what a function does without any surrounding context. Avoid abbreviations and acronyms unless they are universally understood (e.g. `url`, `id`).
|
|
10
|
+
|
|
11
|
+
## Variables
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
# ❌ BAD
|
|
15
|
+
img = load(p)
|
|
16
|
+
hist = compute_hist(img)
|
|
17
|
+
res = run(cfg)
|
|
18
|
+
|
|
19
|
+
# ✅ GOOD
|
|
20
|
+
image = load_image(path)
|
|
21
|
+
image_histogram = compute_image_histogram(image)
|
|
22
|
+
result = run_training(config)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Functions
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
# ❌ BAD
|
|
29
|
+
def proc_img(p): ...
|
|
30
|
+
def calc_loss(pred, tgt): ...
|
|
31
|
+
def get_cfg(): ...
|
|
32
|
+
|
|
33
|
+
# ✅ GOOD
|
|
34
|
+
def process_image(path): ...
|
|
35
|
+
def calculate_loss(prediction, target): ...
|
|
36
|
+
def load_config(): ...
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Allowed Short Names
|
|
40
|
+
|
|
41
|
+
Only use single-letter or abbreviated names for:
|
|
42
|
+
|
|
43
|
+
- Loop indices: `i`, `j`, `k`
|
|
44
|
+
- Math coordinates: `x`, `y`, `z`
|
|
45
|
+
- Throwaway unpacking: `_`
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
for i, image in enumerate(images):
|
|
49
|
+
...
|
|
50
|
+
|
|
51
|
+
x, y, z = position
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Common Substitutions
|
|
55
|
+
|
|
56
|
+
| ❌ Avoid | ✅ Use instead |
|
|
57
|
+
|----------|----------------|
|
|
58
|
+
| `img` | `image` |
|
|
59
|
+
| `cfg` | `config` |
|
|
60
|
+
| `res` / `ret` | `result` |
|
|
61
|
+
| `pred` | `prediction` |
|
|
62
|
+
| `tgt` | `target` |
|
|
63
|
+
| `src` | `source` |
|
|
64
|
+
| `dst` | `destination` |
|
|
65
|
+
| `buf` | `buffer` |
|
|
66
|
+
| `num_` prefix | `count_` or spell out (e.g. `number_of_epochs`) |
|
|
67
|
+
| `tmp` | `temporary_...` or a descriptive name |
|
|
68
|
+
| `p` / `fp` | `path` / `file_path` |
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Python testing conventions — pytest, colocated tests, fixtures
|
|
3
|
+
globs: **/*_test.py
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Testing Conventions
|
|
8
|
+
|
|
9
|
+
## File Location
|
|
10
|
+
|
|
11
|
+
Place test files next to the file they test, using the `_test.py` suffix:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
dataset.py
|
|
15
|
+
dataset_test.py
|
|
16
|
+
|
|
17
|
+
model.py
|
|
18
|
+
model_test.py
|
|
19
|
+
|
|
20
|
+
trainer.py
|
|
21
|
+
trainer_test.py
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Use `@pytest.fixture` Instead of Test Classes
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
# ❌ BAD — unittest-style classes
|
|
28
|
+
class TestDataset(unittest.TestCase):
|
|
29
|
+
def setUp(self):
|
|
30
|
+
self.dataset = Dataset("data/train")
|
|
31
|
+
|
|
32
|
+
def test_length(self):
|
|
33
|
+
self.assertEqual(len(self.dataset), 100)
|
|
34
|
+
|
|
35
|
+
# ✅ GOOD — fixtures
|
|
36
|
+
@pytest.fixture
|
|
37
|
+
def training_dataset():
|
|
38
|
+
return Dataset("data/train")
|
|
39
|
+
|
|
40
|
+
def test_dataset_length(training_dataset):
|
|
41
|
+
assert len(training_dataset) == 100
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Use `@pytest.mark.parametrize` for Multiple Scenarios
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
# ❌ BAD — duplicated test functions
|
|
48
|
+
def test_normalise_zero():
|
|
49
|
+
assert normalise(0.0) == 0.0
|
|
50
|
+
|
|
51
|
+
def test_normalise_one():
|
|
52
|
+
assert normalise(255.0) == 1.0
|
|
53
|
+
|
|
54
|
+
# ✅ GOOD — parametrized
|
|
55
|
+
@pytest.mark.parametrize("pixel_value, expected", [
|
|
56
|
+
(0.0, 0.0),
|
|
57
|
+
(255.0, 1.0),
|
|
58
|
+
(127.5, 0.5),
|
|
59
|
+
])
|
|
60
|
+
def test_normalise_pixel(pixel_value, expected):
|
|
61
|
+
assert normalise(pixel_value) == expected
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## General Rules
|
|
65
|
+
|
|
66
|
+
- Use plain `assert` statements — no `assertEqual`, `assertTrue`, etc.
|
|
67
|
+
- Name tests `test_<what it does>`, not `test_<function name>`
|
|
68
|
+
- Keep each test focused on one behaviour
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
# Temporary file for partial code execution
|
|
204
|
+
tempCodeRunnerFile.py
|
|
205
|
+
|
|
206
|
+
# Ruff stuff:
|
|
207
|
+
.ruff_cache/
|
|
208
|
+
|
|
209
|
+
# PyPI configuration file
|
|
210
|
+
.pypirc
|
|
211
|
+
|
|
212
|
+
# Marimo
|
|
213
|
+
marimo/_static/
|
|
214
|
+
marimo/_lsp/
|
|
215
|
+
__marimo__/
|
|
216
|
+
|
|
217
|
+
# Streamlit
|
|
218
|
+
.streamlit/secrets.toml
|