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

Implement workflow-level Play button business-logic #6427

Merged
merged 2 commits into from
Apr 27, 2023

Conversation

MichaelMauderer
Copy link
Contributor

@MichaelMauderer MichaelMauderer commented Apr 25, 2023

Pull Request Description

Implements #6179

Peek.2023-04-26.00-30.mp4

Important Notes

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

@MichaelMauderer MichaelMauderer self-assigned this Apr 25, 2023
@MichaelMauderer MichaelMauderer added the CI: No changelog needed Do not require a changelog entry for this PR. label Apr 25, 2023
@MichaelMauderer MichaelMauderer marked this pull request as ready for review April 25, 2023 23:31
Copy link
Contributor

@farmaazon farmaazon left a comment

Choose a reason for hiding this comment

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

I need to have some things clarified.

Comment on lines 368 to 373

/// Trigger the execution of the current graph.
pub async fn start_execution(&self) -> FallibleResult {
self.execution_ctx.start_execution().await?;
Ok(())
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should add somewhere more information about this method. It's not just starting execution (as the execution is actually performed automatically on each change). According to the design. It ought to clear caches and re-execute the entire graph.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this handled by it using the live execution context? If not, we do need some more special handling here. I’ll have a look.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I clarified the naming and comments. The clean re-execution should be handled by the API call requesting language_server::InvalidatedExpressions::All.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd call it something like recompute_in_live_environment to align with the underlying LS call. AFAIK this is not handled by the live environment specifically but rather by the usage of recompute with specific arguments (InvalidatedExpressions::All)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I chose trigger_clean_live_execution now, but we can do recompute_in_live_environment if that is preferable. I don't have a string opinion either way.

Comment on lines 333 to 345
fn start_execution(&self) -> BoxFuture<FallibleResult> {
async move {
self.language_server
.client
.recompute(
&self.id,
&language_server::InvalidatedExpressions::All,
&Some(ExecutionEnvironment::Live),
)
.await?;
Ok(())
}
.boxed_local()
Copy link
Contributor

Choose a reason for hiding this comment

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

We should also turn on "read-only" flag on controllers, implemented by @vitvakatu AFAIK.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That should already happen through the double click, which emits the appropriate FRP event from the graph editor.

Comment on lines 545 to +547
Event::Notification(Notification::ExecutionComplete { context_id }) => {
execution_update_handler(context_id, ExecutionUpdate::Completed);
publisher.notify(model::project::Notification::ExecutionFinished);
Copy link
Contributor

Choose a reason for hiding this comment

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

If this notification is sent also when any execution finishes (also those performed automatically after a change), then we could have a race where:

  1. User did a change, the automatic execution starts
  2. User clicks the play button. We set read-only flag to true.
  3. We receive "ExecutionComplete" event about execution launched in 1. We turn off "read-only" flag.
  4. Only after some time we receive "ExecutionComplete" event about execution launched in 2. Here we should turn off the flag instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. But is the old execution not aborted when we request a new one? It could still happen in a very small time window, though. But I don't think we currently have a way to match a request for re-computation with its status update, unless I'm missing something.

Copy link
Contributor

Choose a reason for hiding this comment

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

@4e6 could you help us with that? Will the engine stop the current execution when receiving a recompute message?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, when the recompute message is received, the engine aborts the current execution and re-schedules a new one. In general, the engine follows the principle that if it needs to schedule a new execution, it makes sure that the other execution is stopped. Otherwise, it may accumulate those commands and re-execute the program in a sequence.

@MichaelMauderer MichaelMauderer linked an issue Apr 27, 2023 that may be closed by this pull request
@vitvakatu
Copy link
Contributor

QA: passed 🟢

@MichaelMauderer MichaelMauderer added the CI: Ready to merge This PR is eligible for automatic merge label Apr 27, 2023
@mergify mergify bot merged commit 00510de into develop Apr 27, 2023
@mergify mergify bot deleted the wip/MichaelMauderer/Play-Button-Integration branch April 27, 2023 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Workflow-level Play button business-logic
5 participants