Skip to content

Commit

Permalink
Merge pull request #178 from Shubha-accenture/papermill_file_check_fix
Browse files Browse the repository at this point in the history
Fix to bug Job schedule not working for new plugin customers
  • Loading branch information
ojarjur authored Sep 5, 2024
2 parents 9519b25 + 78bb5d0 commit 8942d59
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
18 changes: 11 additions & 7 deletions dataproc_jupyter_plugin/services/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import subprocess
import uuid
from datetime import datetime, timedelta
from google.cloud import storage
from google.api_core.exceptions import NotFound

import aiohttp
import pendulum
Expand Down Expand Up @@ -86,14 +88,16 @@ async def get_bucket(self, runtime_env):
self.log.exception(f"Error getting bucket name: {str(e)}")
raise Exception(f"Error getting composer bucket: {str(e)}")

async def check_file_exists(self, bucket, file_path):
async def check_file_exists(self, bucket_name, file_path):
try:
cmd = f"gsutil ls gs://{bucket}/dataproc-notebooks/{file_path}"
await async_run_gsutil_subcommand(cmd)
return True
except subprocess.CalledProcessError as error:
self.log.exception(f"Error checking papermill file: {error.decode()}")
raise IOError(error.decode)
if not bucket_name:
raise ValueError("Bucket name cannot be empty")
bucket = storage.Client().bucket(bucket_name)
blob = bucket.blob(file_path)
return blob.exists()
except Exception as error:
self.log.exception(f"Error checking file: {error}")
raise IOError(f"Error creating dag: {error}")

async def upload_papermill_to_gcs(self, gcs_dag_bucket):
env = Environment(
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ dependencies = [
"pendulum>=3.0.0",
"pydantic~=1.10.0",
"bigframes~=0.22.0",
"aiohttp~=3.9.5"
"aiohttp~=3.9.5",
"google-cloud-storage~=2.18.2"
]
dynamic = ["version", "description", "authors", "urls", "keywords"]

Expand Down

0 comments on commit 8942d59

Please sign in to comment.