potiuk commented on a change in pull request #6596: [AIRFLOW-6004] Untangle
Executors class to avoid cyclic imports
URL: https://github.com/apache/airflow/pull/6596#discussion_r351931925
##########
File path: airflow/plugins_manager.py
##########
@@ -142,32 +142,31 @@ def is_valid_plugin(plugin_obj, existing_plugins):
# Crawl through the plugins folder to find AirflowPlugin derivatives
for root, dirs, files in os.walk(settings.PLUGINS_FOLDER, followlinks=True):
for f in files:
+ filepath = os.path.join(root, f)
try:
- filepath = os.path.join(root, f)
- try:
- if not os.path.isfile(filepath):
- continue
- mod_name, file_ext = os.path.splitext(
- os.path.split(filepath)[-1])
- if file_ext != '.py':
- continue
-
- log.debug('Importing plugin module %s', filepath)
- # normalize root path as namespace
- namespace = '_'.join([re.sub(norm_pattern, '__', root),
mod_name])
-
- m = imp.load_source(namespace, filepath)
- for obj in list(m.__dict__.values()):
- if is_valid_plugin(obj, plugins):
- plugins.append(obj)
- except Exception as e: # pylint: disable=broad-except
- log.exception(e)
- log.error('Failed to import plugin %s', filepath)
- import_errors[filepath] = str(e)
+ if not os.path.isfile(filepath):
+ continue
+ mod_name, file_ext = os.path.splitext(
+ os.path.split(filepath)[-1])
+ if file_ext != '.py':
+ continue
+
+ log.debug('Importing plugin module %s', filepath)
+ # normalize root path as namespace
+ namespace = '_'.join([re.sub(norm_pattern, '__', root), mod_name])
+
+ m = imp.load_source(namespace, filepath)
+ for obj in list(m.__dict__.values()):
+ if is_valid_plugin(obj, plugins):
+ plugins.append(obj)
except Exception as e: # pylint: disable=broad-except
log.exception(e)
- log.error('Failed to import plugin %s', str(f))
- import_errors[str(f)] = str(e)
+ if not filepath:
+ log.error('Failed to import plugin %s', str(f))
+ import_errors[str(f)] = str(e)
+ else:
+ log.error('Failed to import plugin %s', filepath)
+ import_errors[filepath] = str(e)
Review comment:
I am going to change it in follow-up request, but yes.
----------------------------------------------------------------
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]
With regards,
Apache Git Services