You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "gopidesupavan (via GitHub)" <gi...@apache.org> on 2024/06/17 23:53:02 UTC

[PR] Add comprehend document classifier [airflow]

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

   <!--
    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.
    -->
   Adding Amazon Comprehend document classifier. Doc, Operator, Sensor, Trigger, Waiter, Unit Test, System Test.
   
   Manually tested in Breeze with
   
   wait_for_completion=False with a Sensor
   deferrable=True.
   wait_for_completion=True
   
   For the system test, I used two documents from AWS samples and created multiple copies. Since the classifier requires a minimum of 10 documents for training for each label. I've observed that it takes a maximum of 10 to 15 minutes to train the classifier, given the limited number of labels and documents. This is the minimum setup I was able to get running, so it can be executed in the daily system test suite.
   
   
   <img width="1220" alt="image" src="https://github.com/apache/airflow/assets/31437079/11d9cabf-66c9-4f49-99e7-2dc4b5fdb2d4">
   
   <!--
   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/
   -->
   
   
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **^ Add meaningful description above**
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.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+Improvement+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


Re: [PR] Add Amazon Comprehend Document Classifier [airflow]

Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #40287:
URL: https://github.com/apache/airflow/pull/40287#discussion_r1644637473


##########
tests/system/providers/amazon/aws/example_comprehend_document_classifier.py:
##########
@@ -0,0 +1,234 @@
+# 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
+
+import os
+import tempfile
+from datetime import datetime
+from urllib.request import urlretrieve
+
+from airflow import DAG
+from airflow.decorators import task, task_group
+from airflow.models.baseoperator import chain
+from airflow.providers.amazon.aws.hooks.comprehend import ComprehendHook
+from airflow.providers.amazon.aws.hooks.s3 import S3Hook
+from airflow.providers.amazon.aws.operators.comprehend import (
+    ComprehendCreateDocumentClassifierOperator,
+)
+from airflow.providers.amazon.aws.operators.s3 import (
+    S3CreateBucketOperator,
+    S3CreateObjectOperator,
+    S3DeleteBucketOperator,
+)
+from airflow.providers.amazon.aws.sensors.comprehend import (
+    ComprehendCreateDocumentClassifierCompletedSensor,
+)
+from airflow.utils.trigger_rule import TriggerRule
+from tests.system.providers.amazon.aws.utils import SystemTestContextBuilder
+
+ROLE_ARN_KEY = "ROLE_ARN"
+sys_test_context_task = SystemTestContextBuilder().add_variable(ROLE_ARN_KEY).build()
+
+DAG_ID = "example_comprehend_document_classifier"
+ANNOTATION_BUCKET_KEY = "training-labels/label.csv"
+TRAINING_DATA_PREFIX = "training-docs"
+
+# To create a custom document classifier, we need a minimum of 10 documents for each label.
+# for testing purpose, we will generate 10 copies of each document referenced below.
+PUBLIC_DATA_SOURCES = [
+    {
+        "fileName": "discharge-summary.pdf",
+        "url": "https://github.com/aws-samples/amazon-comprehend-examples/blob/master/building-custom-classifier/sample-docs/discharge-summary.pdf?raw=true",
+    },
+    {
+        "fileName": "doctors-notes.pdf",
+        "url": "https://github.com/aws-samples/amazon-comprehend-examples/blob/master/building-custom-classifier/sample-docs/doctors-notes.pdf?raw=true",
+    },
+]
+
+# Annotations file won't allow headers
+# label,document name,page number
+
+ANNOTATIONS = """DISCHARGE_SUMMARY,discharge-summary-0.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-1.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-2.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-3.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-4.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-5.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-6.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-7.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-8.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-9.pdf,1
+DOCTOR_NOTES,doctors-notes-0.pdf,1
+DOCTOR_NOTES,doctors-notes-1.pdf,1
+DOCTOR_NOTES,doctors-notes-2.pdf,1
+DOCTOR_NOTES,doctors-notes-3.pdf,1
+DOCTOR_NOTES,doctors-notes-4.pdf,1
+DOCTOR_NOTES,doctors-notes-5.pdf,1
+DOCTOR_NOTES,doctors-notes-6.pdf,1
+DOCTOR_NOTES,doctors-notes-7.pdf,1
+DOCTOR_NOTES,doctors-notes-8.pdf,1
+DOCTOR_NOTES,doctors-notes-9.pdf,1"""
+
+
+@task_group
+def document_classifier_workflow():
+    # [START howto_operator_create_document_classifier]
+    create_document_classifier = ComprehendCreateDocumentClassifierOperator(
+        task_id="create_document_classifier",
+        document_classifier_name=classifier_name,
+        input_data_config=input_data_configurations,
+        output_data_config=output_data_configurations,
+        mode="MULTI_CLASS",
+        data_access_role_arn=test_context[ROLE_ARN_KEY],
+        language_code="en",
+        document_classifier_kwargs=document_classifier_kwargs,
+    )
+    # [END howto_operator_create_document_classifier]
+    create_document_classifier.wait_for_completion = False
+
+    # [START howto_sensor_create_document_classifier]
+    await_create_document_classifier = ComprehendCreateDocumentClassifierCompletedSensor(
+        task_id="await_create_document_classifier", document_classifier_arn=create_document_classifier.output
+    )
+    # [END howto_sensor_create_document_classifier]
+
+    @task
+    def delete_classifier(document_classifier_arn: str):
+        ComprehendHook().conn.delete_document_classifier(DocumentClassifierArn=document_classifier_arn)
+
+    chain(
+        create_document_classifier,
+        await_create_document_classifier,
+        delete_classifier(create_document_classifier.output),
+    )
+
+
+@task
+def copy_data_to_s3(bucket: str, sources: list[dict], prefix: str, number_of_copies=1):

Review Comment:
   Have you considered using operators such as `HttpToS3Operator` or `LocalFilesystemToS3Operator`?



##########
tests/system/providers/amazon/aws/example_comprehend_document_classifier.py:
##########
@@ -0,0 +1,234 @@
+# 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
+
+import os
+import tempfile
+from datetime import datetime
+from urllib.request import urlretrieve
+
+from airflow import DAG
+from airflow.decorators import task, task_group
+from airflow.models.baseoperator import chain
+from airflow.providers.amazon.aws.hooks.comprehend import ComprehendHook
+from airflow.providers.amazon.aws.hooks.s3 import S3Hook
+from airflow.providers.amazon.aws.operators.comprehend import (
+    ComprehendCreateDocumentClassifierOperator,
+)
+from airflow.providers.amazon.aws.operators.s3 import (
+    S3CreateBucketOperator,
+    S3CreateObjectOperator,
+    S3DeleteBucketOperator,
+)
+from airflow.providers.amazon.aws.sensors.comprehend import (
+    ComprehendCreateDocumentClassifierCompletedSensor,
+)
+from airflow.utils.trigger_rule import TriggerRule
+from tests.system.providers.amazon.aws.utils import SystemTestContextBuilder
+
+ROLE_ARN_KEY = "ROLE_ARN"
+sys_test_context_task = SystemTestContextBuilder().add_variable(ROLE_ARN_KEY).build()
+
+DAG_ID = "example_comprehend_document_classifier"
+ANNOTATION_BUCKET_KEY = "training-labels/label.csv"
+TRAINING_DATA_PREFIX = "training-docs"
+
+# To create a custom document classifier, we need a minimum of 10 documents for each label.
+# for testing purpose, we will generate 10 copies of each document referenced below.
+PUBLIC_DATA_SOURCES = [
+    {
+        "fileName": "discharge-summary.pdf",
+        "url": "https://github.com/aws-samples/amazon-comprehend-examples/blob/master/building-custom-classifier/sample-docs/discharge-summary.pdf?raw=true",
+    },
+    {
+        "fileName": "doctors-notes.pdf",
+        "url": "https://github.com/aws-samples/amazon-comprehend-examples/blob/master/building-custom-classifier/sample-docs/doctors-notes.pdf?raw=true",
+    },
+]
+
+# Annotations file won't allow headers
+# label,document name,page number
+
+ANNOTATIONS = """DISCHARGE_SUMMARY,discharge-summary-0.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-1.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-2.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-3.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-4.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-5.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-6.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-7.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-8.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-9.pdf,1
+DOCTOR_NOTES,doctors-notes-0.pdf,1
+DOCTOR_NOTES,doctors-notes-1.pdf,1
+DOCTOR_NOTES,doctors-notes-2.pdf,1
+DOCTOR_NOTES,doctors-notes-3.pdf,1
+DOCTOR_NOTES,doctors-notes-4.pdf,1
+DOCTOR_NOTES,doctors-notes-5.pdf,1
+DOCTOR_NOTES,doctors-notes-6.pdf,1
+DOCTOR_NOTES,doctors-notes-7.pdf,1
+DOCTOR_NOTES,doctors-notes-8.pdf,1
+DOCTOR_NOTES,doctors-notes-9.pdf,1"""
+
+
+@task_group
+def document_classifier_workflow():
+    # [START howto_operator_create_document_classifier]
+    create_document_classifier = ComprehendCreateDocumentClassifierOperator(
+        task_id="create_document_classifier",
+        document_classifier_name=classifier_name,
+        input_data_config=input_data_configurations,
+        output_data_config=output_data_configurations,
+        mode="MULTI_CLASS",
+        data_access_role_arn=test_context[ROLE_ARN_KEY],
+        language_code="en",
+        document_classifier_kwargs=document_classifier_kwargs,
+    )
+    # [END howto_operator_create_document_classifier]
+    create_document_classifier.wait_for_completion = False
+
+    # [START howto_sensor_create_document_classifier]
+    await_create_document_classifier = ComprehendCreateDocumentClassifierCompletedSensor(
+        task_id="await_create_document_classifier", document_classifier_arn=create_document_classifier.output
+    )
+    # [END howto_sensor_create_document_classifier]
+
+    @task

Review Comment:
   ```suggestion
       @task(trigger_rule=TriggerRule.ALL_DONE)
   ```



-- 
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


Re: [PR] Add Amazon Comprehend Document Classifier [airflow]

Posted by "gopidesupavan (via GitHub)" <gi...@apache.org>.
gopidesupavan commented on code in PR #40287:
URL: https://github.com/apache/airflow/pull/40287#discussion_r1645011338


##########
tests/system/providers/amazon/aws/example_comprehend_document_classifier.py:
##########
@@ -0,0 +1,234 @@
+# 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
+
+import os
+import tempfile
+from datetime import datetime
+from urllib.request import urlretrieve
+
+from airflow import DAG
+from airflow.decorators import task, task_group
+from airflow.models.baseoperator import chain
+from airflow.providers.amazon.aws.hooks.comprehend import ComprehendHook
+from airflow.providers.amazon.aws.hooks.s3 import S3Hook
+from airflow.providers.amazon.aws.operators.comprehend import (
+    ComprehendCreateDocumentClassifierOperator,
+)
+from airflow.providers.amazon.aws.operators.s3 import (
+    S3CreateBucketOperator,
+    S3CreateObjectOperator,
+    S3DeleteBucketOperator,
+)
+from airflow.providers.amazon.aws.sensors.comprehend import (
+    ComprehendCreateDocumentClassifierCompletedSensor,
+)
+from airflow.utils.trigger_rule import TriggerRule
+from tests.system.providers.amazon.aws.utils import SystemTestContextBuilder
+
+ROLE_ARN_KEY = "ROLE_ARN"
+sys_test_context_task = SystemTestContextBuilder().add_variable(ROLE_ARN_KEY).build()
+
+DAG_ID = "example_comprehend_document_classifier"
+ANNOTATION_BUCKET_KEY = "training-labels/label.csv"
+TRAINING_DATA_PREFIX = "training-docs"
+
+# To create a custom document classifier, we need a minimum of 10 documents for each label.
+# for testing purpose, we will generate 10 copies of each document referenced below.
+PUBLIC_DATA_SOURCES = [
+    {
+        "fileName": "discharge-summary.pdf",
+        "url": "https://github.com/aws-samples/amazon-comprehend-examples/blob/master/building-custom-classifier/sample-docs/discharge-summary.pdf?raw=true",
+    },
+    {
+        "fileName": "doctors-notes.pdf",
+        "url": "https://github.com/aws-samples/amazon-comprehend-examples/blob/master/building-custom-classifier/sample-docs/doctors-notes.pdf?raw=true",
+    },
+]
+
+# Annotations file won't allow headers
+# label,document name,page number
+
+ANNOTATIONS = """DISCHARGE_SUMMARY,discharge-summary-0.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-1.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-2.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-3.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-4.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-5.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-6.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-7.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-8.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-9.pdf,1
+DOCTOR_NOTES,doctors-notes-0.pdf,1
+DOCTOR_NOTES,doctors-notes-1.pdf,1
+DOCTOR_NOTES,doctors-notes-2.pdf,1
+DOCTOR_NOTES,doctors-notes-3.pdf,1
+DOCTOR_NOTES,doctors-notes-4.pdf,1
+DOCTOR_NOTES,doctors-notes-5.pdf,1
+DOCTOR_NOTES,doctors-notes-6.pdf,1
+DOCTOR_NOTES,doctors-notes-7.pdf,1
+DOCTOR_NOTES,doctors-notes-8.pdf,1
+DOCTOR_NOTES,doctors-notes-9.pdf,1"""
+
+
+@task_group
+def document_classifier_workflow():
+    # [START howto_operator_create_document_classifier]
+    create_document_classifier = ComprehendCreateDocumentClassifierOperator(
+        task_id="create_document_classifier",
+        document_classifier_name=classifier_name,
+        input_data_config=input_data_configurations,
+        output_data_config=output_data_configurations,
+        mode="MULTI_CLASS",
+        data_access_role_arn=test_context[ROLE_ARN_KEY],
+        language_code="en",
+        document_classifier_kwargs=document_classifier_kwargs,
+    )
+    # [END howto_operator_create_document_classifier]
+    create_document_classifier.wait_for_completion = False
+
+    # [START howto_sensor_create_document_classifier]
+    await_create_document_classifier = ComprehendCreateDocumentClassifierCompletedSensor(
+        task_id="await_create_document_classifier", document_classifier_arn=create_document_classifier.output
+    )
+    # [END howto_sensor_create_document_classifier]
+
+    @task
+    def delete_classifier(document_classifier_arn: str):
+        ComprehendHook().conn.delete_document_classifier(DocumentClassifierArn=document_classifier_arn)
+
+    chain(
+        create_document_classifier,
+        await_create_document_classifier,
+        delete_classifier(create_document_classifier.output),
+    )
+
+
+@task
+def copy_data_to_s3(bucket: str, sources: list[dict], prefix: str, number_of_copies=1):

Review Comment:
   These are actually useful here, somehow i forgot. I have updated now, copy data to use HttpToS3Operator. Thank you @vincbeck. 😄  



-- 
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


Re: [PR] Add Amazon Comprehend Document Classifier [airflow]

Posted by "gopidesupavan (via GitHub)" <gi...@apache.org>.
gopidesupavan commented on code in PR #40287:
URL: https://github.com/apache/airflow/pull/40287#discussion_r1645008542


##########
tests/system/providers/amazon/aws/example_comprehend_document_classifier.py:
##########
@@ -0,0 +1,234 @@
+# 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
+
+import os
+import tempfile
+from datetime import datetime
+from urllib.request import urlretrieve
+
+from airflow import DAG
+from airflow.decorators import task, task_group
+from airflow.models.baseoperator import chain
+from airflow.providers.amazon.aws.hooks.comprehend import ComprehendHook
+from airflow.providers.amazon.aws.hooks.s3 import S3Hook
+from airflow.providers.amazon.aws.operators.comprehend import (
+    ComprehendCreateDocumentClassifierOperator,
+)
+from airflow.providers.amazon.aws.operators.s3 import (
+    S3CreateBucketOperator,
+    S3CreateObjectOperator,
+    S3DeleteBucketOperator,
+)
+from airflow.providers.amazon.aws.sensors.comprehend import (
+    ComprehendCreateDocumentClassifierCompletedSensor,
+)
+from airflow.utils.trigger_rule import TriggerRule
+from tests.system.providers.amazon.aws.utils import SystemTestContextBuilder
+
+ROLE_ARN_KEY = "ROLE_ARN"
+sys_test_context_task = SystemTestContextBuilder().add_variable(ROLE_ARN_KEY).build()
+
+DAG_ID = "example_comprehend_document_classifier"
+ANNOTATION_BUCKET_KEY = "training-labels/label.csv"
+TRAINING_DATA_PREFIX = "training-docs"
+
+# To create a custom document classifier, we need a minimum of 10 documents for each label.
+# for testing purpose, we will generate 10 copies of each document referenced below.
+PUBLIC_DATA_SOURCES = [
+    {
+        "fileName": "discharge-summary.pdf",
+        "url": "https://github.com/aws-samples/amazon-comprehend-examples/blob/master/building-custom-classifier/sample-docs/discharge-summary.pdf?raw=true",
+    },
+    {
+        "fileName": "doctors-notes.pdf",
+        "url": "https://github.com/aws-samples/amazon-comprehend-examples/blob/master/building-custom-classifier/sample-docs/doctors-notes.pdf?raw=true",
+    },
+]
+
+# Annotations file won't allow headers
+# label,document name,page number
+
+ANNOTATIONS = """DISCHARGE_SUMMARY,discharge-summary-0.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-1.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-2.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-3.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-4.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-5.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-6.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-7.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-8.pdf,1
+DISCHARGE_SUMMARY,discharge-summary-9.pdf,1
+DOCTOR_NOTES,doctors-notes-0.pdf,1
+DOCTOR_NOTES,doctors-notes-1.pdf,1
+DOCTOR_NOTES,doctors-notes-2.pdf,1
+DOCTOR_NOTES,doctors-notes-3.pdf,1
+DOCTOR_NOTES,doctors-notes-4.pdf,1
+DOCTOR_NOTES,doctors-notes-5.pdf,1
+DOCTOR_NOTES,doctors-notes-6.pdf,1
+DOCTOR_NOTES,doctors-notes-7.pdf,1
+DOCTOR_NOTES,doctors-notes-8.pdf,1
+DOCTOR_NOTES,doctors-notes-9.pdf,1"""
+
+
+@task_group
+def document_classifier_workflow():
+    # [START howto_operator_create_document_classifier]
+    create_document_classifier = ComprehendCreateDocumentClassifierOperator(
+        task_id="create_document_classifier",
+        document_classifier_name=classifier_name,
+        input_data_config=input_data_configurations,
+        output_data_config=output_data_configurations,
+        mode="MULTI_CLASS",
+        data_access_role_arn=test_context[ROLE_ARN_KEY],
+        language_code="en",
+        document_classifier_kwargs=document_classifier_kwargs,
+    )
+    # [END howto_operator_create_document_classifier]
+    create_document_classifier.wait_for_completion = False
+
+    # [START howto_sensor_create_document_classifier]
+    await_create_document_classifier = ComprehendCreateDocumentClassifierCompletedSensor(
+        task_id="await_create_document_classifier", document_classifier_arn=create_document_classifier.output
+    )
+    # [END howto_sensor_create_document_classifier]
+
+    @task

Review Comment:
   Updated.



-- 
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


Re: [PR] Add Amazon Comprehend Document Classifier [airflow]

Posted by "gopidesupavan (via GitHub)" <gi...@apache.org>.
gopidesupavan commented on PR #40287:
URL: https://github.com/apache/airflow/pull/40287#issuecomment-2176905727

   > Just 2 comments but overall fantastic work!!
   
   Thank you 😄 


-- 
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