nroggendorff commited on
Commit
a04f2e1
·
verified ·
1 Parent(s): 5ec318d

Update train.py

Browse files
Files changed (1) hide show
  1. train.py +8 -2
train.py CHANGED
@@ -39,6 +39,11 @@ class Space:
39
 
40
  space = Space()
41
 
 
 
 
 
 
42
  def load_data():
43
  if not INSTRUCT_FINETUNE_BOOL:
44
  dataset = load_dataset(INPUT_DATASET, "cosmopedia-v2", split="train", streaming=True)
@@ -245,10 +250,11 @@ def main(push_to_hub=True, is_inst_finetune=False):
245
 
246
  print("Training Model..")
247
  train_model(model, tokenizer, dataset, push_to_hub, is_inst_finetune)
248
- raise Exception
249
 
250
  if __name__ == "__main__":
251
  try:
252
  main(PUSH_TO_HUB, INSTRUCT_FINETUNE_BOOL)
253
- except:
 
254
  space.pause()
 
39
 
40
  space = Space()
41
 
42
+ class FineError(Exception):
43
+ def __init__(self, message="Script execution has completed."):
44
+ self.message = message
45
+ super().__init__(self.message)
46
+
47
  def load_data():
48
  if not INSTRUCT_FINETUNE_BOOL:
49
  dataset = load_dataset(INPUT_DATASET, "cosmopedia-v2", split="train", streaming=True)
 
250
 
251
  print("Training Model..")
252
  train_model(model, tokenizer, dataset, push_to_hub, is_inst_finetune)
253
+ raise FineError("All tasks have been completed.")
254
 
255
  if __name__ == "__main__":
256
  try:
257
  main(PUSH_TO_HUB, INSTRUCT_FINETUNE_BOOL)
258
+ except Exception as e:
259
+ print(f'{e.__name__}: {e}')
260
  space.pause()