RNA API: Support Proper Deprecation Process #127876

Open
opened 2024-09-19 18:58:33 +02:00 by Bastien Montagne · 0 comments

Currently, there is no proper way to deprecate some RNA properties, functions and/or parameters. This design is to define a proper way to support such deprecation.

For recent examples where this could have become handy, see e.g. !127806 or !126796 (from which this task originated).

Problem

There should not be API breakages outside of new major release cycles. However, often in development, cleanups or refactors would require renaming or removal of some items in our RNA API.

There is currently no proper way to achieve this while keeping existing Python code working, and avoiding cluttering the API.

Further more, there is no systematic ways to handle such deprecation, ensure that deprecated items get removed when scheduled, etc.

Proposal

The general idea is to add 'deprecation' meta-data to RNA properties/functions. Then:

  • This info is available from bpy (Type.bl_rna.properties["deprecated_prop"]), so API doc generation tool can either ignore them, and/or add proper deprecation info.
  • This info is used by makesrna to:
    • Generate deprecated warning when property is accessed.
    • Assert when current Blender version reaches the 'expected removal' one (which makes it trivial to keep track of deprecated things to remove as scheduled).

Technical Implementation

Marking an RNA item as deprecated would happen with a new definition call, something like: RNA_def_property_deprecated(PropertyRNA *prop, StringRefNull message, uint3 removal_version) (and similar for RNA functions).

  • message would be information about how to replace current usages of the deprecated item.
  • removal_version would be the expected release where this deprecated item would be removed (typically a new major release cycle).

User/Dev information about deprecated API usages has to be done carefully, to ensure that the info is visible by devs, while not being too annoying for regular users. This could be done like that e.g.:

  • Regular users ('dev extra' disabled):
    • Display warning in the console once, on first access.
  • Devs ('dev extra' enabled):
    • Display warning in the console on every access.
    • Display warning in the UI once, on first access.

Questions

  • Is the same system also useful for RNA struct?
  • Is more info than the proposed deprecation message and version necessary?
Currently, there is no proper way to deprecate some RNA properties, functions and/or parameters. This design is to define a proper way to support such deprecation. For recent examples where this could have become handy, see e.g. !127806 or !126796 (from which this task originated). ## Problem There should not be API breakages outside of new major release cycles. However, often in development, cleanups or refactors would require renaming or removal of some items in our RNA API. There is currently no proper way to achieve this while keeping existing Python code working, and avoiding cluttering the API. Further more, there is no systematic ways to handle such deprecation, ensure that deprecated items get removed when scheduled, etc. ## Proposal The general idea is to add 'deprecation' meta-data to RNA properties/functions. Then: * This info is available from bpy (`Type.bl_rna.properties["deprecated_prop"]`), so API doc generation tool can either ignore them, and/or add proper deprecation info. * This info is used by `makesrna` to: - Generate deprecated warning when property is accessed. - Assert when current Blender version reaches the 'expected removal' one (which makes it trivial to keep track of deprecated things to remove as scheduled). ### Technical Implementation Marking an RNA item as deprecated would happen with a new definition call, something like: `RNA_def_property_deprecated(PropertyRNA *prop, StringRefNull message, uint3 removal_version)` (and similar for RNA functions). * `message` would be information about how to replace current usages of the deprecated item. * `removal_version` would be the expected release where this deprecated item would be removed (typically a new major release cycle). User/Dev information about deprecated API usages has to be done carefully, to ensure that the info is visible by devs, while not being too annoying for regular users. This could be done like that e.g.: * Regular users ('dev extra' disabled): - Display warning in the console once, on first access. * Devs ('dev extra' enabled): - Display warning in the console on every access. - Display warning in the UI once, on first access. ### Questions * Is the same system also useful for RNA struct? * Is more info than the proposed deprecation message and version necessary?
Bastien Montagne added the
Type
Design
label 2024-09-19 18:58:33 +02:00
Bastien Montagne added this to the Core project 2024-09-19 18:58:42 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#127876
No description provided.