python-decorator

Apply Python decorators to unify parameter names and ordering between PyTorch and Paddle APIs.

285|906|Updated Jun 7, 2018
One-click install
npx skills add https://github.com/PaddlePaddle/docs --skill python-decorator
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-decorator
Source: https://github.com/PaddlePaddle/docs/tree/main/docs/dev_guides/coding_agent/api_compatibility/.claude/skills/python-decorator
Command: npx skills add https://github.com/PaddlePaddle/docs --skill python-decorator

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill addresses the challenge of maintaining API consistency across different frameworks by using Python decorators to handle parameter name differences, ordering, and usage variations seamlessly.

Core Features & Use Cases

  • Parameter aliasing: Enables automatic mapping of parameter names between PyTorch and Paddle APIs.
  • APIs with different signatures: Supports code adaptation for APIs with varying argument orders, optional parameters, and usage patterns.
  • Use case: Developers can quickly adapt PyTorch code to Paddle by applying decorators, reducing rewrite effort and minimizing errors.

Quick Start

Apply the custom Python decorator to an API function to automatically align its parameters with the target framework's signature.

Frequently Asked Questions about python-decorator

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle API parameter naming differences when porting PyTorch code to Paddle?

You can handle API parameter naming differences by applying Python decorators that automatically map and alias parameter names between PyTorch and Paddle. This unifies parameter naming seamlessly, reducing rewrite effort and minimizing migration errors.

Can I use Python decorators to adapt APIs with different argument orders?

Yes, you can use Python decorators to adapt APIs with different argument orders. The decorators handle varying argument orders, optional parameters, and usage patterns to ensure seamless API adaptation within your Python codebase.

What is the best way to maintain API consistency across different frameworks?

The best way to maintain API consistency is by using Python decorators to handle parameter name differences, ordering, and usage variations. This approach unifies API signatures, facilitating rapid migration and consistent behavior across frameworks.

Do I need external dependencies to unify parameter names for cross-framework integration?

No, you do not need external dependencies to unify parameter names. This approach relies on existing Python standard libraries like functools and inspect for function wrapping, ensuring seamless API adaptation without extra installations.