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 2021/12/02 15:14:32 UTC

[GitHub] [airflow] bradleybonitatibus opened a new issue #19977: GoogleDriveToGCSOperator.dry_run raises AttributeError due to deprecated template_fields

bradleybonitatibus opened a new issue #19977:
URL: https://github.com/apache/airflow/issues/19977


   ### Apache Airflow Provider(s)
   
   google
   
   ### Versions of Apache Airflow Providers
   
   apache-airflow-providers-google==5.1.0
   
   ### Apache Airflow version
   
   2.1.4
   
   ### Operating System
   
   MacOS BigSur 11.6
   
   ### Deployment
   
   Virtualenv installation
   
   ### Deployment details
   
   `tox4` virtual environment
   
   ### What happened
   
   1) Unit testing some DAG task operators with `asset op.dry_run() is None`
   2) `AttributeError` is raised when `baseoperator` iterates through `template_fields` and calls `getattr`
   
   ```
       def dry_run(self) -> None:
           """Performs dry run for the operator - just render template fields."""
           self.log.info('Dry run')
           for field in self.template_fields:
               content = getattr(self, field)
   ```
   3) Caused by deprecated `destination_bucket` argument, is being assigned to `self.bucket_name`
   
   
   ### What you expected to happen
   
   Calling `op.dry_run()` should return None and not raise any exceptions.
   
   The templated fields contains deprecated arguments (`destination_bucket`, `destination_object`), and aren't initialized in the init method for the class.
   
   The base operator loops through these templated fields, but since `GoogleDriveToGCSOperator` does not initialize `self.destination_bucket` or `self.destination_object`, it raises an `AttributeError`
   
   ### How to reproduce
   
   ```python
   
   from airflow.providers.google.cloud.transfers import gdrive_to_gcs
   
   
   # pytest fixtures included as arguments
   # won't include for brevity, but can provide if necessary
   def test_gdrive_to_gcs_transfer(
           test_dag,
           mock_gcp_default_conn,
           patched_log_entry,
           today
   ):
       op = gdrive_to_gcs.GoogleDriveToGCSOperator(
           task_id="test_gcs_to_gdrive_transfer",
           dag=test_dag,
           bucket_name="some-other-bucket",
           object_name="thing_i_want_to_copy.csv",
           file_name="my_file.csv",
           folder_id="my_folder",
           drive_id="some_drive_id",
       )
       assert op.dry_run() is None
   ```
   
   ### Anything else
   
   Not sure where it would be appropriate to address this issue since the deprecated fields support backward compatibility to previous versions of the operator.
   
   This is my first time contributing to the project, but hope this is helpful.
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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] ashb commented on issue #19977: GoogleDriveToGCSOperator.dry_run() raises AttributeError due to deprecated template_fields

Posted by GitBox <gi...@apache.org>.
ashb commented on issue #19977:
URL: https://github.com/apache/airflow/issues/19977#issuecomment-985051686


   Closed by #19991


-- 
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 issue #19977: GoogleDriveToGCSOperator.dry_run raises AttributeError due to deprecated template_fields

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #19977:
URL: https://github.com/apache/airflow/issues/19977#issuecomment-984720604


   Thanks for opening your first issue here! Be sure to follow the issue template!
   


-- 
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 issue #19977: GoogleDriveToGCSOperator.dry_run() raises AttributeError due to deprecated template_fields

Posted by GitBox <gi...@apache.org>.
potiuk commented on issue #19977:
URL: https://github.com/apache/airflow/issues/19977#issuecomment-985004138


   I assigned you to it @bradleybonitatibus 


-- 
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] ashb closed issue #19977: GoogleDriveToGCSOperator.dry_run() raises AttributeError due to deprecated template_fields

Posted by GitBox <gi...@apache.org>.
ashb closed issue #19977:
URL: https://github.com/apache/airflow/issues/19977


   


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