Skip to content

Commit 93b366e

Browse files
committed
docs: update migration guide
1 parent 6a81024 commit 93b366e

1 file changed

Lines changed: 61 additions & 74 deletions

File tree

docs/getting_started/migration.md

Lines changed: 61 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
# Migrating from v1 to v2
22

3-
DeepTab v2 keeps the part of v1 you use most, the `fit` / `predict` / `evaluate`
4-
workflow, and rebuilds everything around it. The package layout, the configuration
5-
objects, and a handful of import paths changed, so existing v1 code needs a few
6-
edits before it runs on v2. This page walks through each change and shows the
7-
before and after side by side.
3+
DeepTab v2 keeps the `fit` / `predict` / `evaluate` workflow you already know and
4+
rebuilds the rest around it. The package layout, the configuration objects, and a
5+
few import paths changed, so v1 code needs a handful of edits before it runs. This
6+
page walks through each change with before and after examples.
87

98
```{warning}
109
**v2 is not backward compatible with v1, and v1 is no longer maintained.** The v1
1110
branch receives no bug fixes or security updates. If you are not ready to upgrade,
12-
pin `deeptab<2.0` for now and plan the move when you can.
11+
pin `deeptab<2.0` and plan the move when you can.
1312
```
1413

1514
## Before you upgrade
1615

17-
Pin the major version you are testing against so an upgrade never surprises a
18-
running pipeline:
16+
Pin the major version you test against so a future release never surprises a running
17+
pipeline:
1918

2019
```bash
2120
pip install "deeptab>=2.0,<3.0"
2221
```
2322

24-
Most projects only touch two things: how the estimator is constructed, and a few
25-
import lines. If your code only ever called `Model().fit(...)` and `predict(...)`
26-
with default settings, the change is small. If you reached into internal modules,
27-
read the [Import paths](import-paths) section closely.
23+
Most projects only touch two things: how the estimator is built, and a few import
24+
lines. If you only ever called `Model().fit(...)` and `predict(...)` with defaults,
25+
the change is small. If you imported from internal modules, read [Import
26+
paths](import-paths) closely.
2827

29-
## The change almost every project needs: split configs
28+
## Split configs
3029

31-
In v1, architecture, preprocessing, and training options were all flat keyword
32-
arguments on the estimator. In v2 those same options live in three focused config
33-
objects, so you can tune one concern without disturbing the others.
30+
This is the one change almost every project needs. In v1, architecture,
31+
preprocessing, and training options were flat keyword arguments on the estimator. In
32+
v2 they live in three focused config objects, so you can tune one concern without
33+
touching the others.
3434

3535
```python
3636
# v1: every option flat on the estimator
@@ -50,39 +50,37 @@ from deeptab.models import MambularClassifier
5050
from deeptab.configs import MambularConfig, PreprocessingConfig, TrainerConfig
5151

5252
model = MambularClassifier(
53-
model_config=MambularConfig(d_model=128, n_layers=4), # architecture
54-
preprocessing_config=PreprocessingConfig(numerical_preprocessing="ple"), # features
55-
trainer_config=TrainerConfig(lr=1e-3), # training
53+
model_config=MambularConfig(d_model=128, n_layers=4), # architecture
54+
preprocessing_config=PreprocessingConfig(numerical_preprocessing="ple"), # features
55+
trainer_config=TrainerConfig(lr=1e-3), # training
5656
)
5757
```
5858

5959
Each option moves to the config that owns its concern:
6060

61-
| Where the v1 argument went | Lives in v2 on | Typical fields |
62-
| -------------------------- | --------------------- | ---------------------------------------------------------------- |
63-
| Neural architecture | `<Model>Config` | `d_model`, `n_layers`, `n_heads`, `dropout`, `layer_sizes` |
64-
| Feature handling | `PreprocessingConfig` | `numerical_preprocessing`, `categorical_preprocessing`, `n_bins` |
65-
| Training and optimizer | `TrainerConfig` | `max_epochs`, `batch_size`, `lr`, `patience`, `optimizer_type` |
61+
| v1 argument was about | Now lives on | Typical fields |
62+
| ---------------------- | --------------------- | ---------------------------------------------------------------- |
63+
| Neural architecture | `<Model>Config` | `d_model`, `n_layers`, `n_heads`, `dropout`, `layer_sizes` |
64+
| Feature handling | `PreprocessingConfig` | `numerical_preprocessing`, `categorical_preprocessing`, `n_bins` |
65+
| Training and optimizer | `TrainerConfig` | `max_epochs`, `batch_size`, `lr`, `patience`, `optimizer_type` |
6666

6767
```{important}
68-
The flat keyword arguments from v1 are no longer accepted. Passing them, for
69-
example `MambularClassifier(d_model=128)`, now raises a `TypeError`. Move every
70-
setting into the matching config object.
68+
Flat v1 keyword arguments are no longer accepted. A call like
69+
`MambularClassifier(d_model=128)` now raises a `TypeError`. Move every setting into
70+
its config object.
7171
```
7272

7373
```{tip}
74-
All three configs are optional. `MambularClassifier()` with no arguments uses
75-
sensible defaults for architecture, preprocessing, and training, so you only build
76-
the configs whose defaults you actually want to change.
74+
All three configs are optional. `MambularClassifier()` runs on sensible defaults, so
75+
you only build the configs whose defaults you want to change.
7776
```
7877

79-
For the full field reference and which config owns each setting, see the
80-
[Config System](../core_concepts/config_system) guide.
78+
The [Config System](../core_concepts/config_system) guide is the full field reference.
8179

8280
## Config class renames
8381

84-
The configuration classes dropped their `Default` prefix. The rename is mechanical,
85-
so a find and replace across your codebase covers it.
82+
Configuration classes dropped their `Default` prefix and moved to `deeptab.configs`.
83+
A find and replace covers it.
8684

8785
| v1 | v2 |
8886
| ---------------------------- | --------------------- |
@@ -98,18 +96,12 @@ from deeptab.models import DefaultMambularConfig
9896
from deeptab.configs import MambularConfig
9997
```
10098

101-
```{note}
102-
Config classes now live under `deeptab.configs`, not alongside the models. Importing
103-
them from `deeptab.configs` is the supported path going forward.
104-
```
105-
10699
(import-paths)=
107100

108101
## Import paths
109102

110-
The internal package layout was reorganised under the `deeptab` namespace. The
111-
high-level estimators are still imported from `deeptab.models`, but supporting
112-
pieces moved to dedicated subpackages:
103+
The package was reorganised under the `deeptab` namespace. Estimators still come from
104+
`deeptab.models`; supporting pieces moved to dedicated subpackages:
113105

114106
| What you import | v2 location |
115107
| ---------------------------------------------------------------- | ----------------------- |
@@ -121,31 +113,30 @@ pieces moved to dedicated subpackages:
121113
| Top-level helpers (`InferenceModel`, `set_seed`, `seed_context`) | `deeptab` |
122114

123115
```{tip}
124-
If an import fails after upgrading, check whether you were importing from an
125-
internal v1 module. Code that only used the public estimator and config imports
126-
above needs the least work.
116+
If an import breaks after upgrading, it was probably reaching into an internal v1
117+
module. Code that used only the public estimator and config imports needs the least
118+
work.
127119
```
128120

129121
## Data layer renames
130122

131-
The data modules were renamed to give the pipeline a clear, typed contract:
123+
The data classes were renamed to give the pipeline a clear, typed contract. The old
124+
`Mambular*` aliases are deprecated.
132125

133126
| v1 | v2 |
134127
| ------------------------------- | ------------------- |
135128
| `Mambular*` data module aliases | `TabularDataModule` |
136129
| `Mambular*` dataset aliases | `TabularDataset` |
137130

138-
The v2 data layer also adds `FeatureSchema`, an inspectable description of the
139-
columns a model expects, their order, and their types. You rarely build these by
140-
hand; DeepTab constructs them from your data during `fit` and stores the schema
141-
inside saved artifacts. The old `Mambular*` aliases are deprecated.
131+
v2 also adds `FeatureSchema`, an inspectable description of the columns a model
132+
expects, their order, and their types. You rarely build one by hand: DeepTab derives
133+
it from your data during `fit` and stores it inside saved artifacts.
142134

143135
## Saving, loading, and serving
144136

145-
Persistence in v2 goes through a single self-describing `.deeptab` artifact that
146-
bundles the architecture, feature schema, preprocessing, task type, and package
147-
versions alongside the weights. A saved model therefore carries everything it needs
148-
to reload itself.
137+
Persistence goes through a single self-describing `.deeptab` artifact that bundles
138+
the architecture, feature schema, preprocessing, task type, and package versions
139+
alongside the weights. A saved model carries everything it needs to reload itself.
149140

150141
```python
151142
# Save a fitted estimator
@@ -162,28 +153,28 @@ predictions = served.predict(X_new)
162153
```
163154

164155
```{note}
165-
`InferenceModel` exposes only prediction and input-validation methods. Training is
166-
deliberately absent, so a served model cannot be re-fitted by accident. See
156+
`InferenceModel` exposes prediction and input validation only. Training is absent by
157+
design, so a served model cannot be re-fitted by accident. See
167158
[Inference](../core_concepts/inference) for the full serving surface.
168159
```
169160

170161
## Experimental models
171162

172-
The experimental models, ModernNCA, Tangos, and Trompt, import from a separate
173-
namespace so their less stable status is explicit:
163+
ModernNCA, Tangos, and Trompt import from a separate namespace that makes their less
164+
stable status explicit:
174165

175166
```python
176167
from deeptab.models.experimental import ModernNCAClassifier, TangosRegressor, TromptClassifier
177168
```
178169

179170
```{warning}
180-
Experimental models may change in minor releases. Pin an exact version, for example
181-
`deeptab==2.0.0`, if you depend on one in production.
171+
Experimental models may change in minor releases. Pin an exact version such as
172+
`deeptab==2.0.0` if you depend on one in production.
182173
```
183174

184175
## What did not change
185176

186-
The day-to-day modeling surface is intentionally stable:
177+
The day to day modeling surface is intentionally stable:
187178

188179
- `fit`, `predict`, `predict_proba`, and `evaluate` behave exactly as in v1.
189180
- DeepTab is still scikit-learn compatible, including use inside `GridSearchCV`.
@@ -193,22 +184,18 @@ The day-to-day modeling surface is intentionally stable:
193184

194185
## Upgrade checklist
195186

196-
Use this as a quick pass over a v1 codebase:
197-
198187
1. Pin `deeptab>=2.0,<3.0` and install into a clean environment.
199-
2. Move flat estimator arguments into `MambularConfig` / `PreprocessingConfig` /
200-
`TrainerConfig` (or the config for your model).
201-
3. Rename `Default<Arch>Config` to `<Arch>Config` and import it from
202-
`deeptab.configs`.
188+
2. Move flat estimator arguments into `MambularConfig`, `PreprocessingConfig`, and
189+
`TrainerConfig` (or the configs for your model).
190+
3. Rename `Default<Arch>Config` to `<Arch>Config` and import it from `deeptab.configs`.
203191
4. Update imports: estimators from `deeptab.models`, configs from `deeptab.configs`,
204192
data classes from `deeptab.data`.
205-
5. Replace any `Mambular*` data module or dataset references with
206-
`TabularDataModule` and `TabularDataset`.
207-
6. Run your training script. A `TypeError` on the estimator constructor almost
208-
always means a setting still needs to move into a config object.
193+
5. Replace `Mambular*` data module and dataset references with `TabularDataModule`
194+
and `TabularDataset`.
195+
6. Run your training script. A `TypeError` from the constructor almost always means a
196+
setting still needs to move into a config.
209197

210198
```{seealso}
211-
The [FAQ](faq) answers common upgrade questions and the v1 support policy. The
212-
[Config System](../core_concepts/config_system) guide is the authoritative field
213-
reference for the three config objects.
199+
The [FAQ](faq) covers common upgrade questions and the v1 support policy. The [Config
200+
System](../core_concepts/config_system) guide is the authoritative field reference.
214201
```

0 commit comments

Comments
 (0)