gopidesupavan commented on issue #43582:
URL: https://github.com/apache/airflow/issues/43582#issuecomment-2451781314

   Oh yeah that would helpful :).
   
   When this discussion began a while ago, i heard from the discussion using 
meta path, then I experimented with using this to redirect old imports to new 
ones.
   
   ash please suggest your approach. 
   
   ```
   import sys
   import importlib
   
   class ModuleRedirectSpec:
       def __init__(self, redirects):
           self.redirects = redirects
   
       def find_spec(self, old_module_ref, path, target=None):
           if old_module_ref in self.redirects:
               new_module_name = self.redirects[old_module_ref]
               return importlib.util.find_spec(new_module_name)
           return None
   
   redirects = {
       "airflow.operators.bash": "airflow.providers.standard.operators.bash"
   }
   sys.meta_path.insert(0, ModuleRedirectSpec(redirects))
   ``` 


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