Skip to content

Commit

Permalink
remove data.zip
Browse files Browse the repository at this point in the history
  • Loading branch information
chraibi committed Oct 3, 2024
1 parent a7727e0 commit 31603f3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Main entry point to the app."""

import os
from pathlib import Path
import streamlit as st
from src.utils.logger_config import setup_logging
Expand Down Expand Up @@ -51,5 +52,11 @@
else:
st.warning("No files found. Please download the necessary data.")
if st.button("Download and Extract Data"):
if os.path.exists("data.zip"):
try:
os.remove("data.zip")
print("Deleted data.zip after extraction.")
except OSError as e:
print(f"Error deleting data.zip: {e}")
download_and_extract_zip()
st.success("Download and extraction complete!")
7 changes: 7 additions & 0 deletions src/utils/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,5 +882,12 @@ def download_and_extract_zip() -> None:
if os.path.exists(extracted_data_folder):
shutil.rmtree(extracted_data_folder)
return

if os.path.exists(zip_local_path):
try:
os.remove(zip_local_path)
logging.info(f"Deleted {zip_local_path} after extraction.")
except OSError as e:
logging.error(f"Error deleting {zip_local_path}: {e}")
else:
logging.info(f"{extracted_data_folder = } exists. Not downloading")

0 comments on commit 31603f3

Please sign in to comment.