-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Block Name In Errors #155
Block Name In Errors #155
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one suggestion to localize the try/except handling to only the parts calling block-specific code.
Also, do you have an example of what an error looked like before and after the change?
src/instructlab/sdg/pipeline.py
Outdated
block = block_type(self.ctx, self, block_name, **block_config) | ||
|
||
logger.info("Running block: %s", block_name) | ||
logger.info(dataset) | ||
|
||
dataset = block.generate(dataset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like these lines capture the block-specific code, so you could localize your addition to this part, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Do you think it's worth containing the config parsing as well? It seems like the use of direct indexing (vs .get
) for "name"
, "type"
, and "config"
implies that these are all required fields, but I don't see anywhere that they're validated (though that might happen elsewhere that I haven't found yet?). If it's not done elsewhere, it may be worth doing that validation in the __init__
to avoid getting part-way through the expensive pipeline operation before discovering configuration errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we now have some config validation, at least for the configs we have in the tree. See make validate-pipelines
. It uses a jsonschema definition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, cool, makes sense!
…/type wrapping instructlab#128 Signed-off-by: Gabe Goodhart <[email protected]>
instructlab#128 Signed-off-by: Gabe Goodhart <[email protected]>
46f3e0d
to
10955fe
Compare
Thanks for the suggestion! I've localized the error handling to just the
I don't have a concrete example of before/after, but this uses raise ... from ... syntax. The parent exception will attempt to match the exception type of the one raised in the block with a message |
Here's what an exception from
This isn't actually so problematic since we log which block is being executed, so the user has some context to use in order to debug the error The example I gave in #128 is failing to load a config file when instantiating a block - an error with the pipeline definition, but also one that can't be detected by the schema |
…ption instructlab#128 Signed-off-by: Gabe Goodhart <[email protected]>
src/instructlab/sdg/pipeline.py
Outdated
""" | ||
|
||
def __init__(self, block: Block, exception: Exception): | ||
self.block = block |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: underscore prefix this if you want just .block_name
and .block_type
to be used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left that one "public" thinking that some might like to be able to actually muck with the block itself when handling the exception.
…ration instructlab#128 Signed-off-by: Gabe Goodhart <[email protected]>
instructlab#128 Signed-off-by: Gabe Goodhart <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @gabe-l-hart !
Description
This PR adds
try/except
handling around the core loop inPipeline
. In the handler clause, it creates a wrapper exception, attempting to match the type of the internal error, with theblock_name
andblock_type
included.Closes: #128