Skip to content

Commit

Permalink
40559: fix add project_id to submit_batch_job hook (#40560)
Browse files Browse the repository at this point in the history
* fix: add project_id to submit_batch_job hook

* chore: static checks compliance
  • Loading branch information
guillaumeblaquiere authored Jul 2, 2024
1 parent 8e04ef0 commit bd73064
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion airflow/providers/google/cloud/operators/cloud_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ def __init__(

def execute(self, context: Context):
hook: CloudBatchHook = CloudBatchHook(self.gcp_conn_id, self.impersonation_chain)
job = hook.submit_batch_job(job_name=self.job_name, job=self.job, region=self.region)
job = hook.submit_batch_job(
job_name=self.job_name, job=self.job, region=self.region, project_id=self.project_id
)

if not self.deferrable:
completed_job = hook.wait_for_job(
Expand Down
4 changes: 3 additions & 1 deletion tests/providers/google/cloud/operators/test_cloud_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ def test_execute(self, mock):

assert completed_job["name"] == JOB_NAME

mock.return_value.submit_batch_job.assert_called_with(job_name=JOB_NAME, job=JOB, region=REGION)
mock.return_value.submit_batch_job.assert_called_with(
job_name=JOB_NAME, job=JOB, region=REGION, project_id=PROJECT_ID
)
mock.return_value.wait_for_job.assert_called()

@mock.patch(CLOUD_BATCH_HOOK_PATH)
Expand Down

0 comments on commit bd73064

Please sign in to comment.