Skip to content

Document exception handling in Actions/Rules #3407

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

Merged
merged 5 commits into from
Jan 2, 2023

Conversation

michaelpj
Copy link
Collaborator

I also took the liberty of removing the MonadFail instance for Rules, since failing in Rules seems much worse as it won't automatically be caught. There was only one use of that, which now has an appropriately threatening comment.

I also took the liberty of removing the `MonadFail` instance for
`Rules`, since failing in `Rules` seems much worse as it won't
automatically be caught. There was only one use of that, which now has
an appropriately threatening comment.
Copy link
Collaborator

@fendor fendor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one comment

-- | A computation that defines all the rules that form part of the computation graph.
--
-- 'Rules' has access to 'IO' through 'MonadIO'. Use of 'IO' is at your own risk: if
-- you write 'Rules' that thow exceptions, then you need to make sure to handle them
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-- you write 'Rules' that thow exceptions, then you need to make sure to handle them
-- you write 'Rules' that throw exceptions, then you need to make sure to handle them

-- | An action representing something that can be run as part of a 'Rule'.
--
-- 'Action's can be pure functions but also have access to 'IO' via 'MonadIO' and 'MonadUnliftIO.
-- It should be assumed that actions can throw exceptions, these can be caught with
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for nitpicking, but who assumes these actions can throw exceptions? The user, or the Rules engine? Or both? E.g., are exceptions always caught or may they bubble up and eventually crash HLS?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unclear! I'm writing this for the "user of hls-graph", which in this case is HLS itself, the point being that hls-graph does not do anything about the exceptions, but the user can. Now HLS does use actionCatch to catch such exceptions and turn them into diagnostics, but it's a bit of a layering violation to write that here. Perhaps I should say it anyway?

Conceivably some other user of hls-graph could choose to just let them bubble up and crash the system...

Copy link
Collaborator

@fendor fendor Dec 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, then slightly adapting the beginning of the sentence seems fine by me.

Suggested change
-- It should be assumed that actions can throw exceptions, these can be caught with
-- It should be assumed that actions throw exceptions, these can be caught with

Maybe this is better? Or maybe just go with what you think is better, I am sure your English is better than mine.

Copy link
Collaborator

@pepeiborra pepeiborra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best source of documentation for 'Action', 'Rules' and the exception semantics is Shake itself, which has pretty good docs.

@michaelpj
Copy link
Collaborator Author

I think one relevant difference to Shake broadly assumes that it's the top-level process, and so e.g. failing during Rules should just lead to a quick user-visible failure. I think in our case that's much less clear - crashing HLS is bad and won't generally give a good error, so it's justifiable to make it harder to throw in Rules.

@michaelpj michaelpj added the merge me Label to trigger pull request merge label Dec 21, 2022
@wz1000 wz1000 removed the merge me Label to trigger pull request merge label Dec 22, 2022
@michaelpj michaelpj added the merge me Label to trigger pull request merge label Jan 2, 2023
@mergify mergify bot merged commit 8f0d940 into master Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Label to trigger pull request merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants