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

Receiving output content with kernel execution phase #290

Closed
sok82 opened this issue Aug 16, 2024 · 3 comments
Closed

Receiving output content with kernel execution phase #290

sok82 opened this issue Aug 16, 2024 · 3 comments

Comments

@sok82
Copy link
Contributor

sok82 commented Aug 16, 2024

In my application that is using Output component I need to get FINAL execution state AND output

But in current implementation (#282) - these are two separate things, which could be obtained only separately.

  1. Execution state - from Kernel execution phase
  2. Output - from output state handler

And this is a problem for me in my flow of events which is

  1. Trigger execution
  2. Connect handler to output
  3. Check that execution finished
  4. Disconnect handler from output (this is important)

Previously I checked that execution is finished by receiving output change event and it worked, but I didn't knew in 100% cases state of execution - success or not

Now I am able to get the state, BUT when I receive new ExecutionPhase = completed I have to disconnect output handler - which is bad, because changing of execution phase can be triggered BEFORE output change is triggered and in this case I do not catch output change event and can't set new output value

And sometimes I see that execution phase change happens AFTER output handler is triggered and in this case I can't be sure that execution finished successfully or not, which makes it useless for me.

I need some way to synchronize these two events, and for now I don't know how...

I guess that involves modification of https://github.com/datalayer/jupyter-ui/blob/3ac5b261927f70a526f777b847ee84afc6ad4b3e/packages/react/src/jupyter/kernel/KernelExecutor.ts
in a way that solves this problem?

I see following solutions

  1. Changing of execution phase ALWAYS before output change. In this case I can check execution phase in output handler, knowing that it is final state and process output accordingly
  2. Getting additional information in Output handler about execution phase
@sok82 sok82 changed the title Receiving output content with kerne execution phase Receiving output content with kernel execution phase Aug 16, 2024
@sok82
Copy link
Contributor Author

sok82 commented Aug 16, 2024

Hey @echarles ,
made a PR #291 with new Output parameter notifyOnComplete for KernelExecutor that enables notification of model changes only when execution ends

Pls, take a look if it's correct and doesn't break anything

I guess that this would solve my problem of not having a correct phase when output changes occur

But one thing that I'm not sure of is error handling - in case of errors (if I understood it right) future is not resolved and execution ends before it reaches my piece of logic - that is why error outputs are not affected by my code.
Not sure if it is right

@echarles
Copy link
Member

echarles commented Sep 9, 2024

jupyter-react 0.18.4 is released with this features.

Closing for now, please reopen if needed. Thx again.

@sok82
Copy link
Contributor Author

sok82 commented Sep 12, 2024

Hey @echarles

Finally reworked monitoring of output execution in this PR - #312

Now it looks nice - exactly what I need to handle output state changes

Please check

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

No branches or pull requests

2 participants