ashb commented on a change in pull request #11189:
URL: https://github.com/apache/airflow/pull/11189#discussion_r505651581



##########
File path: airflow/models/dag.py
##########
@@ -88,6 +89,23 @@ def get_last_dagrun(dag_id, session, 
include_externally_triggered=False):
     return query.first()
 
 
+def replace_outdated_dag_actions(access_control):
+    """
+    Looks for outdated dag level permissions (can_dag_read and can_dag_edit) 
in DAG
+    access_controls (for example, {'role1': {'can_dag_read'}, 'role2': 
{'can_dag_read', 'can_dag_edit'}})
+    and replaces them with updated permissions (can_read and can_edit).
+    """
+    new_perm_mapping = {
+        permissions.DEPRECATED_ACTION_CAN_DAG_READ: 
permissions.ACTION_CAN_READ,
+        permissions.DEPRECATED_ACTION_CAN_DAG_EDIT: 
permissions.ACTION_CAN_EDIT,
+    }
+    updated_access_control = {}
+    for role, perms in access_control.items():
+        updated_access_control[role] = {new_perm_mapping.get(perm, perm) for 
perm in perms}

Review comment:
       Could issue a DeprecationWarning if anything was changed? (with the 
right `stacklevel` to have the line number appear where the `DAG()` call is, 3 
I think?)




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

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


Reply via email to