potiuk opened a new pull request #4500: [AIRFLOW-3681] All GCP operators have now optional GCP Project ID URL: https://github.com/apache/airflow/pull/4500 Make sure you have checked _all_ steps below. ### Jira - [x] My PR addresses the following [Airflow Jira](https://issues.apache.org/jira/browse/AIRFLOW/) issues and references them in the PR title. For example, "\[AIRFLOW-XXX\] My Airflow PR" - https://issues.apache.org/jira/browse/AIRFLOW-3681 ### Description - [x] Here are some details about my PR, including screenshots of any UI changes: The service account/connection to GCP can have an optional default project id assigned. The project id can be specified explicitly if we wish to override it, but when not specified (i.e. set to None) the default one should be used instead. This solution uses centralised decorator in order to have a common place where retrieval logic is implemented for all operators. Project_id is an important parameter of all GCP calls, therefore in hooks it is left as always first positional parameter and it has no default value. This has the added value that you have to explicitly provide a value = None if you want to use default project id. On the other hand in operators, project_id is optional as in this case you usually want to operate on default connection and project. ### Tests - [x] My PR adds the following unit test cases: * BigtableInstanceCreateTest.test_create_instance_that_exists_empty_project_id * BigtableInstanceCreateTest.test_updating_cluster_but_instance_does_not_exists_empty_project_id * BigtableInstanceCreateTest.test_updating_cluster_that_does_not_exists_empty_project_id * BigtableInstanceDeleteTest.test_delete_execute_empty_project_id * BigtableInstanceDeleteTest.test_deleting_instance_that_doesnt_exists_empty_project_id * BigtableTableDeleteTest.test_deleting_table_that_doesnt_exists_empty_project_id * BigtableTableCreateTest.test_creating_table_that_exists_empty_project_id * GceInstanceStartTest.test_start_should_not_throw_ex_when_project_id_None * GceInstanceStopTest.test_stop_should_not_throw_ex_when_project_id_none * GceInstanceSetMachineTypeTest.test_set_machine_type_should_not_throw_ex_when_project_id_none * GceInstanceGroupManagerUpdateTest.test_successful_instance_group_update_missing_project_id * GceInstanceTemplateCopyTest.test_successful_copy_template_missing_project_id * GcfFunctionDeployTest.test_empty_project_id_is_ok * CloudSpannerTest.test_instance_create_missing_project_id * CloudSpannerTest.test_instance_update_missing_project_id * CloudSpannerTest.test_instance_query_missing_project_id * CloudSpannerTest.test_database_update_missing_project_id * CloudSpannerTest.test_database_delete_missing_project_id * CloudSqlQueryValidationTest.test_create_operator_with_correct_parameters_project_id_missing * CloudSqlTest.test_instance_create_missing_project_id * CloudSqlTest.test_instance_patch_missing_project_id * CloudSqlTest.test_instance_delete_missing_project_id * CloudSqlTest.test_instance_db_create_missing_project_id * CloudSqlTest.test_instance_db_patch_missing_project_id * CloudSqlTest.test_instance_db_delete_missing_project_id * CloudSqlTest.test_instance_export_missing_project_id * CloudSqlTest.test_instance_import_missing_project_id System tests updated with cases with project_id not set: * example_gcp_sql_query.py * example_gcp_spanner.sql * example_gcp_sql.py * example_gcp_spanner.py * example_gcp_compute_igm.py * example_gcp_compute.py * example_gcp_bigtable_operators.py ### Commits - [x] My commits all reference Jira issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)": 1. Subject is separated from body by a blank line 1. Subject is limited to 50 characters (not including Jira issue reference) 1. Subject does not end with a period 1. Subject uses the imperative mood ("add", not "adding") 1. Body wraps at 72 characters 1. Body explains "what" and "why", not "how" ### Documentation - [x] In case of new functionality, my PR adds documentation that describes how to use it. Documentation is updated. Example dags now include examples with and without project_id ### Code Quality - [x] Passes `flake8`
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on 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
