pyodide-kernel icon indicating copy to clipboard operation
pyodide-kernel copied to clipboard

Read the execution count from the Python kernel

Open jtpio opened this issue 3 years ago • 2 comments

Problem

https://github.com/jupyterlite/jupyterlite/pull/492 added a check to not increment the execution count if store_history is set to false.

This check happens in the base kernel class here:

https://github.com/jupyterlite/jupyterlite/blob/cb66d86e9b10cedc41f6bad77e3a25a97efb9c44/packages/kernel/src/kernel.ts#L536-L538

This means the JS, Python and potentially other kernels get that behavior automatically if they inherit from BaseKernel.

Proposed Solution

We should check whether we would like to read the execution_count from the specialized kernels if available.

In the case of Pyolite that might mean reading it from here:

https://github.com/jupyterlite/jupyterlite/blob/72ebada70067afcd88ddcd283f4b7f0baf36cbdb/packages/pyolite-kernel/src/worker.ts#L181-L185

Additional context

Raised in https://github.com/jupyterlite/jupyterlite/pull/492

jtpio avatar Feb 13 '22 08:02 jtpio

I am looking at good first issues that I could contribute towards, It's one of my first times contributing.

But the Pyodide kernel got shifted to the (https://github.com/jupyterlite/pyodide-kernel) repo, right?

Also, Are you trying to say that the baseKernel class should check if the specialized kernels provide an execution_count?

savakarrohan avatar Aug 21 '23 02:08 savakarrohan

Thanks @savakarrohan for your interest in contributing!

But the Pyodide kernel got shifted to the (https://github.com/jupyterlite/pyodide-kernel) repo, right?

That's right. Now the relevant code is in https://github.com/jupyterlite/pyodide-kernel/blob/main/packages/pyodide-kernel/src/kernel.ts.

Also, Are you trying to say that the baseKernel class should check if the specialized kernels provide an execution_count?

I think that was the idea yes. Which would apply to the JavaScript and Pyodide kernel.

For reference the jupyterlite-xeus-python kernel already keeps track of its own execution count as being based on xeus: https://github.com/jupyterlite/xeus-python-kernel

jtpio avatar Aug 21 '23 06:08 jtpio