amagi-model-sunset 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.
- amagi_model_sunset-0.1.0/LICENSE +21 -0
- amagi_model_sunset-0.1.0/PKG-INFO +141 -0
- amagi_model_sunset-0.1.0/README.md +123 -0
- amagi_model_sunset-0.1.0/pyproject.toml +35 -0
- amagi_model_sunset-0.1.0/setup.cfg +4 -0
- amagi_model_sunset-0.1.0/src/amagi_model_sunset/__init__.py +3 -0
- amagi_model_sunset-0.1.0/src/amagi_model_sunset/__main__.py +5 -0
- amagi_model_sunset-0.1.0/src/amagi_model_sunset/cli.py +135 -0
- amagi_model_sunset-0.1.0/src/amagi_model_sunset/core.py +195 -0
- amagi_model_sunset-0.1.0/src/amagi_model_sunset/data/models.json +1662 -0
- amagi_model_sunset-0.1.0/src/amagi_model_sunset.egg-info/PKG-INFO +141 -0
- amagi_model_sunset-0.1.0/src/amagi_model_sunset.egg-info/SOURCES.txt +15 -0
- amagi_model_sunset-0.1.0/src/amagi_model_sunset.egg-info/dependency_links.txt +1 -0
- amagi_model_sunset-0.1.0/src/amagi_model_sunset.egg-info/entry_points.txt +2 -0
- amagi_model_sunset-0.1.0/src/amagi_model_sunset.egg-info/requires.txt +3 -0
- amagi_model_sunset-0.1.0/src/amagi_model_sunset.egg-info/top_level.txt +1 -0
- amagi_model_sunset-0.1.0/tests/test_core.py +191 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Amagisolutionsgroup, Inc. (AmagiLabs)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: amagi-model-sunset
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Finds hard-coded LLM model ids in your repo and tells you which ones the provider is retiring, and when
|
|
5
|
+
Author-email: "AmagiLabs (Amagisolutionsgroup, Inc.)" <dev@amagisolutionsgroup.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: llm,openai,anthropic,gemini,deprecation,ci,cli
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Requires-Python: >=3.9
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Provides-Extra: dev
|
|
16
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# amagi-model-sunset
|
|
20
|
+
|
|
21
|
+
Scans your repo for hard-coded LLM model ids, tells you which ones OpenAI, Anthropic or Google has retired or is about to retire, and suggests the replacement. Built for developers and small teams who would rather find out in CI than from a 404 in production.
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pipx install amagi-model-sunset
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Python 3.9+, no dependencies. Nothing leaves your machine: it reads your files and a dated data file that ships with the package.
|
|
32
|
+
|
|
33
|
+
## Use
|
|
34
|
+
|
|
35
|
+
Point it at a project:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
amagi-model-sunset .
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This run is against the demo app in the repo (`examples/demo-app`: a Python file, a YAML config and an `.env.example`). `--today` pins the date so the output below is reproducible:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
amagi-model-sunset examples/demo-app --today 2026-11-16
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
config/llm.yaml:3 gemini-1.5-pro-002 -> RETIRED 2025-09-24 (418d ago)
|
|
49
|
+
suggest: gemini-3.6-flash
|
|
50
|
+
config/llm.yaml:4 gemini-1.5-pro-002 -> RETIRED 2025-09-24 (418d ago)
|
|
51
|
+
suggest: gemini-3.6-flash
|
|
52
|
+
config/llm.yaml:6 anthropic.claude-3-5-sonnet-20241022-v2:0 -> RETIRED 2025-10-28 (384d ago)
|
|
53
|
+
suggest: claude-sonnet-5-5
|
|
54
|
+
app.py:14 claude-3-opus-20240229 -> RETIRED 2026-01-05 (315d ago)
|
|
55
|
+
suggest: claude-opus-4-8
|
|
56
|
+
config/llm.yaml:7 us.anthropic.claude-3-opus-20240229-v1:0 -> RETIRED 2026-01-05 (315d ago)
|
|
57
|
+
suggest: claude-opus-4-8
|
|
58
|
+
.env.example:3 text-embedding-004 -> RETIRED 2026-01-14 (306d ago)
|
|
59
|
+
suggest: gemini-embedding-2
|
|
60
|
+
.env.example:2 gpt-4-turbo -> RETIRED 2026-10-23 (24d ago)
|
|
61
|
+
suggest: gpt-5.6-sol
|
|
62
|
+
app.py:6 gpt-4-0613 -> RETIRED 2026-10-23 (24d ago)
|
|
63
|
+
suggest: gpt-5.6-sol
|
|
64
|
+
config/llm.yaml:8 claude-sonnet-4-5-20250929 -> RETIRES 2026-11-30 (in 14d)
|
|
65
|
+
suggest: claude-sonnet-5-5
|
|
66
|
+
app.py:7 gpt-4o-mini -> RETIRES 2027-01-14 (in 59d)
|
|
67
|
+
suggest: gpt-6-luna
|
|
68
|
+
|
|
69
|
+
source: https://cloud.google.com/vertex-ai/generative-ai/docs/learn/model-versions (checked 2026-11-16)
|
|
70
|
+
source: https://platform.claude.com/docs/en/about-claude/model-deprecations (checked 2026-11-16)
|
|
71
|
+
source: https://ai.google.dev/gemini-api/docs/deprecations (checked 2026-11-16)
|
|
72
|
+
source: https://platform.openai.com/docs/deprecations (checked 2026-11-16)
|
|
73
|
+
scanned examples/demo-app: 8 model id(s) in 10 place(s): 6 retired, 2 retiring, 0 deprecated without a date, 0 ok
|
|
74
|
+
FAIL: 9 place(s) use a model that is retired or retires within 30 days
|
|
75
|
+
data checked 2026-11-16 against the providers' own pages; run with --format json for sources
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
It finds plain ids (`gpt-4-0613`), env defaults, YAML values, Bedrock ids and ARNs (`us.anthropic.claude-3-opus-20240229-v1:0`), Vertex paths and `@date` ids, and fine-tune ids (`ft:gpt-4o-mini-...`).
|
|
79
|
+
|
|
80
|
+
## Fail CI before the 404s start
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
amagi-model-sunset . --fail-within 30
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Exit code 1 when a model is already retired or retires within 30 days, 0 otherwise. Use `--fail-within 0` to fail only on models that are already gone. A GitHub Actions step:
|
|
87
|
+
|
|
88
|
+
```yaml
|
|
89
|
+
- run: pipx install amagi-model-sunset
|
|
90
|
+
- run: amagi-model-sunset . --fail-within 30 --exclude "docs/*"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Dates change, so run it on a weekly schedule as well as on pull requests.
|
|
94
|
+
|
|
95
|
+
More options:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
amagi-model-sunset . --format json # machine-readable, with source URL and checked-on date
|
|
99
|
+
amagi-model-sunset . --format md # table for a PR comment
|
|
100
|
+
amagi-model-sunset . --all # also list models with no announced retirement
|
|
101
|
+
amagi-model-sunset . --exclude "*.md" # skip files (repeatable)
|
|
102
|
+
amagi-model-sunset . --list-models # every id the data file knows
|
|
103
|
+
amagi-model-sunset . --data my-models.json # use your own or a newer data file
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Add `# model-sunset: ignore` to a line to skip it (a migration note, a test that checks old ids).
|
|
107
|
+
|
|
108
|
+
## Where the dates come from
|
|
109
|
+
|
|
110
|
+
`src/amagi_model_sunset/data/models.json` holds about 245 ids. Each entry carries the provider page it was copied from and the date it was checked (2026-11-16, or 2026-11-20 for rows added that day):
|
|
111
|
+
|
|
112
|
+
- OpenAI: https://platform.openai.com/docs/deprecations
|
|
113
|
+
- Anthropic: https://platform.claude.com/docs/en/about-claude/model-deprecations
|
|
114
|
+
- Google Gemini API: https://ai.google.dev/gemini-api/docs/deprecations
|
|
115
|
+
- Google Vertex AI (Gemini 1.x): https://cloud.google.com/vertex-ai/generative-ai/docs/learn/model-versions
|
|
116
|
+
|
|
117
|
+
Limits to know about:
|
|
118
|
+
|
|
119
|
+
- Entries marked `verified: false` were not confirmed on the provider page (older aliases that dropped off it). The tool labels them `[unverified date]`.
|
|
120
|
+
- "Suggest" is the provider's own recommendation, not a drop-in guarantee. Test prompts, limits and pricing before you switch.
|
|
121
|
+
- Anthropic's dates apply to the Claude API. Amazon Bedrock and Google-managed Vertex can use different dates, so check your platform's page for those ids.
|
|
122
|
+
- Models with no announced retirement show no date. Anthropic's "not sooner than" dates appear with `--all` and never fail a build.
|
|
123
|
+
- Retirement dates move. A data file that is months old is a risk: upgrade often, or pass `--data`.
|
|
124
|
+
|
|
125
|
+
## Keep the data current
|
|
126
|
+
|
|
127
|
+
The data file is plain JSON, and it is the part that goes stale. Found a changed date or a missing model? Open a PR that edits `scripts/build_data.py`, link the provider page, and run it to regenerate the file.
|
|
128
|
+
|
|
129
|
+
## Use it from Claude Code
|
|
130
|
+
|
|
131
|
+
`.claude/skills/amagi-model-sunset/SKILL.md` makes this a Claude Code skill. Ask "is my code using any retired models?" and Claude runs the scan and reports the replacements.
|
|
132
|
+
|
|
133
|
+
## If this saved you time
|
|
134
|
+
|
|
135
|
+
A star helps others find it. If it caught a model before it broke production, tell us what it found.
|
|
136
|
+
|
|
137
|
+
More from AmagiLabs: [github.com/amagilabs](https://github.com/amagilabs).
|
|
138
|
+
|
|
139
|
+
## License
|
|
140
|
+
|
|
141
|
+
MIT. Copyright (c) 2026 Amagisolutionsgroup, Inc. (AmagiLabs).
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# amagi-model-sunset
|
|
2
|
+
|
|
3
|
+
Scans your repo for hard-coded LLM model ids, tells you which ones OpenAI, Anthropic or Google has retired or is about to retire, and suggests the replacement. Built for developers and small teams who would rather find out in CI than from a 404 in production.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pipx install amagi-model-sunset
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Python 3.9+, no dependencies. Nothing leaves your machine: it reads your files and a dated data file that ships with the package.
|
|
14
|
+
|
|
15
|
+
## Use
|
|
16
|
+
|
|
17
|
+
Point it at a project:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
amagi-model-sunset .
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
This run is against the demo app in the repo (`examples/demo-app`: a Python file, a YAML config and an `.env.example`). `--today` pins the date so the output below is reproducible:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
amagi-model-sunset examples/demo-app --today 2026-11-16
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
config/llm.yaml:3 gemini-1.5-pro-002 -> RETIRED 2025-09-24 (418d ago)
|
|
31
|
+
suggest: gemini-3.6-flash
|
|
32
|
+
config/llm.yaml:4 gemini-1.5-pro-002 -> RETIRED 2025-09-24 (418d ago)
|
|
33
|
+
suggest: gemini-3.6-flash
|
|
34
|
+
config/llm.yaml:6 anthropic.claude-3-5-sonnet-20241022-v2:0 -> RETIRED 2025-10-28 (384d ago)
|
|
35
|
+
suggest: claude-sonnet-5-5
|
|
36
|
+
app.py:14 claude-3-opus-20240229 -> RETIRED 2026-01-05 (315d ago)
|
|
37
|
+
suggest: claude-opus-4-8
|
|
38
|
+
config/llm.yaml:7 us.anthropic.claude-3-opus-20240229-v1:0 -> RETIRED 2026-01-05 (315d ago)
|
|
39
|
+
suggest: claude-opus-4-8
|
|
40
|
+
.env.example:3 text-embedding-004 -> RETIRED 2026-01-14 (306d ago)
|
|
41
|
+
suggest: gemini-embedding-2
|
|
42
|
+
.env.example:2 gpt-4-turbo -> RETIRED 2026-10-23 (24d ago)
|
|
43
|
+
suggest: gpt-5.6-sol
|
|
44
|
+
app.py:6 gpt-4-0613 -> RETIRED 2026-10-23 (24d ago)
|
|
45
|
+
suggest: gpt-5.6-sol
|
|
46
|
+
config/llm.yaml:8 claude-sonnet-4-5-20250929 -> RETIRES 2026-11-30 (in 14d)
|
|
47
|
+
suggest: claude-sonnet-5-5
|
|
48
|
+
app.py:7 gpt-4o-mini -> RETIRES 2027-01-14 (in 59d)
|
|
49
|
+
suggest: gpt-6-luna
|
|
50
|
+
|
|
51
|
+
source: https://cloud.google.com/vertex-ai/generative-ai/docs/learn/model-versions (checked 2026-11-16)
|
|
52
|
+
source: https://platform.claude.com/docs/en/about-claude/model-deprecations (checked 2026-11-16)
|
|
53
|
+
source: https://ai.google.dev/gemini-api/docs/deprecations (checked 2026-11-16)
|
|
54
|
+
source: https://platform.openai.com/docs/deprecations (checked 2026-11-16)
|
|
55
|
+
scanned examples/demo-app: 8 model id(s) in 10 place(s): 6 retired, 2 retiring, 0 deprecated without a date, 0 ok
|
|
56
|
+
FAIL: 9 place(s) use a model that is retired or retires within 30 days
|
|
57
|
+
data checked 2026-11-16 against the providers' own pages; run with --format json for sources
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
It finds plain ids (`gpt-4-0613`), env defaults, YAML values, Bedrock ids and ARNs (`us.anthropic.claude-3-opus-20240229-v1:0`), Vertex paths and `@date` ids, and fine-tune ids (`ft:gpt-4o-mini-...`).
|
|
61
|
+
|
|
62
|
+
## Fail CI before the 404s start
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
amagi-model-sunset . --fail-within 30
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Exit code 1 when a model is already retired or retires within 30 days, 0 otherwise. Use `--fail-within 0` to fail only on models that are already gone. A GitHub Actions step:
|
|
69
|
+
|
|
70
|
+
```yaml
|
|
71
|
+
- run: pipx install amagi-model-sunset
|
|
72
|
+
- run: amagi-model-sunset . --fail-within 30 --exclude "docs/*"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Dates change, so run it on a weekly schedule as well as on pull requests.
|
|
76
|
+
|
|
77
|
+
More options:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
amagi-model-sunset . --format json # machine-readable, with source URL and checked-on date
|
|
81
|
+
amagi-model-sunset . --format md # table for a PR comment
|
|
82
|
+
amagi-model-sunset . --all # also list models with no announced retirement
|
|
83
|
+
amagi-model-sunset . --exclude "*.md" # skip files (repeatable)
|
|
84
|
+
amagi-model-sunset . --list-models # every id the data file knows
|
|
85
|
+
amagi-model-sunset . --data my-models.json # use your own or a newer data file
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Add `# model-sunset: ignore` to a line to skip it (a migration note, a test that checks old ids).
|
|
89
|
+
|
|
90
|
+
## Where the dates come from
|
|
91
|
+
|
|
92
|
+
`src/amagi_model_sunset/data/models.json` holds about 245 ids. Each entry carries the provider page it was copied from and the date it was checked (2026-11-16, or 2026-11-20 for rows added that day):
|
|
93
|
+
|
|
94
|
+
- OpenAI: https://platform.openai.com/docs/deprecations
|
|
95
|
+
- Anthropic: https://platform.claude.com/docs/en/about-claude/model-deprecations
|
|
96
|
+
- Google Gemini API: https://ai.google.dev/gemini-api/docs/deprecations
|
|
97
|
+
- Google Vertex AI (Gemini 1.x): https://cloud.google.com/vertex-ai/generative-ai/docs/learn/model-versions
|
|
98
|
+
|
|
99
|
+
Limits to know about:
|
|
100
|
+
|
|
101
|
+
- Entries marked `verified: false` were not confirmed on the provider page (older aliases that dropped off it). The tool labels them `[unverified date]`.
|
|
102
|
+
- "Suggest" is the provider's own recommendation, not a drop-in guarantee. Test prompts, limits and pricing before you switch.
|
|
103
|
+
- Anthropic's dates apply to the Claude API. Amazon Bedrock and Google-managed Vertex can use different dates, so check your platform's page for those ids.
|
|
104
|
+
- Models with no announced retirement show no date. Anthropic's "not sooner than" dates appear with `--all` and never fail a build.
|
|
105
|
+
- Retirement dates move. A data file that is months old is a risk: upgrade often, or pass `--data`.
|
|
106
|
+
|
|
107
|
+
## Keep the data current
|
|
108
|
+
|
|
109
|
+
The data file is plain JSON, and it is the part that goes stale. Found a changed date or a missing model? Open a PR that edits `scripts/build_data.py`, link the provider page, and run it to regenerate the file.
|
|
110
|
+
|
|
111
|
+
## Use it from Claude Code
|
|
112
|
+
|
|
113
|
+
`.claude/skills/amagi-model-sunset/SKILL.md` makes this a Claude Code skill. Ask "is my code using any retired models?" and Claude runs the scan and reports the replacements.
|
|
114
|
+
|
|
115
|
+
## If this saved you time
|
|
116
|
+
|
|
117
|
+
A star helps others find it. If it caught a model before it broke production, tell us what it found.
|
|
118
|
+
|
|
119
|
+
More from AmagiLabs: [github.com/amagilabs](https://github.com/amagilabs).
|
|
120
|
+
|
|
121
|
+
## License
|
|
122
|
+
|
|
123
|
+
MIT. Copyright (c) 2026 Amagisolutionsgroup, Inc. (AmagiLabs).
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "amagi-model-sunset"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Finds hard-coded LLM model ids in your repo and tells you which ones the provider is retiring, and when"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "AmagiLabs (Amagisolutionsgroup, Inc.)", email = "dev@amagisolutionsgroup.com" }]
|
|
13
|
+
keywords = ["llm", "openai", "anthropic", "gemini", "deprecation", "ci", "cli"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
"Environment :: Console",
|
|
19
|
+
]
|
|
20
|
+
dependencies = []
|
|
21
|
+
|
|
22
|
+
[project.optional-dependencies]
|
|
23
|
+
dev = ["pytest>=7.0"]
|
|
24
|
+
|
|
25
|
+
[project.scripts]
|
|
26
|
+
amagi-model-sunset = "amagi_model_sunset.cli:main"
|
|
27
|
+
|
|
28
|
+
[tool.setuptools.packages.find]
|
|
29
|
+
where = ["src"]
|
|
30
|
+
|
|
31
|
+
[tool.setuptools.package-data]
|
|
32
|
+
amagi_model_sunset = ["data/*.json"]
|
|
33
|
+
|
|
34
|
+
[tool.pytest.ini_options]
|
|
35
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"""amagi-model-sunset command line."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
import datetime as dt
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
from collections import OrderedDict
|
|
10
|
+
from typing import List, Optional
|
|
11
|
+
|
|
12
|
+
from . import __version__
|
|
13
|
+
from .core import Hit, failing, load_data, scan_path
|
|
14
|
+
|
|
15
|
+
ORDER = {"retired": 0, "retiring": 1, "unknown-date": 2, "active": 3}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _label(h: Hit) -> str:
|
|
19
|
+
e = h.entry
|
|
20
|
+
if e.status == "retired":
|
|
21
|
+
return "RETIRED %s (%dd ago)" % (e.retires, -e.days_left)
|
|
22
|
+
if e.status == "retiring":
|
|
23
|
+
return "RETIRES %s (in %dd)" % (e.retires, e.days_left)
|
|
24
|
+
if e.status == "unknown-date":
|
|
25
|
+
return "DEPRECATED, no date"
|
|
26
|
+
return "ok"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _sorted(hits: List[Hit]) -> List[Hit]:
|
|
30
|
+
return sorted(hits, key=lambda h: (ORDER[h.entry.status], h.entry.days_left if h.entry.days_left is not None else 0,
|
|
31
|
+
h.path, h.line))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def render_text(hits: List[Hit], show_all: bool, failed: List[Hit], within: int, scanned: str) -> str:
|
|
35
|
+
shown = [h for h in _sorted(hits) if show_all or h.entry.status != "active"]
|
|
36
|
+
out = []
|
|
37
|
+
for h in shown:
|
|
38
|
+
e = h.entry
|
|
39
|
+
flag = "" if e.verified else " [unverified date]"
|
|
40
|
+
out.append("%s:%d %s -> %s%s" % (h.path, h.line, h.text, _label(h), flag))
|
|
41
|
+
if e.status != "active" and e.replacement:
|
|
42
|
+
out.append(" suggest: %s" % e.replacement)
|
|
43
|
+
elif e.status == "active" and e.not_before:
|
|
44
|
+
out.append(" no retirement announced; provider says not sooner than %s" % e.not_before)
|
|
45
|
+
uniq = OrderedDict()
|
|
46
|
+
for h in hits:
|
|
47
|
+
uniq.setdefault((h.entry.status, h.model), 0)
|
|
48
|
+
uniq[(h.entry.status, h.model)] += 1
|
|
49
|
+
n = lambda s: sum(1 for (st, _m) in uniq if st == s) # noqa: E731
|
|
50
|
+
out.append("")
|
|
51
|
+
srcs = OrderedDict()
|
|
52
|
+
for h in _sorted(hits):
|
|
53
|
+
if h.entry.status != "active":
|
|
54
|
+
srcs.setdefault(h.entry.source, h.entry.checked)
|
|
55
|
+
for src, checked in srcs.items():
|
|
56
|
+
out.append("source: %s (checked %s)" % (src, checked))
|
|
57
|
+
out.append("scanned %s: %d model id(s) in %d place(s): %d retired, %d retiring, %d deprecated without a date, %d ok"
|
|
58
|
+
% (scanned, len(uniq), len(hits), n("retired"), n("retiring"), n("unknown-date"), n("active")))
|
|
59
|
+
if failed:
|
|
60
|
+
out.append("FAIL: %d place(s) use a model that is retired or retires within %d days" % (len(failed), within))
|
|
61
|
+
else:
|
|
62
|
+
out.append("PASS: nothing retired or retiring within %d days" % within)
|
|
63
|
+
return "\n".join(out)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def render_md(hits: List[Hit], show_all: bool, failed: List[Hit], within: int) -> str:
|
|
67
|
+
shown = [h for h in _sorted(hits) if show_all or h.entry.status != "active"]
|
|
68
|
+
out = ["| status | file | model | replacement | source |", "|---|---|---|---|---|"]
|
|
69
|
+
for h in shown:
|
|
70
|
+
e = h.entry
|
|
71
|
+
out.append("| %s | `%s:%d` | `%s` | %s | %s |" % (_label(h), h.path, h.line, h.text, e.replacement or "-", e.source))
|
|
72
|
+
out.append("")
|
|
73
|
+
out.append("%s: %d place(s) retired or retiring within %d days." % ("FAIL" if failed else "PASS", len(failed), within))
|
|
74
|
+
return "\n".join(out)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
78
|
+
p = argparse.ArgumentParser(
|
|
79
|
+
prog="amagi-model-sunset",
|
|
80
|
+
description="Find hard-coded LLM model ids in a repo and report each one's announced retirement date.",
|
|
81
|
+
epilog="Exit codes: 0 clean, 1 a model is retired or retires within --fail-within days, 2 usage error.",
|
|
82
|
+
)
|
|
83
|
+
p.add_argument("path", nargs="?", default=".", help="directory or file to scan (default: current directory)")
|
|
84
|
+
p.add_argument("--fail-within", type=int, default=30, metavar="DAYS",
|
|
85
|
+
help="exit 1 if a model is already retired or retires within DAYS days (default 30; 0 = only retired)")
|
|
86
|
+
p.add_argument("--format", choices=["text", "json", "md"], default="text", help="output format")
|
|
87
|
+
p.add_argument("--all", action="store_true", help="also list models with no retirement announced")
|
|
88
|
+
p.add_argument("--exclude", action="append", default=[], metavar="GLOB",
|
|
89
|
+
help="skip files matching this glob (repeatable)")
|
|
90
|
+
p.add_argument("--data", metavar="FILE", help="use this models.json instead of the bundled one")
|
|
91
|
+
p.add_argument("--today", metavar="YYYY-MM-DD", help="pretend today is this date (for CI reproducibility)")
|
|
92
|
+
p.add_argument("--list-models", action="store_true", help="print every model id in the data file and exit")
|
|
93
|
+
p.add_argument("--version", action="version", version="amagi-model-sunset " + __version__)
|
|
94
|
+
return p
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def main(argv: Optional[List[str]] = None) -> int:
|
|
98
|
+
args = build_parser().parse_args(argv)
|
|
99
|
+
try:
|
|
100
|
+
today = dt.date.fromisoformat(args.today) if args.today else dt.date.today()
|
|
101
|
+
except ValueError:
|
|
102
|
+
print("error: --today must be YYYY-MM-DD", file=sys.stderr)
|
|
103
|
+
return 2
|
|
104
|
+
try:
|
|
105
|
+
data = load_data(args.data)
|
|
106
|
+
except (OSError, ValueError, KeyError) as exc:
|
|
107
|
+
print("error: cannot read data file: %s" % exc, file=sys.stderr)
|
|
108
|
+
return 2
|
|
109
|
+
if args.list_models:
|
|
110
|
+
for key in sorted(data.by_id):
|
|
111
|
+
rec = data.by_id[key]
|
|
112
|
+
print("%-45s %-10s %s" % (key, rec["provider"], rec.get("retires") or "-"))
|
|
113
|
+
return 0
|
|
114
|
+
if not os.path.exists(args.path):
|
|
115
|
+
print("error: %s does not exist" % args.path, file=sys.stderr)
|
|
116
|
+
return 2
|
|
117
|
+
if args.fail_within < 0:
|
|
118
|
+
print("error: --fail-within must be 0 or more", file=sys.stderr)
|
|
119
|
+
return 2
|
|
120
|
+
hits = scan_path(args.path, data, today, args.exclude)
|
|
121
|
+
failed = failing(hits, args.fail_within)
|
|
122
|
+
if args.format == "json":
|
|
123
|
+
print(json.dumps({"scanned": args.path, "today": today.isoformat(), "data_checked": data.checked,
|
|
124
|
+
"fail_within_days": args.fail_within, "failed": len(failed),
|
|
125
|
+
"hits": [h.to_dict() for h in _sorted(hits)]}, indent=2))
|
|
126
|
+
elif args.format == "md":
|
|
127
|
+
print(render_md(hits, args.all, failed, args.fail_within))
|
|
128
|
+
else:
|
|
129
|
+
print(render_text(hits, args.all, failed, args.fail_within, args.path))
|
|
130
|
+
print("data checked %s against the providers' own pages; run with --format json for sources" % data.checked)
|
|
131
|
+
return 1 if failed else 0
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
if __name__ == "__main__":
|
|
135
|
+
sys.exit(main())
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"""Find hard-coded LLM model ids in a source tree and look up their retirement dates."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import datetime as dt
|
|
5
|
+
import fnmatch
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import re
|
|
9
|
+
from dataclasses import dataclass, field
|
|
10
|
+
from importlib import resources
|
|
11
|
+
from typing import Dict, Iterable, Iterator, List, Optional
|
|
12
|
+
|
|
13
|
+
SKIP_DIRS = {
|
|
14
|
+
".git", ".hg", ".svn", "node_modules", ".venv", "venv", "env", "__pycache__", ".tox", ".mypy_cache",
|
|
15
|
+
".pytest_cache", ".ruff_cache", "dist", "build", ".next", ".idea", ".vscode", "site-packages", "target",
|
|
16
|
+
"vendor", ".terraform",
|
|
17
|
+
}
|
|
18
|
+
BINARY_EXT = {
|
|
19
|
+
".png", ".jpg", ".jpeg", ".gif", ".webp", ".ico", ".pdf", ".zip", ".gz", ".tgz", ".bz2", ".xz", ".7z", ".whl",
|
|
20
|
+
".jar", ".class", ".so", ".dll", ".exe", ".dylib", ".pyc", ".woff", ".woff2", ".ttf", ".otf", ".mp3", ".mp4",
|
|
21
|
+
".mov", ".onnx", ".gguf", ".safetensors", ".bin", ".pt", ".parquet", ".sqlite", ".db", ".lock", ".svg",
|
|
22
|
+
}
|
|
23
|
+
MAX_BYTES = 1_000_000
|
|
24
|
+
IGNORE_MARK = "model-sunset: ignore"
|
|
25
|
+
|
|
26
|
+
# one candidate token: letters/digits plus . _ : @ - (so ids, Bedrock ids and ARN tails stay whole)
|
|
27
|
+
TOKEN_RE = re.compile(r"[A-Za-z0-9][A-Za-z0-9._:@-]*[A-Za-z0-9]")
|
|
28
|
+
REGION_PREFIX = re.compile(r"^(?:us-gov|us|eu|apac|jp|au|global)\.")
|
|
29
|
+
VENDOR_PREFIX = re.compile(r"^(?:anthropic|openai|google|meta|amazon)\.")
|
|
30
|
+
BEDROCK_SUFFIX = re.compile(r"(?:-v\d+)?(?::\d+)?$")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass
|
|
34
|
+
class Entry:
|
|
35
|
+
provider: str
|
|
36
|
+
id: str
|
|
37
|
+
status: str # retired | retiring | active | unknown-date
|
|
38
|
+
retires: Optional[str]
|
|
39
|
+
days_left: Optional[int]
|
|
40
|
+
replacement: str
|
|
41
|
+
source: str
|
|
42
|
+
checked: str
|
|
43
|
+
verified: bool
|
|
44
|
+
note: str = ""
|
|
45
|
+
not_before: Optional[str] = None
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@dataclass
|
|
49
|
+
class Hit:
|
|
50
|
+
path: str
|
|
51
|
+
line: int
|
|
52
|
+
text: str # the id as written in the file
|
|
53
|
+
model: str # normalized id that matched the data file
|
|
54
|
+
entry: Entry
|
|
55
|
+
|
|
56
|
+
def to_dict(self) -> dict:
|
|
57
|
+
e = self.entry
|
|
58
|
+
return {
|
|
59
|
+
"path": self.path, "line": self.line, "found": self.text, "model": self.model, "provider": e.provider,
|
|
60
|
+
"status": e.status, "retires": e.retires, "days_left": e.days_left, "replacement": e.replacement,
|
|
61
|
+
"source": e.source, "checked": e.checked, "verified": e.verified, "note": e.note,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@dataclass
|
|
66
|
+
class Data:
|
|
67
|
+
checked: str
|
|
68
|
+
by_id: Dict[str, dict] = field(default_factory=dict)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def load_data(path: Optional[str] = None) -> Data:
|
|
72
|
+
if path:
|
|
73
|
+
with open(path, encoding="utf-8") as fh:
|
|
74
|
+
doc = json.load(fh)
|
|
75
|
+
else:
|
|
76
|
+
doc = json.loads(resources.files("amagi_model_sunset").joinpath("data/models.json").read_text(encoding="utf-8"))
|
|
77
|
+
data = Data(checked=doc.get("checked", ""))
|
|
78
|
+
for m in doc["models"]:
|
|
79
|
+
for mid in m["ids"]:
|
|
80
|
+
data.by_id[mid.lower()] = m
|
|
81
|
+
return data
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def parse_date(s: str) -> dt.date:
|
|
85
|
+
return dt.date.fromisoformat(s)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def make_entry(model_id: str, rec: dict, today: dt.date) -> Entry:
|
|
89
|
+
retires = rec.get("retires")
|
|
90
|
+
if retires:
|
|
91
|
+
days = (parse_date(retires) - today).days
|
|
92
|
+
status = "retired" if days <= 0 else "retiring"
|
|
93
|
+
else:
|
|
94
|
+
days = None
|
|
95
|
+
status = "unknown-date" if rec.get("note", "").lower().startswith(("deprecated", "not found")) or not rec.get(
|
|
96
|
+
"verified", True) else "active"
|
|
97
|
+
return Entry(
|
|
98
|
+
provider=rec["provider"], id=model_id, status=status, retires=retires, days_left=days,
|
|
99
|
+
replacement=rec.get("replacement", ""), source=rec.get("source", ""), checked=rec.get("checked", ""),
|
|
100
|
+
verified=bool(rec.get("verified", True)), note=rec.get("note", ""), not_before=rec.get("not_before"),
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def normalize(token: str) -> List[str]:
|
|
105
|
+
"""Return candidate lookup keys for a raw token (Bedrock, Vertex, fine-tune and ARN spellings)."""
|
|
106
|
+
t = token.lower()
|
|
107
|
+
if t.startswith("ft:"):
|
|
108
|
+
parts = t.split(":")
|
|
109
|
+
t = parts[1] if len(parts) > 1 else t
|
|
110
|
+
keys = [t]
|
|
111
|
+
t2 = REGION_PREFIX.sub("", t)
|
|
112
|
+
t2 = VENDOR_PREFIX.sub("", t2)
|
|
113
|
+
keys.append(t2)
|
|
114
|
+
t3 = BEDROCK_SUFFIX.sub("", t2)
|
|
115
|
+
keys.append(t3)
|
|
116
|
+
for k in list(keys):
|
|
117
|
+
if "@" in k:
|
|
118
|
+
keys.append(re.sub(r"@(\d{8})$", r"-\1", k))
|
|
119
|
+
keys.append(k.split("@")[0])
|
|
120
|
+
out: List[str] = []
|
|
121
|
+
for k in keys:
|
|
122
|
+
if k and k not in out:
|
|
123
|
+
out.append(k)
|
|
124
|
+
return out
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def looks_like_model(token: str) -> bool:
|
|
128
|
+
return any(token.lower().startswith(p) or p in token.lower() for p in (
|
|
129
|
+
"gpt", "claude", "gemini", "o1", "o3", "o4", "tts-", "whisper", "text-", "chatgpt", "codex", "embedding",
|
|
130
|
+
"imagen", "veo", "deep-research", "gemini", "ft:", "dall-e", "sora", "babbage", "davinci",
|
|
131
|
+
"computer-use", "antigravity"))
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def scan_text(text: str, path: str, data: Data, today: dt.date) -> Iterator[Hit]:
|
|
135
|
+
for n, line in enumerate(text.splitlines(), 1):
|
|
136
|
+
if IGNORE_MARK in line:
|
|
137
|
+
continue
|
|
138
|
+
for m in TOKEN_RE.finditer(line):
|
|
139
|
+
raw = m.group(0)
|
|
140
|
+
if not looks_like_model(raw):
|
|
141
|
+
continue
|
|
142
|
+
for key in normalize(raw):
|
|
143
|
+
rec = data.by_id.get(key)
|
|
144
|
+
if rec:
|
|
145
|
+
yield Hit(path, n, raw, key, make_entry(key, rec, today))
|
|
146
|
+
break
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def iter_files(root: str, excludes: Iterable[str] = ()) -> Iterator[str]:
|
|
150
|
+
excludes = list(excludes)
|
|
151
|
+
if os.path.isfile(root):
|
|
152
|
+
yield root
|
|
153
|
+
return
|
|
154
|
+
for dirpath, dirnames, filenames in os.walk(root):
|
|
155
|
+
dirnames[:] = sorted(d for d in dirnames if d not in SKIP_DIRS)
|
|
156
|
+
for fn in sorted(filenames):
|
|
157
|
+
full = os.path.join(dirpath, fn)
|
|
158
|
+
rel = os.path.relpath(full, root).replace(os.sep, "/")
|
|
159
|
+
if os.path.splitext(fn)[1].lower() in BINARY_EXT:
|
|
160
|
+
continue
|
|
161
|
+
if any(fnmatch.fnmatch(rel, pat) or fnmatch.fnmatch(fn, pat) for pat in excludes):
|
|
162
|
+
continue
|
|
163
|
+
try:
|
|
164
|
+
if os.path.getsize(full) > MAX_BYTES:
|
|
165
|
+
continue
|
|
166
|
+
except OSError:
|
|
167
|
+
continue
|
|
168
|
+
yield full
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def scan_path(root: str, data: Data, today: dt.date, excludes: Iterable[str] = ()) -> List[Hit]:
|
|
172
|
+
hits: List[Hit] = []
|
|
173
|
+
base = root if os.path.isdir(root) else os.path.dirname(root) or "."
|
|
174
|
+
for full in iter_files(root, excludes):
|
|
175
|
+
try:
|
|
176
|
+
with open(full, "rb") as fh:
|
|
177
|
+
raw = fh.read()
|
|
178
|
+
except OSError:
|
|
179
|
+
continue
|
|
180
|
+
if b"\x00" in raw[:4096]:
|
|
181
|
+
continue
|
|
182
|
+
text = raw.decode("utf-8", errors="replace")
|
|
183
|
+
rel = os.path.relpath(full, base).replace(os.sep, "/")
|
|
184
|
+
hits.extend(scan_text(text, rel, data, today))
|
|
185
|
+
return hits
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def failing(hits: List[Hit], within_days: int) -> List[Hit]:
|
|
189
|
+
"""Hits that should fail CI: already retired, or retiring within `within_days`."""
|
|
190
|
+
bad = []
|
|
191
|
+
for h in hits:
|
|
192
|
+
e = h.entry
|
|
193
|
+
if e.status == "retired" or (e.status == "retiring" and e.days_left is not None and e.days_left <= within_days):
|
|
194
|
+
bad.append(h)
|
|
195
|
+
return bad
|