vscode-dvc icon indicating copy to clipboard operation
vscode-dvc copied to clipboard

Story: Add language support for DVC.yaml

Open shcheklein opened this issue 3 years ago • 17 comments

We need to help users manage stages, metrics, models, params within the editor.

shcheklein avatar Jan 05 '22 01:01 shcheklein

This story is a prerequisite for the #838

@shcheklein are you sure that is the correct issue?

mattseddon avatar Jan 09 '22 22:01 mattseddon

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?

jorgeorpinel avatar Jun 01 '22 08:06 jorgeorpinel

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 👍🏻.

mattseddon avatar Jun 01 '22 09:06 mattseddon

Oh, I did notice that box but I thought it was an automatic VSC prompt. Cool then

jorgeorpinel avatar Jun 01 '22 16:06 jorgeorpinel

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 avatar Jul 28 '22 18:07 wolmir

@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 avatar Jul 29 '22 01:07 shcheklein

@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.

wolmir avatar Jul 29 '22 13:07 wolmir

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).

skshetry avatar Jul 29 '22 13:07 skshetry

Thanks @skshetry !

While you're here, can you think of other ways VSCode can help with dvc.yaml?

wolmir avatar Jul 29 '22 13:07 wolmir

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.

skshetry avatar Jul 29 '22 14:07 skshetry

:+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, and plots. Even better would be to use file extensions to only suggest appropriate paths (for example, metrics support 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).

dberenbaum avatar Jul 29 '22 18:07 dberenbaum

Nice, thanks @dberenbaum !

wolmir avatar Jul 29 '22 18:07 wolmir

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

wolmir avatar Jul 29 '22 19:07 wolmir