-
Notifications
You must be signed in to change notification settings - Fork 17.1k
Add Amazon Provider Neptune Analytics #64274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
3075078
c28fefa
820f689
ebdbbbc
71aec4c
d63f954
0876b77
d140555
d86498d
6b5c88f
398b4d3
a5540d8
9524958
46fa89f
b2deb20
7f8c3a8
95c0b46
71b9a27
4c18486
ee4155f
933a123
e740ab6
054e05b
8c466bb
71c5db4
d2cf9b3
a4b2f3d
42cb361
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| .. 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. | ||
|
|
||
| ======================== | ||
| Amazon Neptune Analytics | ||
| ======================== | ||
|
|
||
| `Amazon Neptune Analytics <https://docs.aws.amazon.com/neptune-analytics/latest/userguide/what-is-neptune-analytics.html>`__ is a memory-optimized graph database engine for analytics. With Neptune Analytics, you can get insights and find trends by processing large amounts of graph data in seconds. | ||
|
|
||
| Prerequisite Tasks | ||
| ------------------ | ||
|
|
||
| .. include:: ../_partials/prerequisite_tasks.rst | ||
|
|
||
| Generic Parameters | ||
| ------------------ | ||
|
|
||
| .. include:: ../_partials/generic_parameters.rst | ||
|
|
||
| Operators | ||
| --------- | ||
|
|
||
| .. _howto/operator:NeptuneCreateGraphOperator: | ||
|
|
||
| Create a new Neptune Graph | ||
| ========================== | ||
|
|
||
| To create a new Neptune Analytics Graph, you can use | ||
| :class:`~airflow.providers.amazon.aws.operators.neptune_analytics.NeptuneCreateGraphOperator`. | ||
| This operator can be run in deferrable mode by passing ``deferrable=True`` as a parameter. This requires | ||
| the aiobotocore module to be installed. | ||
|
|
||
| .. exampleinclude:: /../../amazon/tests/system/amazon/aws/example_neptune_analytics.py | ||
| :language: python | ||
| :dedent: 4 | ||
| :start-after: [START howto_operator_neptune_analytics_create_graph] | ||
| :end-before: [END howto_operator_neptune_analytics_create_graph] | ||
|
|
||
|
|
||
| .. _howto/operator:NeptuneDeleteGraphOperator: | ||
|
|
||
| Delete a Neptune Graph | ||
| ====================== | ||
|
|
||
| To delete an existing Neptune Analytics Graph, you can use | ||
| :class:`~airflow.providers.amazon.aws.operators.neptune_analytics.NeptuneDeleteGraphOperator`. | ||
| This operator can be run in deferrable mode by passing ``deferrable=True`` as a parameter. This requires | ||
| the aiobotocore module to be installed. | ||
|
|
||
| .. exampleinclude:: /../../amazon/tests/system/amazon/aws/example_neptune_analytics.py | ||
| :language: python | ||
| :dedent: 4 | ||
| :start-after: [START howto_operator_neptune_analytics_delete_graph] | ||
| :end-before: [END howto_operator_neptune_analytics_delete_graph] | ||
|
|
||
| .. _howto/operator:NeptuneCreatePrivateGraphEndpointOperator: | ||
|
|
||
| Create a Neptune Graph private endpoint | ||
| ======================================= | ||
|
|
||
| To create a VPC Endpoint for connecting to an existing Neptune Graph, you can use | ||
| :class:`~airflow.providers.amazon.aws.operators.neptune_analytics.NeptuneCreatePrivateGraphEndpointOperator`. | ||
| This operator can be run in deferrable mode by passing ``deferrable=True`` as a parameter. This requires | ||
| the aiobotocore module to be installed. | ||
|
|
||
| .. exampleinclude:: /../../amazon/tests/system/amazon/aws/example_neptune_analytics.py | ||
| :language: python | ||
| :dedent: 4 | ||
| :start-after: [START howto_operator_neptune_analytics_create_private_endpoint] | ||
| :end-before: [END howto_operator_neptune_analytics_create_private_endpoint] | ||
|
|
||
| .. _howto/operator:NeptuneDeletePrivateGraphEndpointOperator: | ||
|
|
||
| Delete a Neptune Graph private endpoint | ||
| ======================================= | ||
|
|
||
| To delete a VPC Endpoint attached to an existing Neptune Graph, you can use | ||
| :class:`~airflow.providers.amazon.aws.operators.neptune_analytics.NeptuneDeletePrivateGraphEndpointOperator`. | ||
| This operator can be run in deferrable mode by passing ``deferrable=True`` as a parameter. This requires | ||
| the aiobotocore module to be installed. | ||
|
|
||
| .. exampleinclude:: /../../amazon/tests/system/amazon/aws/example_neptune_analytics.py | ||
| :language: python | ||
| :dedent: 4 | ||
| :start-after: [START howto_operator_neptune_analytics_delete_private_endpoint] | ||
| :end-before: [END howto_operator_neptune_analytics_delete_private_endpoint] | ||
|
|
||
| .. _howto/operator:NeptuneCreateGraphWithImportOperator: | ||
|
|
||
| Create a Neptune Graph with a data import task | ||
| ============================================== | ||
|
|
||
| To create a Neptune Analytics Graph and immediately import data, you can use | ||
| :class:`~airflow.providers.amazon.aws.operators.neptune_analytics.NeptuneCreateGraphWithImportOperator`. | ||
| This operator can be run in deferrable mode by passing ``deferrable=True`` as a parameter. This requires | ||
| the aiobotocore module to be installed. | ||
|
|
||
| .. exampleinclude:: /../../amazon/tests/system/amazon/aws/example_neptune_analytics.py | ||
| :language: python | ||
| :dedent: 4 | ||
| :start-after: [START howto_operator_neptune_analytics_create_graph_with_import] | ||
| :end-before: [END howto_operator_neptune_analytics_create_graph_with_import] | ||
|
|
||
| .. _howto/operator:NeptuneStartImportTaskOperator: | ||
|
|
||
| Import data into an existing Neptune Graph | ||
| ========================================== | ||
|
|
||
| To import data into an existing Neptune Analytics Graph, you can use | ||
| :class:`~airflow.providers.amazon.aws.operators.neptune_analytics.NeptuneStartImportTaskOperator`. | ||
| This operator can be run in deferrable mode by passing ``deferrable=True`` as a parameter. This requires | ||
| the aiobotocore module to be installed. | ||
|
|
||
| .. exampleinclude:: /../../amazon/tests/system/amazon/aws/example_neptune_analytics.py | ||
| :language: python | ||
| :dedent: 4 | ||
| :start-after: [START howto_operator_neptune_analytics_start_import_task] | ||
| :end-before: [END howto_operator_neptune_analytics_start_import_task] | ||
|
|
||
| .. _howto/operator:NeptuneCancelImportTaskOperator: | ||
|
|
||
| Cancel a running import task | ||
| ============================ | ||
|
|
||
| To cancel an existing import task, you can use | ||
| :class:`~airflow.providers.amazon.aws.operators.neptune_analytics.NeptuneCancelImportTaskOperator`. | ||
| This operator can be run in deferrable mode by passing ``deferrable=True`` as a parameter. This requires | ||
| the aiobotocore module to be installed. | ||
|
|
||
| .. exampleinclude:: /../../amazon/tests/system/amazon/aws/example_neptune_analytics.py | ||
| :language: python | ||
| :dedent: 4 | ||
| :start-after: [START howto_operator_neptune_analytics_cancel_import_task] | ||
| :end-before: [END howto_operator_neptune_analytics_cancel_import_task] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # | ||
| # 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 __future__ import annotations | ||
|
|
||
| from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook | ||
|
|
||
|
|
||
| class NeptuneAnalyticsHook(AwsBaseHook): | ||
| """ | ||
| Interact with Amazon Neptune Analytics. | ||
|
|
||
| Additional arguments (such as ``aws_conn_id``) may be specified and | ||
| are passed down to the underlying AwsBaseHook. | ||
|
|
||
| .. seealso:: | ||
| - :class:`~airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook` | ||
| """ | ||
|
|
||
| def __init__(self, *args, **kwargs): | ||
| kwargs["client_type"] = "neptune-graph" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. difference between neptune graph vs neptune analytics?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neptune analytics is how the service is identified in the AWS documentation. The boto3 service is neptune-graph, which causes confusion. I chose Neptune Analytics for all the operators since a customer is likely to use that name with searching. |
||
| super().__init__(*args, **kwargs) | ||
|
|
||
| def _get_graph_endpoint_id(self, graph_id: str, vpc_id: str): | ||
| """Return the vpc endpoint id for this graph.""" | ||
| result = self.conn.get_private_graph_endpoint(graphIdentifier=graph_id, vpcId=vpc_id) | ||
| return result.get("vpcEndpointId") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,3 +44,14 @@ class EC2InstanceDashboardLink(BaseAwsLink): | |
| @staticmethod | ||
| def format_instance_id_filter(instance_ids: list[str]) -> str: | ||
| return ",:".join(instance_ids) | ||
|
|
||
|
|
||
| class VpcEndpointLink(BaseAwsLink): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wondering if this should be in vpc.py
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't sure about this. I opted for ec2.py because all the VPC-related actions fall under the ec2 client. I'd probably search under VPC before I searched under ec2 if I were looking for this. What's the preference? |
||
| """Helper class for constructing a VPC Endpoint link.""" | ||
|
|
||
| name = "VPC Endpoint" | ||
| key = "_vpc_endpoint" | ||
| format_str = ( | ||
| BASE_AWS_CONSOLE_LINK | ||
| + "/vpcconsole/home?region={region_name}#EndpointDetails:vpcEndpointId={endpoint_id}" | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # 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 __future__ import annotations | ||
|
|
||
| from airflow.providers.amazon.aws.links.base_aws import BASE_AWS_CONSOLE_LINK, BaseAwsLink | ||
|
|
||
|
|
||
| class NeptuneGraphLink(BaseAwsLink): | ||
| """Helper class for constructing an Amazon Neptune Analytics Graph Link.""" | ||
|
|
||
| name = "Neptune Graph" | ||
| key = "_neptune_graph" | ||
| format_str = ( | ||
| BASE_AWS_CONSOLE_LINK | ||
| + "/neptune/home?region={region_name}#analytics-graph-details:id={graph_id}" | ||
| + ";tab=connectivity" | ||
| ) | ||
|
|
||
|
|
||
| class NeptuneImportTaskLink(BaseAwsLink): | ||
| """Helper class for constructing an Amazon Neptune Analytics import task link.""" | ||
|
|
||
| name = "Neptune Import Task" | ||
| key = "_import_task" | ||
| format_str = ( | ||
| BASE_AWS_CONSOLE_LINK | ||
| + "/neptune/home?region={region_name}#analytics-import-task-details:id={import_task_id}" | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
:class:references point toairflow.providers.amazon.aws.operators.neptune.*, but the Neptune Analytics operators in this PR live inairflow.providers.amazon.aws.operators.neptune_analytics. Update these references throughout this doc so the rendered documentation links to the correct classes.