Skip to content
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

Skip files that include Runme session IDs (those are output files) #459

Merged
merged 4 commits into from
Dec 29, 2023

Conversation

sourishkrout
Copy link
Member

@sourishkrout sourishkrout commented Dec 28, 2023

The extension will write Outputs to a separate session file. The idea is to make saving outputs available ahead of load (deserialization) and chunk up the dev effort required to unlock both.

Since, by default, the Session Outputs file will be colocated with its original document, it's highly likely to be included when a project is being loaded. The extension UX rejects running Session Outputs files in the notebook UX (stateful/vscode-runme#1025).

This PR introduces a check for a Runme session ID, which will skip these docs/tasks accordingly.

PS: Also brings back a launch cfg to attach to dlv which is required for tui debugging.

@sourishkrout
Copy link
Member Author

Please review as per description, @adambabik.

@adambabik
Copy link
Collaborator

The idea is to make saving outputs available ahead of load (deserialization) and chunk up the dev effort required to unlock both.

I don't quite understand "[...] saving outputs available ahead of load (deserialization)". Is it to cover the case of a new or modified and unsaved file?

@@ -410,6 +410,11 @@ func getCodeBlocksFromFile(path string) (document.CodeBlocks, error) {
func getCodeBlocks(data []byte) (document.CodeBlocks, error) {
identityResolver := identity.NewResolver(identity.DefaultLifecycleIdentity)
d := document.New(data, identityResolver)

if f, _ := d.Frontmatter(); f != nil && f.Runme.Session.ID != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: To be completely safe in the case the API changes, I recommend:

Suggested change
if f, _ := d.Frontmatter(); f != nil && f.Runme.Session.ID != "" {
if f, err := d.Frontmatter(); err == nil && f != nil && f.Runme.Session.ID != "" {

@@ -410,6 +410,11 @@ func getCodeBlocksFromFile(path string) (document.CodeBlocks, error) {
func getCodeBlocks(data []byte) (document.CodeBlocks, error) {
identityResolver := identity.NewResolver(identity.DefaultLifecycleIdentity)
d := document.New(data, identityResolver)

if f, _ := d.Frontmatter(); f != nil && f.Runme.Session.ID != "" {
return document.CodeBlocks{}, nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hint: This is more idiomatic and does not allocate any memory (negligible in this case):

Suggested change
return document.CodeBlocks{}, nil
return nil, nil

@sourishkrout
Copy link
Member Author

The idea is to make saving outputs available ahead of load (deserialization) and chunk up the dev effort required to unlock both.

I don't quite understand "[...] saving outputs available ahead of load (deserialization)". Is it to cover the case of a new or modified and unsaved file?

Neither. It's to get closer to make stateful/vscode-runme#996 an opt-out versus opt-in feature (which it currently is). Runme knows how to write markdowns with cell outputs but can't do the reverse (yet). See screenshot in PR for clarity.

@sourishkrout sourishkrout merged commit 9fe054f into main Dec 29, 2023
4 checks passed
@sourishkrout sourishkrout deleted the skip-session-outputs branch December 29, 2023 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants