3535]
3636
3737# Model families known to work well with modctl
38- KNOWN_FAMILIES = [
38+ KNOWN_FAMILIES = {
3939 "llama" ,
4040 "qwen" ,
4141 "qwen2" ,
5050 "falcon" ,
5151 "mpt" ,
5252 "stablelm" ,
53- ]
53+ }
5454
5555
5656def 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
6970def 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
8081def 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
0 commit comments