antiquality commited on
Commit
ec110e2
1 Parent(s): 46dc612

Optimizing the exception logic

Browse files
Files changed (1) hide show
  1. src/submission/check_validity.py +6 -4
src/submission/check_validity.py CHANGED
@@ -43,12 +43,14 @@ def is_model_on_hub(model_name: str, revision: str, token: str = None, trust_rem
43
  else:
44
  tokenizer_class_candidate = config.tokenizer_class
45
 
46
-
47
- tokenizer_class = tokenizer_class_from_name(tokenizer_class_candidate)
 
 
48
  if tokenizer_class is None:
49
  return (
50
  False,
51
- f"uses {tokenizer_class_candidate}, which is not in a transformers release, therefore not supported at the moment.",
52
  None
53
  )
54
  return True, None, config
@@ -61,7 +63,7 @@ def is_model_on_hub(model_name: str, revision: str, token: str = None, trust_rem
61
  )
62
 
63
  except Exception as e:
64
- return False, f" error: {e}", None
65
 
66
 
67
  def get_model_size(model_info: ModelInfo, precision: str):
 
43
  else:
44
  tokenizer_class_candidate = config.tokenizer_class
45
 
46
+ if tokenizer_class_candidate:
47
+ tokenizer_class = tokenizer_class_from_name(tokenizer_class_candidate)
48
+ else:
49
+ tokenizer_class = None
50
  if tokenizer_class is None:
51
  return (
52
  False,
53
+ f"uses '{tokenizer_class_candidate}' tokenizer class, which is not supported at the moment.",
54
  None
55
  )
56
  return True, None, config
 
63
  )
64
 
65
  except Exception as e:
66
+ return False, f" is not found on the hub (error: {e})", None
67
 
68
 
69
  def get_model_size(model_info: ModelInfo, precision: str):