cli-pydantic 0.2.0__py3-none-any.whl → 0.2.1__py3-none-any.whl
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.
cli_pydantic/lib.py
CHANGED
|
@@ -104,12 +104,12 @@ def model_help(model: type[BaseModel], prefix: str = "") -> list[str]:
|
|
|
104
104
|
if field.default is PydanticUndefined
|
|
105
105
|
else f" (default: {field.default})"
|
|
106
106
|
)
|
|
107
|
-
desc = field.description
|
|
107
|
+
desc = f" {field.description}" if field.description else ""
|
|
108
108
|
out.append((f"--{key} {ty_name(ann)}", f"{desc}{default}"))
|
|
109
109
|
return out
|
|
110
110
|
|
|
111
111
|
items = entries(model, prefix)
|
|
112
|
-
col = max((len(f) for f, _ in items), default=0) +
|
|
112
|
+
col = max((len(f) for f, _ in items), default=0) + 1
|
|
113
113
|
return [f" {f:<{col}}{h}" for f, h in items]
|
|
114
114
|
|
|
115
115
|
|
|
@@ -152,9 +152,10 @@ def cli[T: BaseModel](model_cls: type[T], desc: str = "") -> T:
|
|
|
152
152
|
|
|
153
153
|
def print_help():
|
|
154
154
|
prog = Path(sys.argv[0]).name
|
|
155
|
-
lines = [
|
|
155
|
+
lines = []
|
|
156
156
|
if desc:
|
|
157
|
-
lines.append(f"
|
|
157
|
+
lines.append(f"help: {desc}\n")
|
|
158
|
+
lines.append(f"usage: {prog} [-h] [configs ...] [--overrides ...]")
|
|
158
159
|
lines.append("\nconfig arguments:")
|
|
159
160
|
lines.extend(model_help(model_cls))
|
|
160
161
|
print("\n".join(lines))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: cli-pydantic
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Add your description here
|
|
5
5
|
Author: Tom Pollak
|
|
6
6
|
Author-email: Tom Pollak <tomp@graphcore.ai>
|
|
@@ -25,8 +25,7 @@ pip install cli-pydantic
|
|
|
25
25
|
## Usage
|
|
26
26
|
|
|
27
27
|
```python
|
|
28
|
-
|
|
29
|
-
from pydantic import BaseModel
|
|
28
|
+
from pydantic import BaseModel, Field
|
|
30
29
|
from cli_pydantic import cli
|
|
31
30
|
|
|
32
31
|
class Data(BaseModel):
|
|
@@ -42,7 +41,7 @@ class Config(BaseModel):
|
|
|
42
41
|
data: Data = Data()
|
|
43
42
|
model: Model = Model()
|
|
44
43
|
epochs: int = 10
|
|
45
|
-
|
|
44
|
+
profile: bool = Field(False, description="dump chrome trace")
|
|
46
45
|
|
|
47
46
|
cfg = cli(Config, desc="Training pipeline")
|
|
48
47
|
```
|
|
@@ -58,7 +57,7 @@ python train.py base.yaml
|
|
|
58
57
|
python train.py base.yaml fast.yaml --model.lr 0.05 --epochs 3
|
|
59
58
|
|
|
60
59
|
# Lists and booleans
|
|
61
|
-
python train.py --model.layers 16,32 --
|
|
60
|
+
python train.py --model.layers 16,32 --profile
|
|
62
61
|
```
|
|
63
62
|
|
|
64
63
|
## Semantics:
|
|
@@ -67,3 +66,21 @@ python train.py --model.layers 16,32 --verbose
|
|
|
67
66
|
- For lists: `--nums=1,2,3` or `--nums 1 --nums=2 --nums 3`
|
|
68
67
|
- For bools: `--enable` / `--no-enable`
|
|
69
68
|
- Lists will _replace_ previous configs on override -- not append!
|
|
69
|
+
|
|
70
|
+
## Automatic help
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
$ python train.py --help
|
|
74
|
+
help: Training pipeline
|
|
75
|
+
|
|
76
|
+
usage: train.py [-h] [configs ...] [--overrides ...]
|
|
77
|
+
|
|
78
|
+
config arguments:
|
|
79
|
+
--data.path str (default: ./data)
|
|
80
|
+
--data.splits list[str] (default: ['train', 'val'])
|
|
81
|
+
--model.arch str (default: resnet50)
|
|
82
|
+
--model.lr float (default: 0.001)
|
|
83
|
+
--model.layers list[int] (default: [64, 128, 256])
|
|
84
|
+
--epochs int (default: 10)
|
|
85
|
+
--verbose bool dump chrome trace (default: False)
|
|
86
|
+
```
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
cli_pydantic/__init__.py,sha256=FzDWd6rL0-KFfomhD6Zfa_Au9y9g7jznspke55BFHbI,40
|
|
2
|
+
cli_pydantic/lib.py,sha256=UE-pjLAzo4E5g0Mqz7SkpR9OQDm8WtCDLOvHyQEFccs,5661
|
|
3
|
+
cli_pydantic/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
cli_pydantic-0.2.1.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
|
|
5
|
+
cli_pydantic-0.2.1.dist-info/METADATA,sha256=eoaU3Cr9uFSilxNQyVE7w6efqN-Rx6h9lF-DcxpwuNY,2093
|
|
6
|
+
cli_pydantic-0.2.1.dist-info/RECORD,,
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
cli_pydantic/__init__.py,sha256=FzDWd6rL0-KFfomhD6Zfa_Au9y9g7jznspke55BFHbI,40
|
|
2
|
-
cli_pydantic/lib.py,sha256=vZsv9rSlYmL-aIDKD1Y-cRE3ElhkKzdI82cpeLVmDbY,5603
|
|
3
|
-
cli_pydantic/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
cli_pydantic-0.2.0.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
|
|
5
|
-
cli_pydantic-0.2.0.dist-info/METADATA,sha256=oR2y5ZDl6-9xvRW7xoEV24iTkRhO4g2yTxrlk15kLdw,1556
|
|
6
|
-
cli_pydantic-0.2.0.dist-info/RECORD,,
|
|
File without changes
|