Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Refactored __new__ magic method of BaseOperatorMeta to avoi…
…d bad mixing classic and decorated operators (#37937) * refactor: Refactored __new__ magic method of BaseOperatorMeta class to include an execute safeguard which prohibits called the execute method manually from a Python callable or @task decorated python method. * refactor: Get unit_test_mode from airflow config instead of directly retrieving it from env variable * fix: Fixed import of AirflowException * refactor: Use conf_vars instead of patch.dict to alter Airflow unit_test_mode config parameter and use pytest instead of unittest to run the test * fix: Fixed match on expected exception message * refactor: Added test case where HelloWorldOperator is called from within an PythonOperator * refactor: Refactored TestBaseOperatorMeta by having a dedicated fixture for TaskInstance * refactor: Reformatted some files that where failing due to static checks * refactor: Try disabling unit_test_mode right just before calling the run method of task instance in hope test won't fail on Airflow * refactor: Re-ordered imports as asked by static checks * refactor: Added license at top of new test module * refactor: Refactored ExecutorSafeguard decorator as a class so we can toggle the test_mode on it when used in unit tests * refactor: Removed patch of sqlalchemy Session on test methods * refactor: Refactored ExecutorSafeguard decorator as a class so we can toggle the test_mode on it when used in unit tests * Revert "refactor: Refactored ExecutorSafeguard decorator as a class so we can toggle the test_mode on it when used in unit tests" This reverts commit fabea74. * refactor: Refactored ExecutorSafeguard decorator as a class so we can toggle the test_mode on it when used in unit tests * refactor: Added docstring to ExecutorSafeguard decorator * docs: Reformatted docstring of ExecutorSafeguard * refactor: Added missing white line between docstring and test_mode class var of ExecutorSafeguard class * refactor: Fixed unit tests for ExecutorSafeguard * refactor: Reformatted baseoperator and test_baseoperatormeta file as expected by static check * fix: Fixed import of partial function from functools * refactor: Refactored multiple patches into one context manager so it's Python 3.8 compatible * refactor: Reformatted patch statement in TestExecutorSafeguard * refactor: Added allow_mixing attribute to BaseOperator and added test case when allow_mixing is enabled * refactor: Fixed static checks on baseoperator * fix: Forgot to also add allow_mixin parameter to partial method in BaseOperator * refactor: Trying to fix example in docstring of allow_mixin param in BaseOperator * refactor: Added bool type to allow_mixing attribute of BaseOperator * refactor: Added allow_mixin parameter * refactor: Added init file in resources package * refactor: Changed docstring of BaseOperator to raw string due to backslash present in example * fix: Fixed name of allow_mixin parameter * fix: Fixed check on allow_mixin property * fix: Fixed allow_mixin property in test * refactor: Added allow_mixin to schema.json and assertion in test_dag_serialization * refactor: Refactored tests using dag_maker fixture and running them as db_test + fixed issue of nested calls with ExecutorSafeguard * refactor: Moved import of Context under type checking * refactor: Reformatted TestExecutorSafeguard * refactor: Simplified check on test_mode in wrapper * refactor: Improved check as a classic operator can also be called through a python function called by a Python operator * refactor: Fixed additional static checks * refactor: Fixed additional static checks * refactor: Use sentinel instead of traceback to detect if execute was called outside TaskInstance * refactor: Use test_mode from TaskInstance * refactor: Removed unused imports * refactor: Put message in one line * Revert "refactor: Use test_mode from TaskInstance" This reverts commit 8a35ebb * refactor: Put message on one line * refactor: Fixed passing of sentinel arg when resume_execution is being called * refactor: Reformatted test * refactor: Check if next_kwargs is not None * refactor: Fixed DAG example in docstring of chain_linear method * refactor: Renamed allow_mixin parameter of BaseOperator to allow_nested_operators --------- Co-authored-by: David Blain <david.blain@infrabel.be>
- Loading branch information