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

Live Stream Lambda Output During Execution #406

Merged
merged 19 commits into from
Oct 1, 2019

Conversation

mandatoryprogrammer
Copy link
Contributor

This PR adds the ability to stream the output of Code Block executions in real time as they happen.

Video of the update: https://drive.google.com/file/d/1xzyBIWCDxdtbc45i-tKtfhuhqxOb6zP5/view?usp=sharing

Notes about this feature:

  • Works on dev and prod Code Blocks
  • Changes the loading UI
  • The streamed output of the Code Block automatically tails the code output. If the user scrolls up during the output then the tailing is disable for the specific run (and then tailing starts again on the next execution). This is implemented as an additional feature for the Monaco editor component.
    • This was especially painful because Monaco does not provide any way to understand the difference between a programmatically-caused scroll and a user-caused scroll. This is instead determined by the editor scroll direction and the contents of the editor.
  • Adds Websocket integration

return true;
}

// Otherwise, false. This is not valid output.
return false;
}

public getRunLambdaReturn(hasValidOutput: string | null | boolean) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The name of this parameter is pretty confusing (it sounds like a boolean but it's not always). And it's also probably doing too much (3 different types).

I'd recommend just handing this function the output from this.runResultOutput and have it pull runResultOutput.returned_data. Would be a bit less confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was trying to make it DRY, did as requested: 1cc92bb

Also changed the function to getRunLambdaReturnFieldValue

Copy link
Collaborator

@freeqaz freeqaz left a comment

Choose a reason for hiding this comment

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

Awesome to see this come together! The Vue plugin seems like it did a lot of the heavy lifting here -- the rest looks like glue around getting the data into the store + some UX tweaks to make the feature usable.

I'm sure you learned about the Monaco docs being a bit painful. ;)

Nice work on this. Threw a few comments around on a few enhancements/cleanups. Let me know if you have any questions. :)

front-end/src/shims-vue.d.ts Outdated Show resolved Hide resolved
front-end/src/store/modules/run-lambda.ts Outdated Show resolved Hide resolved
front-end/src/store/modules/run-lambda.ts Outdated Show resolved Hide resolved
}

// Types
export interface RunLambdaState {
isRunningLambda: boolean;
runningLambdaType: runningLambdaType | null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I need to figure out how we can do "many-to-many" relationships in Vue soon. It'd be nice to be able to have "one store per running lambda" or something similar. Would allow the user to run a lambda, grab another block, run that, and then click back to the first block. Seamless experience that currently doesn't exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I thought about that while writing this, but tried not to go too far down a rabbit hole.

// Nothing to do here, Websocket connection has been opened.
},
[RunLambdaMutators.WebsocketOnClose](state, event) {
console.info('Websocket connection was closed, attempting to reconnect...');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmmm this is reallllllly weird as a mutator!

But I understand that this is the library... Just weird...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I didn't like it as a mutator either but it's what the library used for some reason \o/

front-end/src/store/modules/run-lambda.ts Outdated Show resolved Hide resolved
front-end/src/store/modules/run-lambda.ts Outdated Show resolved Hide resolved
front-end/src/utils/websocket-utils.ts Outdated Show resolved Hide resolved

onChange?: (s: string) => void;
}

@Component
export default class MonacoEditor extends Vue implements MonacoEditorProps {
editor?: any;
lastEditorHeight?: number;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not actionable feedback on this code and solely an anecdote about this:

I'm not crazy stoked about keeping track of this state in this component, but at the same time I understand why this makes sense to do. Longer term, we'll have to think about how we want to hold state for the editors. Would be nice to have this in the store (especially for debugging). But that's not easy to solve. So I'm fine with this living here for now until we have a better story around how to keep track of Monaco state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Worth making an issue for maybe?

front-end/src/main.ts Outdated Show resolved Hide resolved
@mandatoryprogrammer
Copy link
Contributor Author

Addressed all outstanding comments

@mandatoryprogrammer
Copy link
Contributor Author

Did a port-forward on my router and confirmed this works in the non-ngrok mode. So this should be GTG in production.

Copy link
Collaborator

@freeqaz freeqaz left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes yo :)

# Conflicts:
#	front-end/src/main.ts
#	front-end/src/utils/websocket-utils.ts
@mandatoryprogrammer
Copy link
Contributor Author

Hold on to you butts, we're doing it live - landing this now.

@mandatoryprogrammer mandatoryprogrammer merged commit b5f2f14 into master Oct 1, 2019
@freeqaz freeqaz deleted the websocket-live-debugging branch December 11, 2019 22:50
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