本文整理匯總了Python中airflow.plugins_manager.AirflowPlugin方法的典型用法代碼示例。如果您正苦於以下問題:Python plugins_manager.AirflowPlugin方法的具體用法?Python plugins_manager.AirflowPlugin怎麽用?Python plugins_manager.AirflowPlugin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類airflow.plugins_manager
的用法示例。
在下文中一共展示了plugins_manager.AirflowPlugin方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_should_warning_about_incompatible_plugins
# 需要導入模塊: from airflow import plugins_manager [as 別名]
# 或者: from airflow.plugins_manager import AirflowPlugin [as 別名]
def test_should_warning_about_incompatible_plugins(self):
class AirflowDeprecatedAdminViewsPlugin(AirflowPlugin):
name = "test_admin_views_plugin"
admin_views = [mock.MagicMock()]
class AirflowDeprecatedAdminMenuLinksPlugin(AirflowPlugin):
name = "test_menu_links_plugin"
menu_links = [mock.MagicMock()]
from airflow import plugins_manager
plugins_manager.plugins = [
AirflowDeprecatedAdminViewsPlugin(),
AirflowDeprecatedAdminMenuLinksPlugin()
]
with self.assertLogs(plugins_manager.log) as cm:
plugins_manager.initialize_web_ui_plugins()
self.assertEqual(cm.output, [
'WARNING:airflow.plugins_manager:Plugin \'test_admin_views_plugin\' may not be '
'compatible with the current Airflow version. Please contact the author of '
'the plugin.',
'WARNING:airflow.plugins_manager:Plugin \'test_menu_links_plugin\' may not be '
'compatible with the current Airflow version. Please contact the author of '
'the plugin.'
])
示例2: test_should_response_200_support_plugins
# 需要導入模塊: from airflow import plugins_manager [as 別名]
# 或者: from airflow.plugins_manager import AirflowPlugin [as 別名]
def test_should_response_200_support_plugins(self):
class GoogleLink(BaseOperatorLink):
name = "Google"
def get_link(self, operator, dttm):
return "https://www.google.com"
class S3LogLink(BaseOperatorLink):
name = "S3"
operators = [BigQueryExecuteQueryOperator]
def get_link(self, operator, dttm):
return "https://s3.amazonaws.com/airflow-logs/{dag_id}/{task_id}/{execution_date}".format(
dag_id=operator.dag_id,
task_id=operator.task_id,
execution_date=quote_plus(dttm.isoformat()),
)
class AirflowTestPlugin(AirflowPlugin):
name = "test_plugin"
global_operator_extra_links = [
GoogleLink(),
]
operator_extra_links = [
S3LogLink(),
]
with mock_plugin_manager(plugins=[AirflowTestPlugin]):
response = self.client.get(
"/api/v1/dags/TEST_DAG_ID/dagRuns/TEST_DAG_RUN_ID/taskInstances/TEST_SINGLE_QUERY/links"
)
self.assertEqual(200, response.status_code, response.data)
self.assertEqual(
{
"BigQuery Console": None,
"Google": "https://www.google.com",
"S3": (
"https://s3.amazonaws.com/airflow-logs/"
"TEST_DAG_ID/TEST_SINGLE_QUERY/2020-01-01T00%3A00%3A00%2B00%3A00"
),
},
response.json,
)