Feat: Add inline diagnostics for Metaflow flow structure errors#16
Open
deveshidwivedi wants to merge 5 commits intoouterbounds:mainfrom
Open
Feat: Add inline diagnostics for Metaflow flow structure errors#16deveshidwivedi wants to merge 5 commits intoouterbounds:mainfrom
deveshidwivedi wants to merge 5 commits intoouterbounds:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The extension had no way to catch flow structure errors before runtime. This adds inline diagnostics so mistakes like a missing start step or a bad self.next() reference show up as squiggly underlines while we are writing the flow.
Context
Right now the extension only helps run and spin flows. If we have a typo in a self.next() reference or forget a start step, we find out when the flow crashes. This adds inline warnings so the feedback loop is tighter.
Closes #7
How the parser works
Went with a regex scan in JS rather than spawning Python for an AST. The main reason being that an AST approach breaks on incomplete files mid-edit, which is exactly when we want diagnostics most. Metaflow flows are structured enough that regex handles real-world cases fine.
Steps:
class X(FlowSpec),class X(Base, FlowSpec),class X(metaflow.FlowSpec)@stepmethods to their owner class, bounded by class body so steps from adjacent non-flow classes don't bleed inself.next()calls per step : handles multiple calls in if/else branches as pointed out in the issue discussionstartto find unreachable stepsTesting
Tested via Extension Development Host. Created
test_flow.pywith four flow classes covering all error cases plus one clean flow and one non-flow helper class.test_flow.py
Problems panel output:
Zero diagnostics from
GoodFlow(valid flow),CommentFlow(commented self.next() correctly ignored), andHelper(not a FlowSpec, ignored entirely).Trade-offs / Design Decisions
onDidChangeTextDocument:fast enough to feel live without firing on every characteronDidChangeActiveTextEditorandonDidChangeTextDocumentused as discussed in the issue thread