Skip to content

Commit 9f4e06b

Browse files
optimise as per review
Signed-off-by: Avinash Singh <[email protected]>
1 parent c16eb36 commit 9f4e06b

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

contrib/scripts/select-top-models.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
]
3636

3737
# Model families known to work well with modctl
38-
KNOWN_FAMILIES = [
38+
KNOWN_FAMILIES = {
3939
"llama",
4040
"qwen",
4141
"qwen2",
@@ -50,7 +50,7 @@
5050
"falcon",
5151
"mpt",
5252
"stablelm",
53-
]
53+
}
5454

5555

5656
def get_model_size_gb(model_info) -> Optional[float]:
@@ -62,19 +62,20 @@ def get_model_size_gb(model_info) -> Optional[float]:
6262
if hasattr(file, 'size') and file.size:
6363
total_size += file.size
6464
return total_size / (1024 ** 3) # Convert to GB
65-
except Exception:
65+
except Exception as e:
66+
print(f"Error: An error occurred in get_model_size_gb: {e}", file=sys.stderr)
6667
return None
6768

6869

6970
def has_config_json(model_info) -> bool:
7071
"""Check if model has config.json for auto-detection."""
7172
try:
7273
if hasattr(model_info, 'siblings') and model_info.siblings:
73-
filenames = [f.rfilename for f in model_info.siblings]
74-
return "config.json" in filenames
75-
return False
76-
except Exception:
74+
return any(f.rfilename == "config.json" for f in model_info.siblings)
7775
return False
76+
except Exception as e:
77+
print(f"Error: An error occurred in has_config_json: {e}", file=sys.stderr)
78+
return None
7879

7980

8081
def get_model_format(model_info) -> Optional[str]:
@@ -98,7 +99,8 @@ def get_model_format(model_info) -> Optional[str]:
9899
return "pt"
99100

100101
return None
101-
except Exception:
102+
except Exception as e:
103+
print(f"Error: An error occurred in get_model_format: {e}", file=sys.stderr)
102104
return None
103105

104106

@@ -144,7 +146,8 @@ def detect_family(model_info, model_id: str) -> Optional[str]:
144146
return family
145147

146148
return None
147-
except Exception:
149+
except Exception as e:
150+
print(f"Error: An error occurred in detect_family: {e}", file=sys.stderr)
148151
return None
149152

150153

@@ -319,7 +322,7 @@ def main():
319322
return 0
320323

321324
except Exception as e:
322-
print(f"Error: {e}", file=sys.stderr)
325+
print(f"Error: An error occurred in main: {e}", file=sys.stderr)
323326
import traceback
324327
traceback.print_exc(file=sys.stderr)
325328
return 1

contrib/scripts/top-model-selection.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ python contrib/scripts/select-top-models.py \
5353
Get top 5 small models (< 5GB):
5454

5555
```bash
56-
python contrib/scriptsselect-top-models.py --limit 5 --max-size 5
56+
python contrib/scripts/select-top-models.py --limit 5 --max-size 5
5757
```
5858

5959
Get most liked models:

0 commit comments

Comments
 (0)