Skip to content

Commit 99bfb3a

Browse files
committed
handle cache setup failure
1 parent 6f1a50d commit 99bfb3a

File tree

2 files changed

+39
-18
lines changed

2 files changed

+39
-18
lines changed

api/management/commands/setup_dvc.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,25 @@ def handle(self, *args: Any, **options: Any) -> None:
3131
self.stdout.write("Initialized DVC repository")
3232

3333
# Configure chunking for large files
34-
subprocess.run(
35-
["dvc", "config", "cache.type", "hardlink,symlink"],
36-
cwd=repo_path,
37-
check=True,
38-
)
39-
subprocess.run(
40-
["dvc", "config", "cache.shared", "group"],
41-
cwd=repo_path,
42-
check=True,
43-
)
34+
try:
35+
subprocess.run(
36+
["dvc", "config", "cache.type", "hardlink,symlink"],
37+
cwd=repo_path,
38+
check=True,
39+
)
40+
self.stdout.write("Configured DVC cache type")
41+
except subprocess.CalledProcessError as e:
42+
logger.warning(f"Failed to configure cache type: {str(e)}")
4443

45-
# Configure cache size limits to prevent excessive disk usage
46-
subprocess.run(
47-
["dvc", "config", "cache.size_limit", "10G"],
48-
cwd=repo_path,
49-
check=True,
50-
)
44+
try:
45+
subprocess.run(
46+
["dvc", "config", "cache.shared", "group"],
47+
cwd=repo_path,
48+
check=True,
49+
)
50+
self.stdout.write("Configured DVC cache sharing")
51+
except subprocess.CalledProcessError as e:
52+
logger.warning(f"Failed to configure cache sharing: {str(e)}")
5153

5254
self.stdout.write("Configured DVC for large file handling")
5355

api/managers/dvc_manager.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,30 @@ def show_metrics(self) -> str:
109109
result = self._run_command(["dvc", "metrics", "show"])
110110
return str(result.stdout.strip())
111111

112-
def gc_cache(self, force: bool = False) -> None:
113-
"""Clean up unused cache to save disk space"""
112+
def gc_cache(
113+
self, force: bool = False, cloud: bool = False, workspace: bool = True
114+
) -> None:
115+
"""Clean up unused cache to save disk space
116+
117+
Args:
118+
force: Force garbage collection without prompting
119+
cloud: Also collect garbage in remote storage
120+
workspace: Keep files used in current workspace
121+
"""
114122
cmd = ["dvc", "gc"]
123+
124+
# Keep files used in current workspace (default behavior)
125+
if workspace:
126+
cmd.append("-w")
127+
128+
# Also collect garbage in remote storage
129+
if cloud:
130+
cmd.append("-c")
131+
132+
# Force garbage collection without prompting
115133
if force:
116134
cmd.append("-f")
135+
117136
self._run_command(cmd)
118137

119138
def configure(self, section: str, option: str, value: str) -> None:

0 commit comments

Comments
 (0)