computefence 0.2.19__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {computefence-0.2.19 → computefence-0.3.0}/PKG-INFO +1 -1
- computefence-0.3.0/computefence/__init__.py +1 -0
- {computefence-0.2.19 → computefence-0.3.0}/computefence/checks/dataset.py +15 -9
- {computefence-0.2.19 → computefence-0.3.0}/computefence/checks/environment.py +15 -28
- {computefence-0.2.19 → computefence-0.3.0}/computefence/checks/storage.py +19 -31
- {computefence-0.2.19 → computefence-0.3.0}/computefence/cli.py +42 -8
- {computefence-0.2.19 → computefence-0.3.0}/computefence/telemetry.py +5 -5
- {computefence-0.2.19 → computefence-0.3.0}/computefence.egg-info/PKG-INFO +1 -1
- computefence-0.2.19/computefence/__init__.py +0 -1
- {computefence-0.2.19 → computefence-0.3.0}/LICENSE +0 -0
- {computefence-0.2.19 → computefence-0.3.0}/README.md +0 -0
- {computefence-0.2.19 → computefence-0.3.0}/computefence/checks/__init__.py +0 -0
- {computefence-0.2.19 → computefence-0.3.0}/computefence/drift.py +0 -0
- {computefence-0.2.19 → computefence-0.3.0}/computefence.egg-info/SOURCES.txt +0 -0
- {computefence-0.2.19 → computefence-0.3.0}/computefence.egg-info/dependency_links.txt +0 -0
- {computefence-0.2.19 → computefence-0.3.0}/computefence.egg-info/entry_points.txt +0 -0
- {computefence-0.2.19 → computefence-0.3.0}/computefence.egg-info/requires.txt +0 -0
- {computefence-0.2.19 → computefence-0.3.0}/computefence.egg-info/top_level.txt +0 -0
- {computefence-0.2.19 → computefence-0.3.0}/pyproject.toml +0 -0
- {computefence-0.2.19 → computefence-0.3.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: computefence
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Don't lose another RunPod checkpoint to ephemeral disk before your job bills.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Keywords: runpod,vast.ai,gpu training,hf_home,cuda,preflight,machine learning,mlops,checkpoint
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.0"
|
|
@@ -7,32 +7,32 @@ def check_dataset(dataset_path=None, input_column=None, label_column=None):
|
|
|
7
7
|
|
|
8
8
|
if dataset_path is None:
|
|
9
9
|
results.append({
|
|
10
|
+
"id": "dataset_provided",
|
|
10
11
|
"status": "warn",
|
|
11
12
|
"message": "No dataset path provided — skipping dataset checks",
|
|
12
13
|
"fix": "Run with --dataset path/to/your/dataset.csv to enable dataset checks"
|
|
13
14
|
})
|
|
14
15
|
return results
|
|
15
16
|
|
|
16
|
-
# Check file exists
|
|
17
17
|
path = Path(dataset_path)
|
|
18
18
|
if not path.exists():
|
|
19
19
|
results.append({
|
|
20
|
+
"id": "dataset_exists",
|
|
20
21
|
"status": "fail",
|
|
21
22
|
"message": f"Dataset file not found: {dataset_path}",
|
|
22
23
|
"fix": "Check the path and try again"
|
|
23
24
|
})
|
|
24
25
|
return results
|
|
25
26
|
|
|
26
|
-
# Check file extension
|
|
27
27
|
if path.suffix not in [".csv", ".parquet", ".json"]:
|
|
28
28
|
results.append({
|
|
29
|
+
"id": "dataset_format",
|
|
29
30
|
"status": "warn",
|
|
30
31
|
"message": f"Unrecognised file type: {path.suffix}. Expected .csv, .parquet, or .json",
|
|
31
32
|
"fix": "Convert your dataset to CSV or Parquet format"
|
|
32
33
|
})
|
|
33
34
|
return results
|
|
34
35
|
|
|
35
|
-
# Load the dataset
|
|
36
36
|
try:
|
|
37
37
|
import pandas as pd
|
|
38
38
|
|
|
@@ -45,91 +45,97 @@ def check_dataset(dataset_path=None, input_column=None, label_column=None):
|
|
|
45
45
|
|
|
46
46
|
except Exception as e:
|
|
47
47
|
results.append({
|
|
48
|
+
"id": "dataset_load",
|
|
48
49
|
"status": "fail",
|
|
49
50
|
"message": f"Could not load dataset: {e}",
|
|
50
51
|
"fix": "Check the file is not corrupted and is a valid CSV, Parquet, or JSON file"
|
|
51
52
|
})
|
|
52
53
|
return results
|
|
53
54
|
|
|
54
|
-
# Row count
|
|
55
55
|
row_count = len(df)
|
|
56
56
|
results.append({
|
|
57
|
+
"id": "dataset_loaded",
|
|
57
58
|
"status": "pass",
|
|
58
59
|
"message": f"Dataset loaded — {row_count:,} rows, {len(df.columns)} columns"
|
|
59
60
|
})
|
|
60
61
|
|
|
61
|
-
# Check for missing values
|
|
62
62
|
missing = df.isnull().sum().sum()
|
|
63
63
|
if missing > 0:
|
|
64
64
|
results.append({
|
|
65
|
+
"id": "dataset_missing_values",
|
|
65
66
|
"status": "warn",
|
|
66
67
|
"message": f"{missing:,} missing values detected across dataset",
|
|
67
68
|
"fix": "Review and handle missing values before training"
|
|
68
69
|
})
|
|
69
70
|
else:
|
|
70
71
|
results.append({
|
|
72
|
+
"id": "dataset_missing_values",
|
|
71
73
|
"status": "pass",
|
|
72
74
|
"message": "No missing values detected"
|
|
73
75
|
})
|
|
74
76
|
|
|
75
|
-
# Check for duplicate rows
|
|
76
77
|
duplicate_count = df.duplicated().sum()
|
|
77
78
|
if duplicate_count > 0:
|
|
78
79
|
pct = (duplicate_count / row_count) * 100
|
|
79
80
|
results.append({
|
|
81
|
+
"id": "dataset_duplicates",
|
|
80
82
|
"status": "warn",
|
|
81
83
|
"message": f"{duplicate_count:,} duplicate rows detected ({pct:.1f}% of dataset)",
|
|
82
84
|
"fix": "Remove duplicates with df.drop_duplicates() before training"
|
|
83
85
|
})
|
|
84
86
|
else:
|
|
85
87
|
results.append({
|
|
88
|
+
"id": "dataset_duplicates",
|
|
86
89
|
"status": "pass",
|
|
87
90
|
"message": "No duplicate rows detected"
|
|
88
91
|
})
|
|
89
92
|
|
|
90
|
-
# Optional classification checks
|
|
91
93
|
if input_column and label_column:
|
|
92
94
|
if input_column not in df.columns:
|
|
93
95
|
results.append({
|
|
96
|
+
"id": "dataset_input_column",
|
|
94
97
|
"status": "fail",
|
|
95
98
|
"message": f"Input column '{input_column}' not found in dataset",
|
|
96
99
|
"fix": f"Available columns: {', '.join(df.columns.tolist())}"
|
|
97
100
|
})
|
|
98
101
|
elif label_column not in df.columns:
|
|
99
102
|
results.append({
|
|
103
|
+
"id": "dataset_label_column",
|
|
100
104
|
"status": "fail",
|
|
101
105
|
"message": f"Label column '{label_column}' not found in dataset",
|
|
102
106
|
"fix": f"Available columns: {', '.join(df.columns.tolist())}"
|
|
103
107
|
})
|
|
104
108
|
else:
|
|
105
|
-
# Check for conflicting labels
|
|
106
109
|
conflicts = df.groupby(input_column)[label_column].nunique()
|
|
107
110
|
conflicting = conflicts[conflicts > 1].count()
|
|
108
111
|
if conflicting > 0:
|
|
109
112
|
results.append({
|
|
113
|
+
"id": "dataset_label_conflicts",
|
|
110
114
|
"status": "warn",
|
|
111
115
|
"message": f"{conflicting:,} inputs have conflicting labels",
|
|
112
116
|
"fix": "Review and resolve label conflicts before training"
|
|
113
117
|
})
|
|
114
118
|
else:
|
|
115
119
|
results.append({
|
|
120
|
+
"id": "dataset_label_conflicts",
|
|
116
121
|
"status": "pass",
|
|
117
122
|
"message": "No conflicting labels detected"
|
|
118
123
|
})
|
|
119
124
|
|
|
120
|
-
# Class distribution
|
|
121
125
|
class_counts = df[label_column].value_counts()
|
|
122
126
|
min_class = class_counts.min()
|
|
123
127
|
max_class = class_counts.max()
|
|
124
128
|
imbalance_ratio = max_class / min_class if min_class > 0 else float("inf")
|
|
125
129
|
if imbalance_ratio > 10:
|
|
126
130
|
results.append({
|
|
131
|
+
"id": "dataset_class_balance",
|
|
127
132
|
"status": "warn",
|
|
128
133
|
"message": f"Class imbalance detected — ratio {imbalance_ratio:.1f}:1 between largest and smallest class",
|
|
129
134
|
"fix": "Consider resampling or using class weights during training"
|
|
130
135
|
})
|
|
131
136
|
else:
|
|
132
137
|
results.append({
|
|
138
|
+
"id": "dataset_class_balance",
|
|
133
139
|
"status": "pass",
|
|
134
140
|
"message": f"Class distribution looks reasonable — ratio {imbalance_ratio:.1f}:1"
|
|
135
141
|
})
|
|
@@ -5,12 +5,6 @@ from pathlib import Path
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
def describe_interpreter():
|
|
8
|
-
"""Report the interpreter that is executing computefence right now.
|
|
9
|
-
|
|
10
|
-
Every package check in this module imports in-process, so this path is
|
|
11
|
-
exactly the environment those checks see. Surfacing it makes an
|
|
12
|
-
install-location mismatch obvious instead of silent.
|
|
13
|
-
"""
|
|
14
8
|
return {
|
|
15
9
|
"version": platform.python_version(),
|
|
16
10
|
"executable": sys.executable,
|
|
@@ -20,12 +14,6 @@ def describe_interpreter():
|
|
|
20
14
|
|
|
21
15
|
|
|
22
16
|
def in_active_virtualenv(interpreter):
|
|
23
|
-
"""True when VIRTUAL_ENV is set but computefence is running outside it.
|
|
24
|
-
|
|
25
|
-
This is the failure that looks like a broken PyTorch check: the shell has a
|
|
26
|
-
venv activated (with torch in it) while `computefence` resolves to a script
|
|
27
|
-
installed against a different interpreter, which cannot see that torch.
|
|
28
|
-
"""
|
|
29
17
|
virtual_env = interpreter["virtual_env"]
|
|
30
18
|
if not virtual_env:
|
|
31
19
|
return None
|
|
@@ -36,12 +24,6 @@ def in_active_virtualenv(interpreter):
|
|
|
36
24
|
|
|
37
25
|
|
|
38
26
|
def detect_torch():
|
|
39
|
-
"""Detect PyTorch with a direct, in-process import.
|
|
40
|
-
|
|
41
|
-
The import runs inside the interpreter executing computefence, so it sees
|
|
42
|
-
precisely what the active environment provides. No subprocess, no
|
|
43
|
-
os.system, no hardcoded python path.
|
|
44
|
-
"""
|
|
45
27
|
result = {
|
|
46
28
|
"available": False,
|
|
47
29
|
"version": None,
|
|
@@ -58,9 +40,6 @@ def detect_torch():
|
|
|
58
40
|
except ImportError:
|
|
59
41
|
return result
|
|
60
42
|
except Exception as exc:
|
|
61
|
-
# torch is installed but unusable — a CUDA/driver mismatch or a broken
|
|
62
|
-
# build raises OSError or RuntimeError here, not ImportError. Reporting
|
|
63
|
-
# it beats crashing the whole doctor run with a traceback.
|
|
64
43
|
result["error"] = exc
|
|
65
44
|
return result
|
|
66
45
|
|
|
@@ -92,13 +71,14 @@ def check_environment():
|
|
|
92
71
|
torch_info = detect_torch()
|
|
93
72
|
|
|
94
73
|
results.append({
|
|
74
|
+
"id": "python_version",
|
|
95
75
|
"status": "pass",
|
|
96
76
|
"message": f"Python {interpreter['version']} ({interpreter['executable']})"
|
|
97
77
|
})
|
|
98
78
|
|
|
99
|
-
# Warn when the shell has a venv active that computefence is not running in.
|
|
100
79
|
if in_active_virtualenv(interpreter) is False:
|
|
101
80
|
results.append({
|
|
81
|
+
"id": "virtualenv_mismatch",
|
|
102
82
|
"status": "warn",
|
|
103
83
|
"message": (
|
|
104
84
|
f"computefence is not running inside the active virtual environment "
|
|
@@ -111,12 +91,14 @@ def check_environment():
|
|
|
111
91
|
if not torch_info["available"]:
|
|
112
92
|
if torch_info["error"] is not None:
|
|
113
93
|
results.append({
|
|
94
|
+
"id": "torch_import",
|
|
114
95
|
"status": "fail",
|
|
115
96
|
"message": f"PyTorch is installed but failed to import: {torch_info['error']}",
|
|
116
97
|
"fix": "Check your PyTorch build matches the installed CUDA driver"
|
|
117
98
|
})
|
|
118
99
|
else:
|
|
119
100
|
results.append({
|
|
101
|
+
"id": "torch_missing",
|
|
120
102
|
"status": "warn",
|
|
121
103
|
"message": f"PyTorch not found in {interpreter['executable']} — skipping GPU checks",
|
|
122
104
|
"fix": "pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118"
|
|
@@ -125,6 +107,7 @@ def check_environment():
|
|
|
125
107
|
|
|
126
108
|
if torch_info["cuda_available"]:
|
|
127
109
|
results.append({
|
|
110
|
+
"id": "torch_cuda",
|
|
128
111
|
"status": "pass",
|
|
129
112
|
"message": (
|
|
130
113
|
f"PyTorch {torch_info['version']} detected "
|
|
@@ -133,12 +116,14 @@ def check_environment():
|
|
|
133
116
|
})
|
|
134
117
|
else:
|
|
135
118
|
results.append({
|
|
119
|
+
"id": "torch_cuda",
|
|
136
120
|
"status": "pass",
|
|
137
121
|
"message": f"PyTorch {torch_info['version']} detected"
|
|
138
122
|
})
|
|
139
123
|
|
|
140
124
|
if torch_info["error"] is not None:
|
|
141
125
|
results.append({
|
|
126
|
+
"id": "cuda_query",
|
|
142
127
|
"status": "fail",
|
|
143
128
|
"message": f"Could not query CUDA: {torch_info['error']}",
|
|
144
129
|
"fix": "Check your CUDA installation and PyTorch version match"
|
|
@@ -147,6 +132,7 @@ def check_environment():
|
|
|
147
132
|
|
|
148
133
|
if not torch_info["cuda_available"]:
|
|
149
134
|
results.append({
|
|
135
|
+
"id": "cuda_visibility",
|
|
150
136
|
"status": "fail",
|
|
151
137
|
"message": "CUDA not available — PyTorch cannot see any GPUs",
|
|
152
138
|
"fix": "Check your CUDA installation and PyTorch version match"
|
|
@@ -166,17 +152,13 @@ def check_accelerate(config_path=None, torch_info=None):
|
|
|
166
152
|
if not torch_info["available"]:
|
|
167
153
|
return results
|
|
168
154
|
|
|
169
|
-
# Find the Accelerate config
|
|
170
155
|
if config_path:
|
|
171
156
|
config_file = Path(config_path)
|
|
172
157
|
else:
|
|
173
|
-
# Try common default locations
|
|
174
158
|
candidates = [
|
|
175
159
|
Path.home() / ".cache" / "huggingface" / "accelerate" / "default_config.yaml",
|
|
176
160
|
Path.home() / ".config" / "huggingface" / "accelerate" / "default_config.yaml",
|
|
177
161
|
]
|
|
178
|
-
|
|
179
|
-
# Also check HF_HOME based path
|
|
180
162
|
hf_home = os.environ.get("HF_HOME")
|
|
181
163
|
if hf_home:
|
|
182
164
|
candidates.insert(0, Path(hf_home) / "accelerate" / "default_config.yaml")
|
|
@@ -189,13 +171,13 @@ def check_accelerate(config_path=None, torch_info=None):
|
|
|
189
171
|
|
|
190
172
|
if config_file is None or not Path(config_file).exists():
|
|
191
173
|
results.append({
|
|
174
|
+
"id": "accelerate_config",
|
|
192
175
|
"status": "warn",
|
|
193
176
|
"message": "No Accelerate config found — skipping GPU count check",
|
|
194
177
|
"fix": "Run 'accelerate config' to create a configuration file"
|
|
195
178
|
})
|
|
196
179
|
return results
|
|
197
180
|
|
|
198
|
-
# Parse the config
|
|
199
181
|
try:
|
|
200
182
|
import yaml
|
|
201
183
|
with open(config_file) as f:
|
|
@@ -205,6 +187,7 @@ def check_accelerate(config_path=None, torch_info=None):
|
|
|
205
187
|
|
|
206
188
|
if num_processes is None:
|
|
207
189
|
results.append({
|
|
190
|
+
"id": "accelerate_num_processes",
|
|
208
191
|
"status": "warn",
|
|
209
192
|
"message": "Could not read num_processes from Accelerate config",
|
|
210
193
|
"fix": "Check your Accelerate config file is valid"
|
|
@@ -215,27 +198,31 @@ def check_accelerate(config_path=None, torch_info=None):
|
|
|
215
198
|
|
|
216
199
|
if num_processes > visible_gpus:
|
|
217
200
|
results.append({
|
|
201
|
+
"id": "accelerate_gpu_count",
|
|
218
202
|
"status": "fail",
|
|
219
203
|
"message": f"Accelerate config requests {num_processes} processes but only {visible_gpus} GPU(s) are visible",
|
|
220
204
|
"fix": "Run accelerate config to update your GPU count then re-run doctor"
|
|
221
205
|
})
|
|
222
206
|
else:
|
|
223
207
|
results.append({
|
|
208
|
+
"id": "accelerate_gpu_count",
|
|
224
209
|
"status": "pass",
|
|
225
210
|
"message": f"Accelerate config requests {num_processes} process(es) — {visible_gpus} GPU(s) available"
|
|
226
211
|
})
|
|
227
212
|
|
|
228
213
|
except ImportError:
|
|
229
214
|
results.append({
|
|
215
|
+
"id": "accelerate_pyyaml",
|
|
230
216
|
"status": "warn",
|
|
231
217
|
"message": "PyYAML not installed — cannot parse Accelerate config",
|
|
232
218
|
"fix": "pip install pyyaml"
|
|
233
219
|
})
|
|
234
220
|
except Exception as e:
|
|
235
221
|
results.append({
|
|
222
|
+
"id": "accelerate_parse",
|
|
236
223
|
"status": "warn",
|
|
237
224
|
"message": f"Could not parse Accelerate config: {e}",
|
|
238
225
|
"fix": "Check your Accelerate config file is valid YAML"
|
|
239
226
|
})
|
|
240
227
|
|
|
241
|
-
return results
|
|
228
|
+
return results
|
|
@@ -2,7 +2,6 @@ import os
|
|
|
2
2
|
import shutil
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
|
|
5
|
-
# Persistent volume mount points used by the common GPU rental providers.
|
|
6
5
|
MOUNT_CANDIDATES = ["/workspace", "/runpod-volume", "/vast"]
|
|
7
6
|
|
|
8
7
|
GB = 1024 ** 3
|
|
@@ -14,57 +13,58 @@ DISK_FIX = "Free up disk space or move checkpoints to a larger volume: df -h to
|
|
|
14
13
|
def check_storage():
|
|
15
14
|
results = []
|
|
16
15
|
|
|
17
|
-
# Read HuggingFace cache environment variables
|
|
18
16
|
hf_home = os.environ.get("HF_HOME")
|
|
19
|
-
hf_hub_cache = os.environ.get("HF_HUB_CACHE")
|
|
20
|
-
xdg_cache = os.environ.get("XDG_CACHE_HOME")
|
|
21
17
|
|
|
22
|
-
# Detect mounted persistent volumes
|
|
23
18
|
mounted_volumes = []
|
|
24
19
|
for path in MOUNT_CANDIDATES:
|
|
25
20
|
if Path(path).exists():
|
|
26
21
|
mounted_volumes.append(path)
|
|
27
22
|
|
|
28
|
-
# Check HF_HOME
|
|
29
23
|
if hf_home is None:
|
|
30
24
|
if mounted_volumes:
|
|
31
25
|
results.append({
|
|
26
|
+
"id": "hf_home",
|
|
32
27
|
"status": "warn",
|
|
33
28
|
"message": f"HF_HOME is not set. Mounted volume detected at {mounted_volumes[0]} but HuggingFace will cache to default local path.",
|
|
34
29
|
"fix": f"export HF_HOME={mounted_volumes[0]}/.cache/huggingface"
|
|
35
30
|
})
|
|
36
31
|
else:
|
|
37
32
|
results.append({
|
|
33
|
+
"id": "hf_home",
|
|
38
34
|
"status": "warn",
|
|
39
35
|
"message": "HF_HOME is not set. HuggingFace will use default local cache.",
|
|
40
36
|
"fix": "export HF_HOME=/workspace/.cache/huggingface"
|
|
41
37
|
})
|
|
42
38
|
elif hf_home.startswith("/root") or hf_home.startswith("/tmp"):
|
|
43
39
|
results.append({
|
|
40
|
+
"id": "hf_home",
|
|
44
41
|
"status": "warn",
|
|
45
42
|
"message": f"HF_HOME appears to point to ephemeral storage: {hf_home}",
|
|
46
|
-
"fix":
|
|
43
|
+
"fix": "export HF_HOME=/workspace/.cache/huggingface"
|
|
47
44
|
})
|
|
48
45
|
elif mounted_volumes and not any(hf_home.startswith(v) for v in mounted_volumes):
|
|
49
46
|
results.append({
|
|
47
|
+
"id": "hf_home",
|
|
50
48
|
"status": "warn",
|
|
51
49
|
"message": f"HF_HOME ({hf_home}) does not appear to be on a mounted volume.",
|
|
52
50
|
"fix": f"export HF_HOME={mounted_volumes[0]}/.cache/huggingface"
|
|
53
51
|
})
|
|
54
52
|
else:
|
|
55
53
|
results.append({
|
|
54
|
+
"id": "hf_home",
|
|
56
55
|
"status": "pass",
|
|
57
56
|
"message": f"HF_HOME is set to {hf_home}"
|
|
58
57
|
})
|
|
59
58
|
|
|
60
|
-
# Report mounted volumes found
|
|
61
59
|
if mounted_volumes:
|
|
62
60
|
results.append({
|
|
61
|
+
"id": "persistent_volume",
|
|
63
62
|
"status": "pass",
|
|
64
63
|
"message": f"Persistent volume(s) detected: {', '.join(mounted_volumes)}"
|
|
65
64
|
})
|
|
66
65
|
else:
|
|
67
66
|
results.append({
|
|
67
|
+
"id": "persistent_volume",
|
|
68
68
|
"status": "warn",
|
|
69
69
|
"message": "No mounted persistent volumes detected at /workspace, /runpod-volume, or /vast",
|
|
70
70
|
"fix": "Mount a network volume at /workspace before launching your job"
|
|
@@ -72,16 +72,10 @@ def check_storage():
|
|
|
72
72
|
|
|
73
73
|
return results
|
|
74
74
|
|
|
75
|
-
def check_disk_headroom():
|
|
76
|
-
"""Report free space on the workspace volume(s) and the root disk.
|
|
77
75
|
|
|
78
|
-
|
|
79
|
-
numbers as exact bytes, with no output parsing and no subprocess.
|
|
80
|
-
"""
|
|
76
|
+
def check_disk_headroom():
|
|
81
77
|
results = []
|
|
82
78
|
|
|
83
|
-
# Build the target list, skipping any path that shares a device with one
|
|
84
|
-
# already queued so a single filesystem is not reported twice.
|
|
85
79
|
targets = []
|
|
86
80
|
seen_devices = set()
|
|
87
81
|
for path in MOUNT_CANDIDATES + ["/"]:
|
|
@@ -99,12 +93,15 @@ def check_disk_headroom():
|
|
|
99
93
|
targets.append(candidate)
|
|
100
94
|
|
|
101
95
|
for target in targets:
|
|
102
|
-
|
|
96
|
+
is_root = str(target) == "/"
|
|
97
|
+
label = "Root disk (/)" if is_root else f"Volume {target}"
|
|
98
|
+
check_id = "disk_root" if is_root else f"disk_{str(target).strip('/').replace('/', '_')}"
|
|
103
99
|
|
|
104
100
|
try:
|
|
105
101
|
usage = shutil.disk_usage(target)
|
|
106
102
|
except OSError as e:
|
|
107
103
|
results.append({
|
|
104
|
+
"id": check_id,
|
|
108
105
|
"status": "warn",
|
|
109
106
|
"message": f"{label} — could not read disk usage: {e}",
|
|
110
107
|
"fix": DISK_FIX
|
|
@@ -117,18 +114,21 @@ def check_disk_headroom():
|
|
|
117
114
|
|
|
118
115
|
if free_gb < BLOCKER_BELOW_GB:
|
|
119
116
|
results.append({
|
|
117
|
+
"id": check_id,
|
|
120
118
|
"status": "fail",
|
|
121
119
|
"message": f"{summary} (below {BLOCKER_BELOW_GB} GB)",
|
|
122
120
|
"fix": DISK_FIX
|
|
123
121
|
})
|
|
124
122
|
elif free_gb < WARNING_BELOW_GB:
|
|
125
123
|
results.append({
|
|
124
|
+
"id": check_id,
|
|
126
125
|
"status": "warn",
|
|
127
126
|
"message": f"{summary} (below {WARNING_BELOW_GB} GB)",
|
|
128
127
|
"fix": DISK_FIX
|
|
129
128
|
})
|
|
130
129
|
else:
|
|
131
130
|
results.append({
|
|
131
|
+
"id": check_id,
|
|
132
132
|
"status": "pass",
|
|
133
133
|
"message": summary
|
|
134
134
|
})
|
|
@@ -136,32 +136,18 @@ def check_disk_headroom():
|
|
|
136
136
|
return results
|
|
137
137
|
|
|
138
138
|
|
|
139
|
-
# Paths that are wiped when a rented instance stops.
|
|
140
139
|
EPHEMERAL_PREFIXES = ["/root", "/tmp"]
|
|
141
|
-
# Paths that survive an instance restart.
|
|
142
140
|
PERSISTENT_PREFIXES = ["/workspace", "/runpod-volume", "/vast", "/home"]
|
|
143
141
|
OUTPUT_DIR_FIX = "Move your output_dir to /workspace/checkpoints or your mounted volume"
|
|
144
142
|
|
|
145
143
|
|
|
146
144
|
def _is_under(path, prefix):
|
|
147
|
-
"""True when path sits at or below prefix.
|
|
148
|
-
|
|
149
|
-
Compares path components rather than string prefixes so /workspace-old is
|
|
150
|
-
not mistaken for a child of /workspace. Avoids Path.is_relative_to, which
|
|
151
|
-
needs Python 3.9 while this package supports 3.8.
|
|
152
|
-
"""
|
|
153
145
|
path_parts = Path(path).parts
|
|
154
146
|
prefix_parts = Path(prefix).parts
|
|
155
147
|
return path_parts[: len(prefix_parts)] == prefix_parts
|
|
156
148
|
|
|
157
149
|
|
|
158
150
|
def check_output_dir(output_dir=None):
|
|
159
|
-
"""Flag a checkpoint directory that will not survive the instance stopping.
|
|
160
|
-
|
|
161
|
-
Uses abspath rather than resolve() so a path is judged as written: on macOS
|
|
162
|
-
/tmp is a symlink to /private/tmp, and resolving it first would hide the
|
|
163
|
-
very ephemeral prefix this check exists to catch.
|
|
164
|
-
"""
|
|
165
151
|
if output_dir is None:
|
|
166
152
|
return []
|
|
167
153
|
|
|
@@ -173,12 +159,14 @@ def check_output_dir(output_dir=None):
|
|
|
173
159
|
|
|
174
160
|
if is_ephemeral:
|
|
175
161
|
return [{
|
|
162
|
+
"id": "output_dir",
|
|
176
163
|
"status": "fail",
|
|
177
164
|
"message": f"Output directory {path} is on ephemeral storage and will be lost when the instance stops",
|
|
178
165
|
"fix": OUTPUT_DIR_FIX
|
|
179
166
|
}]
|
|
180
167
|
|
|
181
168
|
return [{
|
|
169
|
+
"id": "output_dir",
|
|
182
170
|
"status": "pass",
|
|
183
171
|
"message": f"Output directory {path} is on persistent storage"
|
|
184
|
-
}]
|
|
172
|
+
}]
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import sys
|
|
2
|
+
import json
|
|
2
3
|
from rich.console import Console
|
|
3
4
|
from computefence import __version__
|
|
4
5
|
from computefence.checks.environment import check_environment
|
|
@@ -32,6 +33,7 @@ def doctor():
|
|
|
32
33
|
save_env_flag = False
|
|
33
34
|
check_drift_flag = False
|
|
34
35
|
path_override = None
|
|
36
|
+
json_flag = False
|
|
35
37
|
|
|
36
38
|
args = sys.argv[1:]
|
|
37
39
|
i = 0
|
|
@@ -57,12 +59,16 @@ def doctor():
|
|
|
57
59
|
elif args[i] == "--path" and i + 1 < len(args):
|
|
58
60
|
path_override = args[i + 1]
|
|
59
61
|
i += 2
|
|
62
|
+
elif args[i] == "--json":
|
|
63
|
+
json_flag = True
|
|
64
|
+
i += 1
|
|
60
65
|
else:
|
|
61
66
|
i += 1
|
|
62
67
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
if not json_flag:
|
|
69
|
+
console.print()
|
|
70
|
+
console.print(f"[bold]ComputeFence v{__version__} — Pre-flight diagnostic[/bold]")
|
|
71
|
+
console.print("━" * 50)
|
|
66
72
|
|
|
67
73
|
env_results = check_environment()
|
|
68
74
|
storage_results = check_storage() + check_disk_headroom() + check_output_dir(output_dir)
|
|
@@ -74,10 +80,41 @@ def doctor():
|
|
|
74
80
|
|
|
75
81
|
all_results = env_results + storage_results + dataset_results
|
|
76
82
|
|
|
83
|
+
if check_drift_flag:
|
|
84
|
+
drift_results = check_drift(output_dir=output_dir, path_override=path_override)
|
|
85
|
+
all_results = all_results + drift_results
|
|
86
|
+
|
|
77
87
|
failures = [r for r in all_results if r["status"] == "fail"]
|
|
78
88
|
warnings = [r for r in all_results if r["status"] == "warn"]
|
|
79
89
|
passed = [r for r in all_results if r["status"] == "pass"]
|
|
80
90
|
|
|
91
|
+
if json_flag:
|
|
92
|
+
output = {
|
|
93
|
+
"schema_version": "1",
|
|
94
|
+
"computefence_version": __version__,
|
|
95
|
+
"summary": {
|
|
96
|
+
"passed": len(passed),
|
|
97
|
+
"warnings": len(warnings),
|
|
98
|
+
"blockers": len(failures),
|
|
99
|
+
},
|
|
100
|
+
"checks": [
|
|
101
|
+
{
|
|
102
|
+
"id": r.get("id", r.get("message", "")[:40].lower().replace(" ", "_")),
|
|
103
|
+
"status": r["status"],
|
|
104
|
+
"message": r.get("message", ""),
|
|
105
|
+
"remediation": r.get("fix", ""),
|
|
106
|
+
}
|
|
107
|
+
for r in all_results
|
|
108
|
+
],
|
|
109
|
+
}
|
|
110
|
+
print(json.dumps(output, indent=2))
|
|
111
|
+
record_run(all_results)
|
|
112
|
+
if failures:
|
|
113
|
+
sys.exit(2)
|
|
114
|
+
elif warnings:
|
|
115
|
+
sys.exit(1)
|
|
116
|
+
sys.exit(0)
|
|
117
|
+
|
|
81
118
|
console.print()
|
|
82
119
|
console.print(
|
|
83
120
|
f"[yellow]{len(warnings)} WARNINGS[/yellow] · "
|
|
@@ -98,12 +135,10 @@ def doctor():
|
|
|
98
135
|
print_result(result)
|
|
99
136
|
|
|
100
137
|
if check_drift_flag:
|
|
101
|
-
drift_results = check_drift(output_dir=output_dir, path_override=path_override)
|
|
102
138
|
console.print()
|
|
103
139
|
console.print("[bold blue]Drift[/bold blue]")
|
|
104
140
|
for result in drift_results:
|
|
105
141
|
print_result(result)
|
|
106
|
-
all_results = all_results + drift_results
|
|
107
142
|
|
|
108
143
|
console.print()
|
|
109
144
|
console.print("━" * 50)
|
|
@@ -118,9 +153,8 @@ def doctor():
|
|
|
118
153
|
console.print("[dim]Tip: add this to your launch script to run automatically every time:[/dim]")
|
|
119
154
|
console.print('[dim] alias train="computefence doctor && python train.py"[/dim]')
|
|
120
155
|
console.print(
|
|
121
|
-
"[dim]Anonymous run stats are collected
|
|
122
|
-
"
|
|
123
|
-
"To opt out: touch ~/.computefence_no_telemetry[/dim]"
|
|
156
|
+
"[dim]Anonymous run stats are not collected by default. "
|
|
157
|
+
"To opt in: touch ~/.computefence_telemetry[/dim]"
|
|
124
158
|
)
|
|
125
159
|
console.print()
|
|
126
160
|
|
|
@@ -10,10 +10,10 @@ from pathlib import Path
|
|
|
10
10
|
SUPABASE_URL = "https://pidpadpudbcdldyvrlog.supabase.co"
|
|
11
11
|
SUPABASE_ANON_KEY = "sb_publishable_A2zwbfTFiOs63jz8313GXg_elw3F5dy"
|
|
12
12
|
TABLE = "computefence_runs"
|
|
13
|
-
|
|
13
|
+
OPT_IN_FILE = Path.home() / ".computefence_telemetry"
|
|
14
14
|
|
|
15
|
-
def
|
|
16
|
-
return
|
|
15
|
+
def _is_opted_in():
|
|
16
|
+
return OPT_IN_FILE.exists()
|
|
17
17
|
|
|
18
18
|
def get_project_id() -> str:
|
|
19
19
|
# Primary: persistent home directory token — not linked to any repo
|
|
@@ -89,7 +89,7 @@ def _send(payload: dict):
|
|
|
89
89
|
pass
|
|
90
90
|
|
|
91
91
|
def record_run(results: list):
|
|
92
|
-
if
|
|
92
|
+
if not _is_opted_in():
|
|
93
93
|
return
|
|
94
94
|
if os.environ.get("COMPUTEFENCE_DEV"):
|
|
95
95
|
return
|
|
@@ -117,7 +117,7 @@ def record_run(results: list):
|
|
|
117
117
|
"warning_count": warning_count,
|
|
118
118
|
"blocker_count": blocker_count,
|
|
119
119
|
"pass_count": pass_count,
|
|
120
|
-
"
|
|
120
|
+
"opted_in": True,
|
|
121
121
|
"project_id": get_project_id(),
|
|
122
122
|
"run_id": str(uuid.uuid4()),
|
|
123
123
|
"execution_mode": get_execution_mode(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: computefence
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Don't lose another RunPod checkpoint to ephemeral disk before your job bills.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Keywords: runpod,vast.ai,gpu training,hf_home,cuda,preflight,machine learning,mlops,checkpoint
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.19"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|