Skip to content

Instantly share code, notes, and snippets.

@kurianbenoy
Created Apr 6, 2022
Embed
What would you like to do?
supported = ['a', 'b',..]
def load_model(source, target):
try:
if source == target:
raise AssertionError("source and target shouldn't be same")
if( source in supported) and (target in supported):
.....
if source == "ta":
raise ValueError("Not supported pair")
except AssertionError as e:
return {"inputerror": "Please enter required fields"}
except ValueError as e:
return {"error": e}
//Assume this as flask API endpoint
def predict_raw(X):
try:
tokenizer, model = load_model(X['s'], X['t'])
.....
return preds
except Exception as e:
return {"error": e}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment