From e3ad87e1c831958f68a75390bee4a37d636af8a6 Mon Sep 17 00:00:00 2001 From: Jack Kolb Date: Sun, 28 Apr 2024 14:53:32 -0400 Subject: [PATCH 1/4] try/catching the git-lfs prune for versions that do not support -f Some common git-lfs versions (e.g., 2.9.2 which Ubuntu 20.04 runs) do not support the -f flag on `git lfs prune`. This change wraps the `git lfs prune -f --recent` call in a try/catch for compatibility. --- src_python/habitat_sim/utils/datasets_download.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src_python/habitat_sim/utils/datasets_download.py b/src_python/habitat_sim/utils/datasets_download.py index 1d4445d6f6..65712ee22c 100755 --- a/src_python/habitat_sim/utils/datasets_download.py +++ b/src_python/habitat_sim/utils/datasets_download.py @@ -594,7 +594,13 @@ def clone_repo_source( # prune the repo to reduce wasted memory consumption prune_command = "git lfs prune -f --recent" - subprocess.check_call(shlex.split(prune_command), cwd=version_dir) + try: + subprocess.check_call(shlex.split(prune_command), cwd=version_dir) + except subprocess.CalledProcessError as e: + # a response of status code 127 suggests a git-lfs version that does not support the -f flag + if "status 127" in e: + prune_command = "git lfs prune --recent" + subprocess.check_call(shlex.split(prune_command), cwd=version_dir) def checkout_repo_tag(repo: Repo, version_dir: str, tag: str): From 8760f3ff7d20cee87e2de62a0f3b267f66078b4f Mon Sep 17 00:00:00 2001 From: Jack Kolb Date: Sun, 28 Apr 2024 15:11:10 -0400 Subject: [PATCH 2/4] Split a comment onto two lines for black --- src_python/habitat_sim/utils/datasets_download.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src_python/habitat_sim/utils/datasets_download.py b/src_python/habitat_sim/utils/datasets_download.py index 65712ee22c..db7061c7ca 100755 --- a/src_python/habitat_sim/utils/datasets_download.py +++ b/src_python/habitat_sim/utils/datasets_download.py @@ -597,10 +597,10 @@ def clone_repo_source( try: subprocess.check_call(shlex.split(prune_command), cwd=version_dir) except subprocess.CalledProcessError as e: - # a response of status code 127 suggests a git-lfs version that does not support the -f flag + # a response of status code 127 suggests a git-lfs version + # that does not support the -f flag if "status 127" in e: - prune_command = "git lfs prune --recent" - subprocess.check_call(shlex.split(prune_command), cwd=version_dir) + subprocess.check_call(shlex.split("git lfs prune --recent"), cwd=version_dir) def checkout_repo_tag(repo: Repo, version_dir: str, tag: str): From c729e72c19e7626dcfe14e548ae712eb63d2996b Mon Sep 17 00:00:00 2001 From: Jack Kolb Date: Sun, 28 Apr 2024 15:14:44 -0400 Subject: [PATCH 3/4] Fixed for eslint --- src_python/habitat_sim/utils/datasets_download.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src_python/habitat_sim/utils/datasets_download.py b/src_python/habitat_sim/utils/datasets_download.py index db7061c7ca..b92308317d 100755 --- a/src_python/habitat_sim/utils/datasets_download.py +++ b/src_python/habitat_sim/utils/datasets_download.py @@ -598,9 +598,11 @@ def clone_repo_source( subprocess.check_call(shlex.split(prune_command), cwd=version_dir) except subprocess.CalledProcessError as e: # a response of status code 127 suggests a git-lfs version - # that does not support the -f flag + # that does not support the -f flag if "status 127" in e: - subprocess.check_call(shlex.split("git lfs prune --recent"), cwd=version_dir) + subprocess.check_call( + shlex.split("git lfs prune --recent"), cwd=version_dir + ) def checkout_repo_tag(repo: Repo, version_dir: str, tag: str): From 875ee0bcb5b53b12a62ec33ea201e047c1ea2e0f Mon Sep 17 00:00:00 2001 From: Jack Kolb Date: Sun, 28 Apr 2024 15:26:32 -0400 Subject: [PATCH 4/4] Wrapped exception string in str() for better python version compatability --- src_python/habitat_sim/utils/datasets_download.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src_python/habitat_sim/utils/datasets_download.py b/src_python/habitat_sim/utils/datasets_download.py index b92308317d..d2096abc46 100755 --- a/src_python/habitat_sim/utils/datasets_download.py +++ b/src_python/habitat_sim/utils/datasets_download.py @@ -599,7 +599,7 @@ def clone_repo_source( except subprocess.CalledProcessError as e: # a response of status code 127 suggests a git-lfs version # that does not support the -f flag - if "status 127" in e: + if "status 127" in str(e): subprocess.check_call( shlex.split("git lfs prune --recent"), cwd=version_dir )