deprecate-api
Skill13k starsChanged 5 months agoApache-2.0View on GitHub
Mark a Polygraphy function, class, module, or alias as deprecated so it warns at runtime and is scheduled for removal. Use when asked to deprecate an API, replace one API with another while keeping backwards compatibility, or add a deprecation warning.
Trending
Quiet this year.thin dataabout the whole repository
Who's talking about NVIDIA/TensorRT
- AUTOMATIC1111/stable-diffusion-webui“[Feature Request]: Potential mode for TensorRT inference over native PyTorch”GitHub · Jan 29, 2023 · 62 reactions
- ultralytics/yolov5“Gain of `EfficientNMS_TRT` embed on TensorRT”GitHub · Jan 26, 2022 · 15 reactions
- AiuniAI/Unique3D“For Windows users”GitHub · Jun 9, 2024 · 8 reactions
- A Hacker News story“TensorRT Open Source Software”Hacker News · Jul 2, 2019 · 1 points
The biggest 4 of 4 mentions linking to the repository that our crawl found. Each line is their own headline.
In this repository8 other files it gives its agents.
- trt-cpp-runtime-quickstartSkill
- trt-onnx-quickstartSkill
- trt-perf-analysisSkill
- trt-strong-typing-migrationSkill
- trt-torch-quickstartSkill
- headless-screenshotsSkill
- release-polygraphySkill
- testSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 30
Decorator order matters: put @staticmethod (or @classmethod) *above* @mod.deprecate so the static/class wrapper stays outermost and …
- Distinctive: line 36
When only a specific argument value or code path is deprecated (not the whole function), call it directly:
- Distinctive: line 55
Avoid making the library warn at itself: update internal callers (and CLI script generation) to use the *new* API so normal usage doesn't …
- Very specific: line 72
If you added a *new* lazy dependency at module scope while doing this, also update the expected set in …
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Deprecating Polygraphy APIs
Polygraphy provides deprecation helpers in polygraphy/mod/exporter.py, exposed via the mod module (from polygraphy import mod).
Decorator: @mod.deprecate (preferred for whole functions/classes/modules)
from polygraphy import mod
class CompareFunc:
@staticmethod
@mod.deprecate(
remove_in="0.60.0",
use_instead="SimpleCompareFunc",
name="CompareFunc.simple", # optional; defaults to obj.__name__
)
def simple(...):
"""<full docstring is preserved>"""
return SimpleCompareFunc(...)remove_in(required): the version the symbol will be removed in. Must be greater than the currentpolygraphy.__version__(seepolygraphy/__init__.py) — otherwiseINTERNAL_CORRECTNESS_CHECKSraises an internal error at import. Recent deprecations target"0.60.0".use_instead: the replacement to recommend (string). PassNoneif there is no replacement.name/module_name: control the displayed name. For a@staticmethod, passname="ClassName.method"sinceobj.__name__would otherwise just be the bare method name.- Decorator order matters: put
@staticmethod(or@classmethod) above@mod.deprecateso the static/class wrapper stays outermost andmod.deprecatereceives the raw function. - The decorator works on functions, classes (returns a subclass that warns on
__init__), and modules. - The decorator preserves the original docstring and prepends a
Deprecated: Use <X> instead.note (seedeprecateinexporter.py). This keeps API reference docs intact.
Inline call: mod.warn_deprecated (for partial / conditional deprecations)
When only a specific argument value or code path is deprecated (not the whole function), call it directly:
mod.warn_deprecated(
"Returning NumPy dtypes from get_input_metadata()",
use_instead=None,
remove_in="0.60.0",
)Examples in-tree: polygraphy/backend/base/runner.py, polygraphy/backend/trt/loader.py, polygraphy/tools/args/util/util.py.
Deprecated aliases
To expose an old name that forwards to a new one, use mod.export_deprecated_alias("OldName", remove_in="0.60.0", use_instead=None) (see export_deprecated_alias in exporter.py). For an entire module: mod.export_deprecated_alias("old_mod", remove_in="0.60.0")(sys.modules[__name__]).
Behavior & gotchas
warn_deprecatedemits a PythonDeprecationWarning(hidden by default; run Python with-W always::DeprecationWarningto see it). Passalways_show_warning=Trueto also log it viaG_LOGGER.warning.- Avoid making the library warn at itself: update internal callers (and CLI script generation) to use the new API so normal usage doesn't trigger the deprecation. E.g.
Comparator.compare_accuracydefaults toSimpleCompareFunc()rather than the deprecatedCompareFunc.simple(). - Tests that still call the deprecated API will pass (there is no
filterwarnings = errorconfig) but will emit warnings.
After deprecating — verify
PYTHONPATH=<repo> python3 -W always::DeprecationWarning -c "
import warnings
from polygraphy.comparator import CompareFunc
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
CompareFunc.simple()
assert any(issubclass(x.category, DeprecationWarning) for x in w)
print('docstring preserved:', 'Args:' in (CompareFunc.simple.__doc__ or ''))
"If you added a new lazy dependency at module scope while doing this, also update the expected set in tests/mod/test_dependencies.py::TestDependencies::test_all_lazy_imports.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

