Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 34 additions & 9 deletions MIGRATION_v3_to_v4.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,23 @@ python -m adcp.migrate v3-to-v4 ./src --auto-apply
python -m adcp.migrate v3-to-v4 ./src --json
```

`--auto-apply` implies `--apply` and additionally rewrites the ~78% of findings
that are mechanically safe: `from adcp.types.generated_poc.X import Symbol` lines
where every symbol has a known public alias on `adcp.types`, and `Assets<N>` numbered
classes that have a documented semantic alias (`Assets81 → VideoFormatAsset`, etc.).
`flag_removed` findings always require human attention.
`--apply` rewrites the nine `<Type>Asset` renames and every
`adcp.types.generated_poc` import path to `adcp.types.domains`, where the
generated tree lives from 9.0 under the same module stems (see
[generated_poc brand split](#generated_poc-brand-split) for the one stem that
did not move whole). `--auto-apply` implies `--apply` and additionally rewrites
the findings that are mechanically safe: `from adcp.types.generated_poc.X import
Symbol` lines where every symbol has a known public alias on `adcp.types` are
imported from there instead of the domain path, and `Assets<N>` numbered classes
that have a documented semantic alias (`Assets81 → VideoFormatAsset`, etc.) are
renamed. `flag_removed` findings always require human attention.

Since the `generated_poc` → `domains` rename landed (#1417), a dry run whose only
findings are deprecated `generated_poc` import paths exits 0: those are mechanical
`rename_import` entries under `applied`, no longer `flag_private` entries. A CI
drift gate that relied on the exit code to catch them should read `--json` and
fail on a non-empty `applied` list (or simply run `--apply` in CI and fail on a
dirty tree).

The CLI exits 0 when all remaining findings are mechanical (or none); exits 1 when
`flag_removed` findings remain for human review — wire it into CI to gate merges
Expand Down Expand Up @@ -78,10 +90,10 @@ felt blast radius, work in this order:
re-export to the rest of your codebase (e.g. a `_base.py` schema barrel).
Fix those before anything else — most of your test-collection failures
disappear.
2. **`adcp.types.generated_poc` reach-ins.** The codemod's per-symbol mapping
tells you the public alias for each (`ContextObject` →
`adcp.types.ContextObject`, etc.). Mechanical lookup once you know the
pattern.
2. **`adcp.types.generated_poc` reach-ins.** `--apply` renames the path to
`adcp.types.domains`, and the report's hint names the public alias where a
symbol has one (`ContextObject` → `adcp.types.ContextObject`, etc.) so
`--auto-apply` can import it from the flat surface instead.
3. **Numbered `Assets<N>` imports.** Switch to the semantic alias from
`adcp.types`. See [Numbered discriminated-union classes
shifted](#numbered-discriminated-union-classes-shifted) below.
Expand Down Expand Up @@ -317,6 +329,19 @@ result = await registry.lookup_brand("nike.com")
manifest = result.brand # Only `.brand`
```

## generated_poc brand split

`brand.json` shares its basename with the `brand/*.json` task schemas, so the
pre-9.0 `adcp.types.generated_poc.brand` module *was* that discovery schema
(`Brand`, `LocalizedName`, 138 more), while `adcp.types.domains.brand` is the
aggregator over `domains/brand/<schema>.py`. The discovery classes are at
`adcp.types.domains.brand_discovery`. `adcp migrate v3-to-v4 --apply` resolves
each imported name to its half — a line that mixes the two becomes two import
statements — and flags what it cannot place: a bare module reference such as
`import adcp.types.generated_poc.brand as b` or a name neither half binds.
Rewrite those by hand with the two module paths above. The deprecated name
keeps serving both halves through 9.x; see `docs/types-9-migration.md`.

## Numbered discriminated-union classes shifted

`datamodel-code-generator` numbers variant classes in the order they appear in
Expand Down
7 changes: 6 additions & 1 deletion docs/types-9-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ deleted and the generated models go back to agreeing with their schema.
+from adcp.types.domains.media_buy.package_request import PackageRequest
```

`adcp migrate v3-to-v4` rewrites those lines. The old path also still
`adcp migrate v3-to-v4 --apply` rewrites those lines, and `--auto-apply`
additionally imports a name from `adcp.types` when every name on the line is
bound there. The old path also still
resolves through the whole 9.x line, emitting a `DeprecationWarning` that
names the new one — #1360 measured 110 such imports in a single production
seller, and 9.0 does not break all of them at once. **It is removed in
Expand All @@ -250,6 +252,9 @@ deleted and the generated models go back to agreeing with their schema.
+from adcp.types.domains.brand_discovery import Brand, LocalizedName
```

The codemod resolves this split per imported name — a line that mixes the
two halves becomes two import statements — and flags a bare
`adcp.types.generated_poc.brand` module reference it cannot place.
The deprecated name keeps serving both halves for the 9.x line, so an
unmigrated `from adcp.types.generated_poc.brand import Brand` still works and
still returns the canonical class. It is the one deprecated name that is a
Expand Down
5 changes: 3 additions & 2 deletions src/adcp/migrate/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ def main() -> int:
"usage: python -m adcp.migrate <migration> <path> [options]\n"
"\n"
"Migrations:\n"
" v3-to-v4 Rewrite <Type>Asset → <Type>Content and flag\n"
" removed-type usages (BrandManifest, DeliverTo, etc).\n"
" v3-to-v4 Rewrite <Type>Asset → <Type>Content, rename\n"
" adcp.types.generated_poc imports to adcp.types.domains,\n"
" and flag removed-type usages (BrandManifest, DeliverTo, etc).\n"
"\n"
"Run `python -m adcp.migrate <migration> --help` for per-migration options.\n",
file=sys.stderr,
Expand Down
Loading
Loading