[jira] [Commented] (AIRFLOW-3406) Implement an Azure CosmosDB operator

2018-12-06 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/AIRFLOW-3406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16711822#comment-16711822
 ] 

ASF GitHub Bot commented on AIRFLOW-3406:
-

feng-tao closed pull request #4265: [AIRFLOW-3406] Implement an Azure CosmosDB 
operator
URL: https://github.com/apache/incubator-airflow/pull/4265
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/airflow/contrib/example_dags/example_cosmosdb_sensor.py 
b/airflow/contrib/example_dags/example_cosmosdb_sensor.py
new file mode 100644
index 00..a801d9f41b
--- /dev/null
+++ b/airflow/contrib/example_dags/example_cosmosdb_sensor.py
@@ -0,0 +1,64 @@
+# -*- coding: utf-8 -*-
+#
+# 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 is only an example DAG to highlight usage of AzureCosmosDocumentSensor to 
detect
+if a document now exists.
+
+You can trigger this manually with `airflow trigger_dag 
example_cosmosdb_sensor`.
+
+*Note: Make sure that connection `azure_cosmos_default` is properly set before 
running
+this example.*
+"""
+
+from airflow import DAG
+from airflow.contrib.sensors.azure_cosmos_sensor import 
AzureCosmosDocumentSensor
+from airflow.contrib.operators.azure_cosmos_insertdocument_operator import 
AzureCosmosInsertDocumentOperator
+from airflow.utils import dates
+
+default_args = {
+'owner': 'airflow',
+'depends_on_past': False,
+'start_date': dates.days_ago(2),
+'email': ['airf...@example.com'],
+'email_on_failure': False,
+'email_on_retry': False
+}
+
+dag = DAG('example_cosmosdb_sensor', default_args=default_args)
+
+dag.doc_md = __doc__
+
+t1 = AzureCosmosDocumentSensor(
+task_id='check_cosmos_file',
+database_name='airflow_example_db',
+collection_name='airflow_example_coll',
+document_id='airflow_checkid',
+azure_cosmos_conn_id='azure_cosmos_default',
+dag=dag)
+
+t2 = AzureCosmosInsertDocumentOperator(
+task_id='insert_cosmos_file',
+dag=dag,
+database_name='airflow_example_db',
+collection_name='new-collection',
+document={"id": "someuniqueid", "param1": "value1", "param2": "value2"},
+azure_cosmos_conn_id='azure_cosmos_default')
+
+t2.set_upstream(t1)
diff --git a/airflow/contrib/hooks/azure_cosmos_hook.py 
b/airflow/contrib/hooks/azure_cosmos_hook.py
new file mode 100644
index 00..01b4007b03
--- /dev/null
+++ b/airflow/contrib/hooks/azure_cosmos_hook.py
@@ -0,0 +1,287 @@
+# -*- coding: utf-8 -*-
+#
+# 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.
+import azure.cosmos.cosmos_client as cosmos_client
+from azure.cosmos.errors import HTTPFailure
+import uuid
+
+from airflow.exceptions import AirflowBadRequest
+from airflow.hooks.base_hook import BaseHook
+
+
+class AzureCosmosDBHook(BaseHook):
+"""
+Interacts with Azure CosmosDB.
+
+login should be the endpoint uri, password should be the master key
+optionally, you can use the following extras to default these values
+{"database_name": "", "collection_name": "COLLECTION_NAME"}.
+
+:param azure_cosmos_conn_id: Reference to the Azure CosmosDB connection.
+:type azure_cosmos_conn_id: str
+"""
+
+def __init__(self, 

[jira] [Commented] (AIRFLOW-3406) Implement an Azure CosmosDB operator

2018-12-04 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/AIRFLOW-3406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16709543#comment-16709543
 ] 

ASF GitHub Bot commented on AIRFLOW-3406:
-

tmiller-msft opened a new pull request #4265: [AIRFLOW-3406] Implement an Azure 
CosmosDB operator
URL: https://github.com/apache/incubator-airflow/pull/4265
 
 
   Add an operator and hook to manipulate and use Azure
   CosmosDB documents, including creation, deletion, and
   updating documents and collections.
   
   Includes sensor to detect documents being added to a
   collection.
   
   Make sure you have checked _all_ steps below.
   
   ### Jira
   
   - [X] My PR addresses the following [Airflow 
Jira](https://issues.apache.org/jira/browse/AIRFLOW/) issues and references 
them in the PR title. For example, "\[AIRFLOW-XXX\] My Airflow PR"
 - https://issues.apache.org/jira/browse/AIRFLOW-3406
 - In case you are fixing a typo in the documentation you can prepend your 
commit with \[AIRFLOW-XXX\], code changes always need a Jira issue.
   
   ### Description
   
   - [X] Here are some details about my PR, including screenshots of any UI 
changes:
   An Azure CosmosDB  hook, operator, and sensor for manipulating documents and 
collections
   
   ### Tests
   
   - [X] My PR adds the following unit tests __OR__ does not need testing for 
this extremely good reason:
   
   ### Commits
   
   - [X] My commits all reference Jira issues in their subject lines, and I 
have squashed multiple commits if they address the same issue. In addition, my 
commits follow the guidelines from "[How to write a good git commit 
message](http://chris.beams.io/posts/git-commit/)":
 1. Subject is separated from body by a blank line
 1. Subject is limited to 50 characters (not including Jira issue reference)
 1. Subject does not end with a period
 1. Subject uses the imperative mood ("add", not "adding")
 1. Body wraps at 72 characters
 1. Body explains "what" and "why", not "how"
   
   ### Documentation
   
   - [X] In case of new functionality, my PR adds documentation that describes 
how to use it.
 - When adding new operators/hooks/sensors, the autoclass documentation 
generation needs to be added.
   
   ### Code Quality
   
   - [X] Passes `flake8`
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Implement an Azure CosmosDB operator 
> -
>
> Key: AIRFLOW-3406
> URL: https://issues.apache.org/jira/browse/AIRFLOW-3406
> Project: Apache Airflow
>  Issue Type: New Feature
>Reporter: Tom Miller
>Assignee: Tom Miller
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (AIRFLOW-3406) Implement an Azure CosmosDB operator

2018-12-04 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/AIRFLOW-3406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16709526#comment-16709526
 ] 

ASF GitHub Bot commented on AIRFLOW-3406:
-

tmiller-msft closed pull request #4265: [AIRFLOW-3406] Implement an Azure 
CosmosDB operator
URL: https://github.com/apache/incubator-airflow/pull/4265
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):



 


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Implement an Azure CosmosDB operator 
> -
>
> Key: AIRFLOW-3406
> URL: https://issues.apache.org/jira/browse/AIRFLOW-3406
> Project: Apache Airflow
>  Issue Type: New Feature
>Reporter: Tom Miller
>Assignee: Tom Miller
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (AIRFLOW-3406) Implement an Azure CosmosDB operator

2018-12-01 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/AIRFLOW-3406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16706088#comment-16706088
 ] 

ASF GitHub Bot commented on AIRFLOW-3406:
-

tmiller-msft opened a new pull request #4265: [AIRFLOW-3406] Implement an Azure 
CosmosDB operator
URL: https://github.com/apache/incubator-airflow/pull/4265
 
 
   Add an operator and hook to manipulate and use Azure
   CosmosDB documents, including creation, deletion, and
   updating documents and collections.
   
   Includes sensor to detect documents being added to a
   collection.
   
   Make sure you have checked _all_ steps below.
   
   ### Jira
   
   - [X] My PR addresses the following [Airflow 
Jira](https://issues.apache.org/jira/browse/AIRFLOW/) issues and references 
them in the PR title. For example, "\[AIRFLOW-XXX\] My Airflow PR"
 - https://issues.apache.org/jira/browse/AIRFLOW-3406
 - In case you are fixing a typo in the documentation you can prepend your 
commit with \[AIRFLOW-XXX\], code changes always need a Jira issue.
   
   ### Description
   
   - [X] Here are some details about my PR, including screenshots of any UI 
changes:
   An Azure CosmosDB  hook, operator, and sensor for manipulating documents and 
collections
   
   ### Tests
   
   - [X] My PR adds the following unit tests __OR__ does not need testing for 
this extremely good reason:
   
   ### Commits
   
   - [X] My commits all reference Jira issues in their subject lines, and I 
have squashed multiple commits if they address the same issue. In addition, my 
commits follow the guidelines from "[How to write a good git commit 
message](http://chris.beams.io/posts/git-commit/)":
 1. Subject is separated from body by a blank line
 1. Subject is limited to 50 characters (not including Jira issue reference)
 1. Subject does not end with a period
 1. Subject uses the imperative mood ("add", not "adding")
 1. Body wraps at 72 characters
 1. Body explains "what" and "why", not "how"
   
   ### Documentation
   
   - [X] In case of new functionality, my PR adds documentation that describes 
how to use it.
 - When adding new operators/hooks/sensors, the autoclass documentation 
generation needs to be added.
   
   ### Code Quality
   
   - [X] Passes `flake8`
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Implement an Azure CosmosDB operator 
> -
>
> Key: AIRFLOW-3406
> URL: https://issues.apache.org/jira/browse/AIRFLOW-3406
> Project: Apache Airflow
>  Issue Type: New Feature
>Reporter: Tom Miller
>Assignee: Tom Miller
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (AIRFLOW-3406) Implement an Azure CosmosDB operator

2018-12-01 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/AIRFLOW-3406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16706087#comment-16706087
 ] 

ASF GitHub Bot commented on AIRFLOW-3406:
-

tmiller-msft closed pull request #4264: [AIRFLOW-3406] Implement an Azure 
CosmosDB operator
URL: https://github.com/apache/incubator-airflow/pull/4264
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/airflow/contrib/example_dags/example_cosmosdb_sensor.py 
b/airflow/contrib/example_dags/example_cosmosdb_sensor.py
new file mode 100644
index 00..a801d9f41b
--- /dev/null
+++ b/airflow/contrib/example_dags/example_cosmosdb_sensor.py
@@ -0,0 +1,64 @@
+# -*- coding: utf-8 -*-
+#
+# 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 is only an example DAG to highlight usage of AzureCosmosDocumentSensor to 
detect
+if a document now exists.
+
+You can trigger this manually with `airflow trigger_dag 
example_cosmosdb_sensor`.
+
+*Note: Make sure that connection `azure_cosmos_default` is properly set before 
running
+this example.*
+"""
+
+from airflow import DAG
+from airflow.contrib.sensors.azure_cosmos_sensor import 
AzureCosmosDocumentSensor
+from airflow.contrib.operators.azure_cosmos_insertdocument_operator import 
AzureCosmosInsertDocumentOperator
+from airflow.utils import dates
+
+default_args = {
+'owner': 'airflow',
+'depends_on_past': False,
+'start_date': dates.days_ago(2),
+'email': ['airf...@example.com'],
+'email_on_failure': False,
+'email_on_retry': False
+}
+
+dag = DAG('example_cosmosdb_sensor', default_args=default_args)
+
+dag.doc_md = __doc__
+
+t1 = AzureCosmosDocumentSensor(
+task_id='check_cosmos_file',
+database_name='airflow_example_db',
+collection_name='airflow_example_coll',
+document_id='airflow_checkid',
+azure_cosmos_conn_id='azure_cosmos_default',
+dag=dag)
+
+t2 = AzureCosmosInsertDocumentOperator(
+task_id='insert_cosmos_file',
+dag=dag,
+database_name='airflow_example_db',
+collection_name='new-collection',
+document={"id": "someuniqueid", "param1": "value1", "param2": "value2"},
+azure_cosmos_conn_id='azure_cosmos_default')
+
+t2.set_upstream(t1)
diff --git a/airflow/contrib/hooks/azure_cosmos_hook.py 
b/airflow/contrib/hooks/azure_cosmos_hook.py
new file mode 100644
index 00..4e5a153bbb
--- /dev/null
+++ b/airflow/contrib/hooks/azure_cosmos_hook.py
@@ -0,0 +1,237 @@
+# -*- coding: utf-8 -*-
+#
+# 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.
+import azure.cosmos.cosmos_client as cosmos_client
+from azure.cosmos.errors import HTTPFailure
+import uuid
+
+from airflow.exceptions import AirflowBadRequest
+from airflow.hooks.base_hook import BaseHook
+
+
+class AzureCosmosDBHook(BaseHook):
+"""
+Interacts with Azure CosmosDB.
+
+login should be the endpoint uri, password should be the master key
+optionally, you can use the following extras to default these values
+{"database_name": "", "collection_name": "COLLECTION_NAME"}.
+
+:param azure_cosmos_conn_id: Reference to the Azure CosmosDB connection.
+:type azure_cosmos_conn_id: str
+"""
+
+def __init__(self, 

[jira] [Commented] (AIRFLOW-3406) Implement an Azure CosmosDB operator

2018-12-01 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/AIRFLOW-3406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16706073#comment-16706073
 ] 

ASF GitHub Bot commented on AIRFLOW-3406:
-

tmiller-msft opened a new pull request #4264: [AIRFLOW-3406] Implement an Azure 
CosmosDB operator
URL: https://github.com/apache/incubator-airflow/pull/4264
 
 
   Add an operator and hook to manipulate and use Azure
   CosmosDB documents, including creation, deletion, and
   updating documents and collections.
   
   Includes sensor to detect documents being added to a
   collection.
   
   Make sure you have checked _all_ steps below.
   
   ### Jira
   
   - [X] My PR addresses the following [Airflow 
Jira](https://issues.apache.org/jira/browse/AIRFLOW/) issues and references 
them in the PR title. For example, "\[AIRFLOW-XXX\] My Airflow PR"
 - https://issues.apache.org/jira/browse/AIRFLOW-3406
 - In case you are fixing a typo in the documentation you can prepend your 
commit with \[AIRFLOW-XXX\], code changes always need a Jira issue.
   
   ### Description
   
   - [X] Here are some details about my PR, including screenshots of any UI 
changes:
   An Azure CosmosDB hook, operator, and sensor to manipulate Azure's CosmosDB 
   
   ### Tests
   
   - [X] My PR adds the following unit tests __OR__ does not need testing for 
this extremely good reason:
   
   ### Commits
   
   - [X] My commits all reference Jira issues in their subject lines, and I 
have squashed multiple commits if they address the same issue. In addition, my 
commits follow the guidelines from "[How to write a good git commit 
message](http://chris.beams.io/posts/git-commit/)":
 1. Subject is separated from body by a blank line
 1. Subject is limited to 50 characters (not including Jira issue reference)
 1. Subject does not end with a period
 1. Subject uses the imperative mood ("add", not "adding")
 1. Body wraps at 72 characters
 1. Body explains "what" and "why", not "how"
   
   ### Documentation
   
   - [X] In case of new functionality, my PR adds documentation that describes 
how to use it.
 - When adding new operators/hooks/sensors, the autoclass documentation 
generation needs to be added.
   
   ### Code Quality
   
   - [X] Passes `flake8`
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Implement an Azure CosmosDB operator 
> -
>
> Key: AIRFLOW-3406
> URL: https://issues.apache.org/jira/browse/AIRFLOW-3406
> Project: Apache Airflow
>  Issue Type: New Feature
>Reporter: Tom Miller
>Assignee: Tom Miller
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)