Dig Through More Errors
00:00
So my suggestion here would be that we focus on the load_model()
function and therefore, at least for now, remove the try
… except
from the main()
and just have the load_model()
call in line 22 and remove the rest for now. Yeah, because the question is about exceptions and how to see, like, exceptions bubble up in the stack trace basically, that if an exception occurs in a called function, that it would also show up in the stack trace, like, inside of the calling function is kind of like what this person is asking about. So we don’t really want to catch the exception here. Right.
00:36
And like Philipp suggested, so let’s just get rid of this try
and except
for now. Exactly. I move this in. And then this predictions, this variable, we don’t have it, it doesn’t add anything here, so I’m just going to remove it for now. Yeah.
00:52 Now we also have another problem here, Pylance is showing, and I can try to run this again. We’re running into an error that doesn’t really help us much. Yeah.
01:04
But you see, like, this is a leftover of the try
… except
block and catching the exception, so there’s nothing that this helps us with at the moment.
01:12
I’m just going to replace it with little print()
statement so that we know when everything runs and then ends up being done. Yeah, but the TypeError
that you’re receiving is that currently in line 22 we try to define tokenizer
and model
as a return from load_model()
, but load_model()
doesn’t return two things. Right?
01:35
So we might just have a load_model()
call there and not assign it to a tokenizer and a model just yet.
01:43
If we want to unpack this error message here, we’ve got the keyword here that tells us that it’s trying to unpack something, which is happening here on line 22, where it’s expecting a returned iterable, like a tool for example, but it’s really just getting a dictionary in these return
statements here.
02:00
Like, we have two return
statements in load_model()
, and both of them return a dictionary. So this unpacking is not going to work and like Philipp suggests, good idea—I’m just going to remove that for now and just keep it as a, just as a call, because we’re looking at the exceptions in here, so we don’t really need to do anything with the return
value that anyways doesn’t work.
Become a Member to join the conversation.