Story: Add language support for DVC.yaml
We need to help users manage stages, metrics, models, params within the editor.
This story is a prerequisite for the #838
@shcheklein are you sure that is the correct issue?
We already have the basic support to check it again the schema
But via the YAML extension by RedHat right? If so should it be recommended somewhere in the Get Started page?
We have an in-product prompt to install that extension. It was added in https://github.com/iterative/vscode-dvc/pull/903. Under this ticket we'll look at expanding support outside of the scope of that extension 👍🏻.
Oh, I did notice that box but I thought it was an automatic VSC prompt. Cool then
Updates:
- Highlighting is working, but we'll need to adjust colors, so we can leave it for later.
Language support:
- (Easy) We can link the file/folder references in the dvc yaml files so VSCode can open them in a new tab.
- (Medium) We can register the parameters as symbols, so the user can jump to them on a Cmd+Click on their reference.
- (Medium) We can register the metric fields as symbols for the same reasons.
- (Hard, because of scoping issues) We can provide definitions for the symbols referenced in the variables, for the same reasons.
I'm posting this now because I believe I have a shot at a first iteration of the first three items in the language support list, and I would like to post a demo tomorrow.
@wolmir can you share some video (even WPI is totally fine)
We can link the file/folder references in the dvc yaml files so VSCode can open them in a new tab.
Can we do things like:
- I edit it in one place and it's being updated in all other places?
- I want to highlight the file in the navigator?
We can register the parameters as symbols, so the user can jump to them on a Cmd+Click on their reference.
- Can we show the value?
Hard, because of scoping issues
Could you clarify please?
@skshetry @dberenbaum anything from the top of your head that would simplify editing /managing DVC files?
@shcheklein I'll try to record a video today
I edit it in one place and it's being updated in all other places?
Technically yes, but can you give me a specific example, please?
I want to highlight the file in the navigator?
Yes that's possible, but we have to be careful with the highlight color to not conflict with other extensions like GitLens for example.
Can we show the value?
Yes, traditionally as a hover tooltip, but there are other possibilities like a faded text next to the symbol.
Could you clarify please?
From the DVC docs, the variables are scoped per stage/foreach block and can't be referenced outside of it. They can also be shadowed by using the same variable name in an inner scope.
From the DVC docs, the variables are scoped per stage/foreach block and can't be referenced outside of it. They can also be shadowed by using the same variable name in an inner scope.
@wolmir, I think you can ignore the inner scope unless someone asks for it (it's an arcane feature).
That said, I think it'd be easier to design it in a way that resolves each stage independently, considering the support for for-each, as the extension still needs to understand item/key (which is shadowed).
Thanks @skshetry !
While you're here, can you think of other ways VSCode can help with dvc.yaml?
While you're here, can you think of other ways VSCode can help with dvc.yaml?
I think a view of all stages in the sidebar would be nice which takes you to the individual definitions of the stages and maybe allows running each individually (just like the tests).
I don't know if it's in the scope of this ticket, but we could also have linter-like features, eg: parameter does not exist or is out of sync, etc.
:+1: to pretty much everything here.
We have an in-product prompt to install that extension. It was added in #903. Under this ticket we'll look at expanding support outside of the scope of that extension 👍🏻.
Can we call this out even more? Like @jorgeorpinel, I didn't realize it was for DVC and ignored it.
- (Medium) We can register the parameters as symbols, so the user can jump to them on a Cmd+Click on their reference.
This would be nice. Even better would be to suggest individual parameters in IntelliSense by parsing params.yaml (or a custom params file if the key has been provided).
- (Medium) We can register the metric fields as symbols for the same reasons.
Unlike params, there shouldn't be individual metrics fields in dvc.yaml. All metrics values should be path-level references. Maybe I'm misunderstanding this point.
- (Hard, because of scoping issues) We can provide definitions for the symbols referenced in the variables, for the same reasons.
Not sure I follow what this would do.
I think a view of all stages in the sidebar would be nice which takes you to the individual definitions of the stages and maybe allows running each individually (just like the tests).
In addition, it would be nice if we could show in which other stages a path is referenced and in what context (what is the stage name and is the path a dep/out/etc.).
Other ideas that I think would be helpful (apologize if some are wildly unrealistic, but I'm excited for this as it could greatly improve the experience of creating pipelines):
Snippets
Suggest filled-out templates for sections of dvc.yaml:
- Whole stages, or maybe have different stage templates (like
dvc exp init --type). - A basic plot template or different templates for various plot types (examples in https://dvc.org/doc/dvclive/api-reference/live/log_plot?tab=roc#supported-plots, https://dvc.org/doc/command-reference/plots#example-smooth-plot).
- Foreach stage template.
- Vars template.
IntelliSense Suggestions
- Suggest path values under sections like
wdir,deps,outs,params,metrics, andplots. Even better would be to use file extensions to only suggest appropriate paths (for example,metricssupport JSON/TOML/YAML). - Suggest params values from
params.yaml. If a specific parameters file is specified, suggest values from that file. - When using vars or foreach and
${}syntax, suggest valid values based on vars/foreach items (and ideally put these at the top of suggestions).
Nice, thanks @dberenbaum !
WIP stuff:
https://user-images.githubusercontent.com/1231848/181832824-6ae3eec9-dbae-4aba-ae9e-8ac21c2d9865.mov
https://user-images.githubusercontent.com/1231848/181832852-2e4f224c-8c16-4b75-a2e4-a6bcc5c5b7f7.mov
https://user-images.githubusercontent.com/1231848/181832917-fd9f8e4b-0204-4ddb-8811-e7107aa37659.mov