Visitar URL original
Add updated-name wrappers for built-in FAB methods. by jhtimmins · Pull Request #16077 · apache/airflow · GitHub
Skip to content

Add updated-name wrappers for built-in FAB methods. - #16077

Merged
potiuk merged 4 commits into
apache:masterfrom
astronomer:add-fab-wrapper-functions
May 29, 2021
Merged

potiuk merged 4 commits into
apache:masterfrom
astronomer:add-fab-wrapper-functions

Conversation

@jhtimmins

Copy link
Copy Markdown
Contributor

This is a re-implementation of one piece of #15398, which uses the "resource" and "action" naming scheme.

The original PR has proved difficult to get reviewed and through CI, as it touches a lot of different files that change frequently. This PR introduces wrapper methods around default FAB methods, this time using the updated naming scheme.

The methods are not in use yet; the next PR will update method calls throughout Airflow to use the new methods instead of the default FAB methods.

@boring-cyborg boring-cyborg Bot added the area:webserver Webserver related Issues label May 26, 2021
@jhtimmins
jhtimmins requested review from ashb, jedcunningham and kaxil May 26, 2021 02:56
@jhtimmins
jhtimmins force-pushed the add-fab-wrapper-functions branch from cb60630 to 6345285 Compare May 26, 2021 03:04

@jedcunningham jedcunningham left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM. Minor nit, might be nice to having typing on these.

Comment thread airflow/www/security.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this super() vs self?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And should we change parameter to action_name? for consistency ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, I like to add only as much explanation as is necessary based on context. In this case it seems reasonable to infer that name refers to the name of the action being retrieved.

Comment thread airflow/www/security.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "action_name" and "resource_name" should be here as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

Comment thread airflow/www/security.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just double-checking - resource here is different than "resource_name" (looks like - from the type).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, resource should apply to the actual object

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few consistency nits.

Would you also care to add Type annotations for parameters? That would make mypy verify types of the parameters in most cases - especially when there was action vs. action_name or resource vs. resource_name.

@jhtimmins
jhtimmins force-pushed the add-fab-wrapper-functions branch from 6b815c9 to 129ebf1 Compare May 26, 2021 20:57
@jhtimmins
jhtimmins requested review from jedcunningham and potiuk May 26, 2021 20:59
Comment thread airflow/www/security.py Outdated
Comment on lines 240 to 242

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sphinx needs one blank line between description and params

Suggested change
Returns a resource record by name, if it exists.
:param name: Name of resource
Returns a resource record by name, if it exists.
:param name: Name of resource

Comment thread airflow/www/security.py Resolved
Comment thread airflow/www/security.py Outdated
Comment on lines 258 to 262

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Gets an existing action record.
:param name: name
Gets an existing action record.
:param name: name

Comment thread airflow/www/security.py Outdated
Comment on lines 268 to 273

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Gets a permission made with the given action->resource pair, if the permission already exists.
:param action_name: Name of action
Gets a permission made with the given action->resource pair, if the permission already exists.
:param action_name: Name of action

Comment thread airflow/www/security.py Outdated
Comment on lines 280 to 286

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Creates a permission linking an action and resource.
:param action_name: Name of existing action
Creates a permission linking an action and resource.
:param action_name: Name of existing action

Comment thread airflow/www/security.py Outdated
Comment on lines 594 to 603

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Add an existing permission pair to a role.
:param role: The role about to get a new permission.
Add an existing permission pair to a role.
:param role: The role about to get a new permission.

Comment thread airflow/www/security.py Outdated
Comment on lines 606 to 616

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Remove a permission pair from a role.
:param role: User role containing permissions.
Remove a permission pair from a role.
:param role: User role containing permissions.

Comment thread airflow/www/security.py Outdated
Comment on lines 616 to 627

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Deletes a permission action.
:param name: Name of action to delete (e.g. can_read).
Deletes a permission action.
:param name: Name of action to delete (e.g. can_read).

Comment thread airflow/www/security.py Outdated
Comment on lines 763 to 775

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Retrieve permission pairs associated with a specific resource object.
:param resource: Object representing a single resource.
Retrieve permission pairs associated with a specific resource object.
:param resource: Object representing a single resource.

Comment thread airflow/www/security.py Outdated
Comment on lines 876 to 892

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
then re-syncs them.
:return: None
then re-syncs them.
:return: None

@jhtimmins
jhtimmins force-pushed the add-fab-wrapper-functions branch from 129ebf1 to c05946a Compare May 27, 2021 01:21
@jhtimmins
jhtimmins requested a review from kaxil May 27, 2021 01:25
@jhtimmins
jhtimmins force-pushed the add-fab-wrapper-functions branch from 08e46ad to 1768355 Compare May 27, 2021 19:02
@jhtimmins

Copy link
Copy Markdown
Contributor Author

@potiuk can you take another look? I've added typing and either updated or explained the naming choices.

@github-actions github-actions Bot added the okay to merge It's ok to merge this PR as it does not require more tests label May 27, 2021
@github-actions

Copy link
Copy Markdown
Contributor

The PR is likely OK to be merged with just subset of tests for default Python and Database versions without running the full matrix of tests, because it does not modify the core of Airflow. If the committers decide that the full tests matrix is needed, they will add the label 'full tests needed'. Then you should rebase to the latest master or amend the last commit of the PR, and push it with --force-with-lease.

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the explanations. Makes sense.

@potiuk
potiuk merged commit a27e930 into apache:master May 29, 2021
@jhtimmins

Copy link
Copy Markdown
Contributor Author

Thanks @potiuk. Is the failing MSSQL test related to that other PR about improving MSSQL compatibility?

@potiuk

potiuk commented May 30, 2021

Copy link
Copy Markdown
Member

Yep. We already have a fix for that. We looked for the problem for last few days and it turned out it is caused by ..... Tmpfs backing our docker engine for self-hosted runners (they are optimized for speed). Fix is coming in #16159

@kaxil
kaxil deleted the add-fab-wrapper-functions branch December 31, 2025 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:webserver Webserver related Issues okay to merge It's ok to merge this PR as it does not require more tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants