Skip to content

Commit

Permalink
moved force regrid in path_exists
Browse files Browse the repository at this point in the history
  • Loading branch information
aniketsinghrawat committed Jan 2, 2024
1 parent fda21bd commit bf2dfeb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion weather_mv/loader_pipeline/regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def apply(self, uri: str):
if self.dry_run:
return

if not self.force_regrid and path_exists(self.target_from(uri)):
if path_exists(self.target_from(uri), self.force_regrid):
logger.info(f"Skipping {uri}")
return

Expand Down
5 changes: 4 additions & 1 deletion weather_mv/loader_pipeline/sinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,12 @@ def upload(src: str, dst: str) -> None:
"""Uploads a file to the specified GCS bucket destination."""
subprocess.run(f'gsutil -m cp {src} {dst}'.split(), check=True, capture_output=True, text=True, input="n/n")

def path_exists(path: str) -> bool:
def path_exists(path: str, force_regrid: bool = False) -> bool:
"""Check if path exists at a certain location.
First Check in Google Cloud Storage then in Local file system."""
if force_regrid:
return False

for command in [
f'gsutil ls {path}',
f'ls {path}'
Expand Down

0 comments on commit bf2dfeb

Please sign in to comment.