mjpieters commented on a change in pull request #10770:
URL: https://github.com/apache/airflow/pull/10770#discussion_r491456171
##########
File path: airflow/plugins_manager.py
##########
@@ -67,6 +67,8 @@ class AirflowPluginException(Exception):
class AirflowPlugin:
"""Class used to define AirflowPlugin."""
name: Optional[str] = None
+ plugin_source: Optional[str] = None
+ plugin_path: Optional[str] = None
Review comment:
Coming back to this: if it is decided to keep this information on the
AirflowPlugin subclasses, then it should be marked as 'internal', by using
names that start with an underscore: `_plugin_source` and `_plugin_path`.
Another thought: should this be a *single* attribute? It could be a data
class along the lines of:
```
class BasePluginSource:
source = None
def __str__(self):
raise NotImplementedError
def __html__(self):
raise NotImplementedError
class PluginsDirectorySource(BasePluginSource):
source = "airflow_plugins_directory"
def __init__(self, path):
self.path = os.path.relpath(path, settings.PLUGINS_FOLDER)
def __str__(self):
return f"$PLUGINS_FOLDER/{self.path}"
def __html__(self):
return f"<em>$PLUGINS_FOLDER/</em>{self.path}"
class EntryPointSource(BasePluginSource):
source = "entrypoint"
def __init__(self, entrypoint):
self.entrypoint = str(entrypoint)
self.dist = str(entrypoint.dist)
def __str__(self):
return f"{self.entrypoint}: {self.dist}"
def __html__(self):
return f"<em>{self.entrypoint}:</em> {self.dist}"
```
The `__html__` method will be called by Jinja instead of `__str__`; the
markup is just a sketch, feel free to provide better markup.
----------------------------------------------------------------
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]