Closed saharNooby closed 7 months ago
Hi @saharNooby!
I'm a first-time contributor and I'm interested to work on this. If I understand correctly, you want it to be fixed like this, right?
From
assert init_prompt != '', 'Prompt must not be empty'
To
if init_prompt != '':
raise AssertionError('Prompt must not be empty')
If so, I think I'd be able to help. 👍
@whitealpa It's good! But if possible, I'd like to suggest that we use error types other than AssertionError
here. The Python documents (here) suggests:
exception AssertionError Raised when an assert statement fails.
Since we do not assert
here, other error types would better fit the code context. Maybe ValueError
s would be better?
It's nice to see we have more contributors for help!
@chenpan321 Oh, my.. You’re absolutely right! I’ve read your PR but still missed it. 😅 Thank you for pointing that out. I’ll make a PR soon.
@whitealpa Note that the expression must be inverted. You've suggested:
if init_prompt != '':
raise AssertionError('Prompt must not be empty')
...but it will actually throw the exception when the prompt is not empty, which is not what we've intended. The correct option would be either of those:
if not (init_prompt != ''):
raise AssertionError('Prompt must not be empty')
# ...or in simplified form:
if init_prompt == '':
raise AssertionError('Prompt must not be empty')
As for exception type, I think ValueError
is fine indeed.
@saharNooby @chenpan321 I've finished the edit but have a problem with DCO. I'll try open a pull request again.
Please check: https://github.com/RWKV/rwkv.cpp/pull/167
Thanks to @chenpan321, I've become aware that Python is allowed to ignore assertions if
-O
flag is used.I've always meant the assertions to be always-run checks; they test important preconditions and are meant to make user's life better by providing clear messages specifying the exact problem.
So, we need to replace all
assert
s withif
s.See this PR for an example of a replacement.