-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Migrate DagFileProcessor.manage_slas to Internal API #28502
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
Conversation
|
@vincbeck need resolve conflicts |
ddf8033 to
3831d1b
Compare
|
Done |
airflow/dag_processing/processor.py
Outdated
| @internal_api_call | ||
| @provide_session | ||
| def manage_slas(self, dag: DAG, session: Session = None) -> None: | ||
| def manage_slas(dag_folder, dag_id: str, log: logging.Logger, session: Session = NEW_SESSION) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing in a logger object feels very wrong to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, it feels also very wrong to me but maybe with some context it will help understanding it :).
All methods decorated with @internal_api_call are meant to be called either directly (like today) or through a new component: internal API (see PR here). This decision is based on the the flag database_access_isolation. What we want to achieve here is when the methods are called directly, the behavior should be the same as today, hence the logger should be the same. However, when these methods are called through the internal API, we want the logs to be separated from the current execution. Then, in that case we want a different logger. This new logger is created by the internal API itself, see PR here.
I hope it helps to understand and feel free to give me your thoughts given this context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the technical aspects, but it would simply indicate either the decorator should be improved to remove this restriction, or we need a new mechanism (perhaps built upon @internal_api_call that can be used on an instance method, not only static methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mhenc what do you think? Meanwhile I'll try to find a in-between solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we could make it work for non-static methods - passing the whole state of the object would be tricky (we want to avoid pickling) and would affect the performance even more.
If the only problem is passing the logger, then I can see few options:
- Instead of passing the logger, just send the logger name and create the logger inside the method
- Make logger static (as Vinc suggested in the first place) - we can wrap it into some method to keep
self.logavailable for other methods. - I think internal_api_call should also work for class methods, so we could do something like this:
https://stackoverflow.com/a/8438818
cc: @potiuk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'll update this PR accordingly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not nice bot.. Closed my PR :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hahaha, yeah! It is a bossy and rude bot xD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR updated
|
(Pending tests passing :) ) |
0e3a07b to
63c1f8c
Compare
Migrate DagFileProcessor.manage_slas to Internal API
Closes: #28268