ninsbl commented on issue #46824:
URL: https://github.com/apache/airflow/issues/46824#issuecomment-2665211976

   > i will take this issue, please assign to me thank you
   
   @azharizz : Thanks! Very much appreciated!
   
   After some more attempts, I am no longer sure this is just a documentation 
issue, The WeightRule Enum used for validation of weight_rule input does not 
seem to contain the added, custom weight rules, although I could verify that 
the plugin is registered and  _validate_and_load_priority_weight_strategy_ 
returns an object of the PriorityWeightStrategy class:
   ```
   from airflow.task.priority_strategy import 
validate_and_load_priority_weight_strategy
   
   
validate_and_load_priority_weight_strategy('decreasing_priority_weight_strategy.DecreasingPriorityStrategy')
   <decreasing_priority_weight_strategy.DecreasingPriorityStrategy object at 
0x7f46c65bb390>
   ```
   Since _WeightRule_ is an Enum, it cannot be easily extended, 
   Maybe, the _weight_rule_ configuration 
(https://github.com/apache/airflow/blob/8fbdf75dc7e536f55d07965254f800d181afa2b7/airflow/configuration.py#L389)
 needs to be extended from plugins too??? It is the marshmallow schema 
validation that seems to fail...
   
   Maybe something like this is needed in the configuration:
   ```
   from enum import Enum
   from airflow import plugins_manager
   plugins_manager.initialize_priority_weight_strategy_plugins()
   plugins_manager.priority_weight_strategy_classes
   
   (...)
   
       enums_options = {
       ("core", "default_task_weight_rule"): Enum(
           "WeightRule", {str(k.upper()): str(k) for k in 
sorted(set(plugins_manager.priority_weight_strategy_classes.keys()))}
           ).__members__.values(),
       (...)
   
   ```
   
   Or the weight_rule validation can be skipped completely at the configuration 
stage, as this is done later with the 
_validate_and_load_priority_weight_strategy_ function?
   
   Anyway, if anyone has an example showing how this feature is implemented in 
a DAG properly, I would be very greatful! Likewise for any hints on fixing the 
issue if it is not documentation only...


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to