Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tracker] Reduce API-decorators complexity #5022

Open
4 of 10 tasks
csadorf opened this issue Nov 23, 2022 · 0 comments
Open
4 of 10 tasks

[Tracker] Reduce API-decorators complexity #5022

csadorf opened this issue Nov 23, 2022 · 0 comments
Assignees
Labels
? - Needs Triage Need team to review and classify feature request New feature or request Tech Debt Issues related to debt Tracker For epoch-level tracking of work that encapsulates many stories

Comments

@csadorf
Copy link
Contributor

csadorf commented Nov 23, 2022

About

This effort is aimed at reducing complexity and tech debt relating to the so called "API-decorators". The purpose of the decorators is to:

  1. Ensure that type conversions and host-device transfers only happen when absolutely necessary.
  2. Allow users to provide array-like input data in the type of their choice and also return results in the same type.

We identified the following key problems with the current implementation:

  1. The inherent complexity makes it hard for developers to follow the control and data flow.
  2. The use of magically applied decorators
    a. removes any obvious visual trigger to developers that they must be aware of the special behavior of a function,
    b. reduce confidence in said behavior.
  3. Non-obvious naming further obfuscates that developers must be aware of special behavior.

The revised implementation should

  1. Clearly communicate to developers what types to expect and what they must return and to prevent or at least discourage unnecessary conversions.
  2. Clearly communicate to users what types they can provide and what to expect in return (typically the same type).

The improved implementation is aiming to achieve three main things:

  1. Simplify the developer API
  2. Reduce implementation complexity
  3. Reduce magic behavior

Only loosely related to this, we should aim to actually use type-checking to check that decorators are correctly applied and the correct return types are returned.

Tasks

  • Avoid need for DecoratorMetaClass
  • Use factory functions instead of multiple-inheritance for Decorator class implementation.
  • Use the same decorators for base-class methods and free-floating functions.
  • Reduce number of decorator (aliases) in preference of configurable decorators and improve naming.
  • Use a stack to keep track of the output type
  • Do not automatically apply decorators; instead require that certain functions are always decorated for classes that derive from Base.
  • Do not allow for multiple decorators to be applied, or have them replace the old one, but in any case do not silently ignore decorators when one was previously applied; like other magic this introduces uncertainty about whether a decorator is applied or not.
  • Do not use type annotations to infer output types during runtime; instead use decorators that are type-checked; but check whether the decorator and the type annotation match.

PRs

@csadorf csadorf added feature request New feature or request ? - Needs Triage Need team to review and classify Tracker For epoch-level tracking of work that encapsulates many stories Tech Debt Issues related to debt labels Nov 23, 2022
@csadorf csadorf self-assigned this Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
? - Needs Triage Need team to review and classify feature request New feature or request Tech Debt Issues related to debt Tracker For epoch-level tracking of work that encapsulates many stories
Projects
None yet
Development

No branches or pull requests

1 participant