potiuk commented on a change in pull request #21076:
URL: https://github.com/apache/airflow/pull/21076#discussion_r791509787
##########
File path: airflow/providers/github/.latest-doc-only-change.txt
##########
@@ -0,0 +1,2 @@
+87dc63b65daaf77c4c9f2f6611b72bcc78603d1e
+# TODO: fix this
Review comment:
You can remove this file.
##########
File path: airflow/providers/github/example_dags/example_github.py
##########
@@ -0,0 +1,57 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from datetime import datetime
+
+from airflow.decorators import task
+from airflow.models.dag import DAG
+from airflow.providers.github.hooks.github import GithubHook
+
+
+@task(task_id="github_task")
+def test_github_hook():
+ bucket_name = 'test-influx'
Review comment:
```suggestion
bucket_name = 'test-github'
```
##########
File path: airflow/providers/github/example_dags/example_github.py
##########
@@ -0,0 +1,57 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from datetime import datetime
+
+from airflow.decorators import task
+from airflow.models.dag import DAG
+from airflow.providers.github.hooks.github import GithubHook
+
+
+@task(task_id="github_task")
+def test_github_hook():
+ bucket_name = 'test-influx'
+ github_hook = GithubHook()
+ client = github_hook.get_conn()
+ print(client)
+ print(f"Organization name {github_hook.org_name}")
+
+ # Make sure enough permissions to create bucket.
+ github_hook.create_bucket(bucket_name, "Bucket to test github connection",
github_hook.org_name)
+ github_hook.write(bucket_name, "test_point", "location", "Prague",
"temperature", 25.3, True)
+
+ tables = github_hook.query('from(bucket:"test-influx") |> range(start:
-10m)')
Review comment:
Same here.
##########
File path: airflow/providers/github/hooks/github.py
##########
@@ -0,0 +1,77 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""This module allows to connect to a Github."""
+
+from typing import Dict
+
+from github import Github as GithubClient, PaginatedList
+
+from airflow.hooks.base import BaseHook
+
+
+class GithubHook(BaseHook):
+ """
+ Interact with Github.
+
+ Performs a connection to Github and retrieves client.
+
+ :param github_conn_id: Reference to :ref:`Github connection id
<howto/connection:github>`.
+ :type github_conn_id: str
+ """
+
+ conn_name_attr = 'github_conn_id'
+ default_conn_name = 'github_default'
+ conn_type = 'github'
+ hook_name = 'Github'
+
+ def __init__(self, github_conn_id: str = default_conn_name, *args,
**kwargs) -> None:
+ super().__init__(*args, **kwargs)
+ self.connection = None
+ self.github_conn_id = github_conn_id
+ self.client = None
+ self.get_conn()
+
+ def get_conn(self) -> GithubClient:
+ """
+ Function that initiates a new Github connection
+ with token and hostname name
+ """
+ if self.client is not None:
+ return self.client
+
+ self.connection = self.get_connection(self.github_conn_id)
+ access_token = self.connection.password
+
+ self.client = GithubClient(login_or_token=access_token)
+ return self.client
+
+ @staticmethod
+ def get_ui_field_behaviour() -> Dict:
+ """Returns custom field behaviour"""
+ return {
+ "hidden_fields": ['schema', 'port', 'host', 'login', 'extra'],
+ "relabeling": {
+ # 'host': 'Github Enterprise Url',
Review comment:
How about the commented hosts ?
##########
File path: airflow/providers/github/sensors/github.py
##########
@@ -0,0 +1,153 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from typing import Any, Callable, Dict, Optional
+
+from github import Repository, GithubException
+
+from airflow import AirflowException
+from airflow.providers.github.operators.github import GithubOperator
+from airflow.sensors.base import BaseSensorOperator
+from airflow.utils.context import Context
+
+
+class GithubSensor(BaseSensorOperator):
+ """
+ Base GithubSensor which can monitor for any change.
+
+ :param github_conn_id: reference to a pre-defined Github Connection
+ :type github_conn_id: str
+ :param method_name: method name from PyGithub to be executed
+ :type method_name: str
+ :param method_params: parameters for the method method_name
+ :type method_params: dict
+ :param result_processor: function that return boolean and act as a sensor
response
+ :type result_processor: function
+ """
+
+ def __init__(
+ self,
+ *,
+ method_name: str,
+ github_conn_id: str = 'github_default',
+ method_params: Optional[dict] = None,
+ result_processor: Optional[Callable] = None,
+ **kwargs,
+ ) -> None:
+ super().__init__(**kwargs)
+ self.github_conn_id = github_conn_id
+ self.result_processor = None
+ if result_processor is not None:
+ self.result_processor = result_processor
+ self.method_name = method_name
+ self.method_params = method_params
+ self.github_operator = GithubOperator(
+ task_id=self.task_id,
+ github_conn_id=self.github_conn_id,
+ github_method=self.method_name,
+ github_method_args=self.method_params,
+ result_processor=self.result_processor,
+ )
+
+ def poke(self, context: Dict) -> Any:
+ return self.github_operator.execute(context=context)
+
+
+class GithubRepositorySensor(GithubSensor):
Review comment:
```suggestion
class BaseGithubRepositorySensor(GithubSensor):
```
##########
File path: airflow/providers/github/sensors/github_old.py
##########
@@ -0,0 +1,68 @@
+# #
Review comment:
Shoudl be removed ?
##########
File path: docs/apache-airflow-providers-github/commits.rst
##########
@@ -0,0 +1,39 @@
+
Review comment:
This one can be removed or left empty - it should be updated after merge
- during release, otherwise it will have wrong commit id (but maybe it is
needed to stop test from failing in which case it can remain as it is).
##########
File path: docs/apache-airflow-providers-github/index.rst
##########
@@ -0,0 +1,103 @@
+
+ .. Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ .. http://www.apache.org/licenses/LICENSE-2.0
+
+ .. Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+``apache-airflow-providers-influxdb``
+=======================================
+
+Content
+-------
+
+.. toctree::
+ :maxdepth: 1
+ :caption: Guides
+
+ Connection types <connections/influxdb>
+ Operators <operators/index>
+
+.. toctree::
+ :maxdepth: 1
+ :caption: References
+
+ Python API <_api/airflow/providers/influxdb/index>
+
+.. toctree::
+ :maxdepth: 1
+ :caption: Resources
+
+ Example DAGs
<https://github.com/apache/airflow/tree/main/airflow/providers/influxdb/example_dags>
+
+.. toctree::
+ :maxdepth: 1
+ :caption: Resources
+
+ PyPI Repository
<https://pypi.org/project/apache-airflow-providers-influxdb/>
+
+.. toctree::
+ :maxdepth: 1
+ :caption: Resources
+
+ PyPI Repository
<https://pypi.org/project/apache-airflow-providers-influxdb/>
+ Installing from sources <installing-providers-from-sources>
+
+.. toctree::
+ :maxdepth: 1
+ :caption: Commits
+
+ Detailed list of commits <commits>
+
+.. THE REMAINDER OF THE FILE IS AUTOMATICALLY GENERATED. IT WILL BE
OVERWRITTEN AT RELEASE TIME!
+
+
+.. toctree::
+ :maxdepth: 1
+ :caption: Commits
+
+ Detailed list of commits <commits>
+
+
+Package apache-airflow-providers-influxdb
+------------------------------------------------------
+
+`InfluxDB <https://www.influxdata.com/>`__
Review comment:
Few references to influx here.
##########
File path: docs/apache-airflow-providers-github/index.rst
##########
@@ -0,0 +1,103 @@
+
+ .. Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ .. http://www.apache.org/licenses/LICENSE-2.0
+
+ .. Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+``apache-airflow-providers-influxdb``
+=======================================
+
+Content
+-------
+
+.. toctree::
+ :maxdepth: 1
+ :caption: Guides
+
+ Connection types <connections/influxdb>
+ Operators <operators/index>
+
+.. toctree::
+ :maxdepth: 1
+ :caption: References
+
+ Python API <_api/airflow/providers/influxdb/index>
+
+.. toctree::
+ :maxdepth: 1
+ :caption: Resources
+
+ Example DAGs
<https://github.com/apache/airflow/tree/main/airflow/providers/influxdb/example_dags>
+
+.. toctree::
+ :maxdepth: 1
+ :caption: Resources
+
+ PyPI Repository
<https://pypi.org/project/apache-airflow-providers-influxdb/>
+
+.. toctree::
+ :maxdepth: 1
+ :caption: Resources
+
+ PyPI Repository
<https://pypi.org/project/apache-airflow-providers-influxdb/>
+ Installing from sources <installing-providers-from-sources>
+
+.. toctree::
+ :maxdepth: 1
+ :caption: Commits
+
+ Detailed list of commits <commits>
+
+.. THE REMAINDER OF THE FILE IS AUTOMATICALLY GENERATED. IT WILL BE
OVERWRITTEN AT RELEASE TIME!
+
Review comment:
You can leave it empty. after that comment. It will be automatically
generated when we release.
--
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]