You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/07/27 17:46:49 UTC

[GitHub] [airflow] syedahsn opened a new pull request, #25345: Convert Local to S3 example DAG to System Test (AIP-47)

syedahsn opened a new pull request, #25345:
URL: https://github.com/apache/airflow/pull/25345

   System test for local to S3, following the template in [#24643](https://github.com/apache/airflow/pull/24643) 
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] potiuk commented on pull request #25345: Convert Local to S3 example DAG to System Test (AIP-47)

Posted by GitBox <gi...@apache.org>.
potiuk commented on PR #25345:
URL: https://github.com/apache/airflow/pull/25345#issuecomment-1198487687

   some related failures.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] boring-cyborg[bot] commented on pull request #25345: Convert Local to S3 example DAG to System Test (AIP-47)

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on PR #25345:
URL: https://github.com/apache/airflow/pull/25345#issuecomment-1203781751

   Awesome work, congrats on your first merged pull request!
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] potiuk merged pull request #25345: Convert Local to S3 example DAG to System Test (AIP-47)

Posted by GitBox <gi...@apache.org>.
potiuk merged PR #25345:
URL: https://github.com/apache/airflow/pull/25345


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] josh-fell commented on a diff in pull request #25345: Convert Local to S3 example DAG to System Test (AIP-47)

Posted by GitBox <gi...@apache.org>.
josh-fell commented on code in PR #25345:
URL: https://github.com/apache/airflow/pull/25345#discussion_r933303535


##########
tests/system/providers/amazon/aws/example_local_to_s3.py:
##########
@@ -0,0 +1,101 @@
+# 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 os
+from datetime import datetime
+
+from airflow import DAG
+from airflow.decorators import task
+from airflow.models.baseoperator import chain
+from airflow.providers.amazon.aws.operators.s3 import S3CreateBucketOperator, S3DeleteBucketOperator
+from airflow.providers.amazon.aws.transfers.local_to_s3 import LocalFilesystemToS3Operator
+from airflow.utils.trigger_rule import TriggerRule
+from tests.system.providers.amazon.aws.utils import SystemTestContextBuilder
+
+sys_test_context_task = SystemTestContextBuilder().build()
+
+
+DAG_ID = 'example_local_to_s3'
+TEMP_FILE_PATH = '/tmp/sample-txt.txt'
+SAMPLE_TEXT = 'This is some sample text.'
+
+
+@task
+def create_temp_file():
+    file = open(TEMP_FILE_PATH, 'w')
+    file.write(SAMPLE_TEXT)
+
+
+@task(trigger_rule=TriggerRule.ALL_DONE)
+def delete_temp_file():
+    if os.path.exists(TEMP_FILE_PATH):
+        os.remove(TEMP_FILE_PATH)
+
+
+with DAG(
+    dag_id=DAG_ID,
+    schedule_interval='@once',
+    start_date=datetime(2021, 1, 1),  # Override to match your needs
+    tags=['example'],
+    catchup=False,
+) as dag:
+    test_context = sys_test_context_task()
+    env_id = test_context['ENV_ID']
+
+    s3_bucket_name = f'{env_id}-bucket'
+    s3_key = f'{env_id}/files/my-temp-file.txt'
+
+    create_s3_bucket = S3CreateBucketOperator(task_id='create-s3-bucket', bucket_name=s3_bucket_name)
+    # [START howto_transfer_local_to_s3]

Review Comment:
   These `START/END` markers in example DAGs are used in the Airflow docs as reference to code snippets. Since the example DAG moved, you'll need to update the [corresponding doc](https://github.com/apache/airflow/blob/main/docs/apache-airflow-providers-amazon/operators/transfer/local_to_s3.rst) to have this code reference point to the new file location of the markers.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org