agentleFS
NVIDIAKnown publisherNVIDIA/TensorRT/tools/Polygraphy/.agents/skills/deprecate-api/SKILL.md

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

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the NVIDIA/TensorRT repository that our weekly crawl found: only 4 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

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
  1. Very specific:

    Decorator order matters: put @staticmethod (or @classmethod) *above* @mod.deprecate so the static/class wrapper stays outermost and …

    line 30
  2. Distinctive:

    When only a specific argument value or code path is deprecated (not the whole function), call it directly:

    line 36
  3. Distinctive:

    Avoid making the library warn at itself: update internal callers (and CLI script generation) to use the *new* API so normal usage doesn't …

    line 55
  4. Very specific:

    If you added a *new* lazy dependency at module scope while doing this, also update the expected set in …

    line 72

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 current polygraphy.__version__ (see polygraphy/__init__.py) — otherwise INTERNAL_CORRECTNESS_CHECKS raises an internal error at import. Recent deprecations target "0.60.0".
  • use_instead: the replacement to recommend (string). Pass None if there is no replacement.
  • name / module_name: control the displayed name. For a @staticmethod, pass name="ClassName.method" since obj.__name__ would otherwise just be the bare method name.
  • Decorator order matters: put @staticmethod (or @classmethod) above @mod.deprecate so the static/class wrapper stays outermost and mod.deprecate receives 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 (see deprecate in exporter.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_deprecated emits a Python DeprecationWarning (hidden by default; run Python with -W always::DeprecationWarning to see it). Pass always_show_warning=True to also log it via G_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_accuracy defaults to SimpleCompareFunc() rather than the deprecated CompareFunc.simple().
  • Tests that still call the deprecated API will pass (there is no filterwarnings = error config) 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.