potiuk commented on a change in pull request #6773: [AIRFLOW-6038] AWS DataSync
example_dags added
URL: https://github.com/apache/airflow/pull/6773#discussion_r358705820
##########
File path: airflow/providers/amazon/aws/operators/datasync.py
##########
@@ -18,34 +16,48 @@
# under the License.
"""
-Get, Create, Update, Delete and execute an AWS DataSync Task.
+Create, get, update, execute and delete an AWS DataSync Task.
"""
+import random
+
from airflow.exceptions import AirflowException
from airflow.models import BaseOperator
from airflow.providers.amazon.aws.hooks.datasync import AWSDataSyncHook
from airflow.utils.decorators import apply_defaults
-class AWSDataSyncCreateTaskOperator(BaseOperator):
- r"""Create an AWS DataSync Task.
+# pylint: disable=too-many-instance-attributes, too-many-arguments
+class AWSDataSyncOperator(BaseOperator):
+ r"""Find, Create, Update, Execute and Delete AWS DataSync Tasks.
- If there are existing Locations which match the specified
- source and destination URIs then these will be used for the Task.
- Otherwise, new Locations can be created automatically,
- depending on input parameters.
+ If ``do_xcom_push`` is True, then the DataSync TaskArn and TaskExecutionArn
+ which were executed will be pushed to an XCom.
- If ``do_xcom_push`` is True, the TaskArn which is created
- will be pushed to an XCom.
+ .. seealso::
+ For more information on how to use this operator, take a look at the
guide:
+ :ref:`howto/operator:AWSDataSyncOperator`
+
+ .. note:: There may be 0, 1, or many existing DataSync Tasks defined in
your AWS
+ environment. The default behavior is to create a new Task if there are
0, or
+ execute the Task if there was 1 Task, or fail if there were many Tasks.
:param str aws_conn_id: AWS connection to use.
- :param str source_location_uri: Source location URI.
+ :param int wait_interval_seconds: Time to wait between two
+ consecutive calls to check TaskExecution status.
+ :param str task_arn: AWS DataSync TaskArn to use. If None, then this
operator will
+ attempt to either search for an existing Task or attempt to create a
new Task.
+ :param str source_location_uri: Source location URI to search for. All
DataSync
+ Tasks with a LocationArn with this URI will be considered.
Example: ``smb://server/subdir``
- :param str destination_location_uri: Destination location URI.
+ :param str destination_location_uri: Destination location URI to search
for.
+ All DataSync Tasks with a LocationArn with this URI will be considered.
Example: ``s3://airflow_bucket/stuff``
- :param bool case_sensitive_location_search: Whether or not to do a
- case-sensitive search for each Location URI.
- :param dict create_task_kwargs: If no suitable TaskArn is found,
+ :param str choose_task_strategy: If multiple Tasks match, one must be
chosen to
Review comment:
I think it would be a bit better to have a bool here
"allow_random_task_selection" and "allow_random_location_selection" or similar.
I think it is a bit overkill to have 'random' string as the only strategy
implemented. My thought when I was reviewing it was "ok - what are the other
strategies ?".
I believe you had in mind to make it future-compatible. In the future we
might be able to not change the interface and use other strategies, but I think
this is a bit of a trap (that's what is suggested by the documentation). I
think this is a bit of a trap - I prefer to implement *just* what is needed in
the simplest possible way. We can always add new parameters in the future in
case we find out that we need. I think the initial idea with callable was
pretty good for the more complex cases (much better than imaginary
'choose_first', 'choose_first_alphabetically', 'fifo', 'lifo' etc. etc.). In
this case it seems that the "random" bool might simply survive as bool flag (if
callable is not specified). In such case str 'random' strategy will be
sttrange.
If we want to introduce 'str' strategy in the future we might always add it
as a new field that can even be working together with random flag (for example
the strategy might pre-select subset of tasks and THEN random choice will be
used).
I do not have a very strong opinion here - I leave it up to you to either
fix or leave as it is, but at least consider this.
----------------------------------------------------------------
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]
With regards,
Apache Git Services