From 105edcb08df3a9906b5c9459befd2ce44460e7b8 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 11 Sep 2025 09:42:22 -0700 Subject: [PATCH 1/3] Add .pre-commit-ci.yaml configuration for develop branch autoupdates (#681) * Initial plan * Add .pre-commit-ci.yaml configuration file for develop branch autoupdates Co-authored-by: ktehranchi <83722342+ktehranchi@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ktehranchi <83722342+ktehranchi@users.noreply.github.com> --- .pre-commit-ci.yaml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .pre-commit-ci.yaml diff --git a/.pre-commit-ci.yaml b/.pre-commit-ci.yaml new file mode 100644 index 00000000..eabac4bb --- /dev/null +++ b/.pre-commit-ci.yaml @@ -0,0 +1 @@ +autoupdate_branch: develop \ No newline at end of file From 04a043923dac7a8d246bb2045ba2916c5ae09437 Mon Sep 17 00:00:00 2001 From: Will McNeil Date: Mon, 29 Sep 2025 16:39:42 -0700 Subject: [PATCH 2/3] Make rule runnable on windows; add zipfile-deflate64 dependency --- pyproject.toml | 1 + workflow/scripts/retrieve_databundles.py | 26 ++++++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 726fe0c3..10591538 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,6 +60,7 @@ dependencies = [ "tsam>=2.3.6", "xarray==2024.9.0", "xlrd==2.0.1", + "zipfile-deflate64==0.2.0" ] diff --git a/workflow/scripts/retrieve_databundles.py b/workflow/scripts/retrieve_databundles.py index 95921ea3..458c78d0 100644 --- a/workflow/scripts/retrieve_databundles.py +++ b/workflow/scripts/retrieve_databundles.py @@ -6,6 +6,11 @@ import zipfile from pathlib import Path +import zipfile_deflate64 # For Windows OS, use zipfile-deflate64 + +def is_wsl(): + with open('/proc/version', 'r') as f: + return 'microsoft' in f.read().lower() from _helpers import configure_logging, progress_retrieve logger = logging.getLogger(__name__) @@ -29,14 +34,17 @@ def download_repository(url, rootpath, repository): progress_retrieve(url, tarball_fn) logger.info(f"Extracting {repository} databundle.") - if ( - repository == "EFS" - ): # deflate64 compression not supported by zipFile, current subprocess command will only work on linux and mac - if platform.system() == "Windows": - cmd = ["tar", "-xf", tarball_fn, "-C", to_fn] - else: - cmd = ["unzip", tarball_fn, "-d", to_fn] - subprocess.run(cmd, check=True) + if repository == "EFS": + if platform.system() == "Windows" or is_wsl(): # Handle both Windows and WSL + try: + with zipfile_deflate64.ZipFile(tarball_fn, "r") as zip_ref: + zip_ref.extractall(to_fn) + except Exception as e: + logger.error(f"Failed to extract zip file with zipfile_deflate64: {e}") + raise + else: # Pure Linux environment + cmd = ["unzip", tarball_fn, "-d", str(to_fn)] + subprocess.run(cmd, check=True) else: with zipfile.ZipFile(tarball_fn, "r") as zip_ref: zip_ref.extractall(to_fn) @@ -62,4 +70,4 @@ def download_repository(url, rootpath, repository): repositories = snakemake.params[0] for repository in repositories: url = repositories[repository] - download_repository(url, rootpath, repository) + download_repository(url, rootpath, repository) \ No newline at end of file From baf16cf720267ef5a3cb28b371b89a50634df1b7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Sep 2025 23:43:06 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .pre-commit-ci.yaml | 2 +- workflow/scripts/retrieve_databundles.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.pre-commit-ci.yaml b/.pre-commit-ci.yaml index eabac4bb..47258ede 100644 --- a/.pre-commit-ci.yaml +++ b/.pre-commit-ci.yaml @@ -1 +1 @@ -autoupdate_branch: develop \ No newline at end of file +autoupdate_branch: develop diff --git a/workflow/scripts/retrieve_databundles.py b/workflow/scripts/retrieve_databundles.py index 458c78d0..096f7456 100644 --- a/workflow/scripts/retrieve_databundles.py +++ b/workflow/scripts/retrieve_databundles.py @@ -6,11 +6,14 @@ import zipfile from pathlib import Path -import zipfile_deflate64 # For Windows OS, use zipfile-deflate64 +import zipfile_deflate64 # For Windows OS, use zipfile-deflate64 + def is_wsl(): - with open('/proc/version', 'r') as f: - return 'microsoft' in f.read().lower() + with open("/proc/version") as f: + return "microsoft" in f.read().lower() + + from _helpers import configure_logging, progress_retrieve logger = logging.getLogger(__name__) @@ -70,4 +73,4 @@ def download_repository(url, rootpath, repository): repositories = snakemake.params[0] for repository in repositories: url = repositories[repository] - download_repository(url, rootpath, repository) \ No newline at end of file + download_repository(url, rootpath, repository)