Skip to content

Commit

Permalink
No public description
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 541993402
  • Loading branch information
metrizable authored and colaboratory-team committed Sep 8, 2023
1 parent f73520d commit 93ce87d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
11 changes: 10 additions & 1 deletion google/colab/_serverextension/_resource_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,17 @@ def get_ram_usage(kernel_manager):
# is better performed in the frontend presentation layer. 2) was only a
# requirement for the split (KMC/K) container, a feature that was dropped
# (cl/470476143).
def get_pid(kernel):
# TODO(b/264409633): Eliminate this function after migration to
# jupyter-client 7.x is complete.
try:
pid = kernel.provisioner.pid
except: # pylint: disable=bare-except
pid = kernel.kernel.pid
return str(pid)

pids_to_kernel_ids = {
str(kernel_manager.get_kernel(kernel_id).kernel.pid): kernel_id
get_pid(kernel_manager.get_kernel(kernel_id)): kernel_id
for kernel_id in kernel_manager.list_kernel_ids()
}

Expand Down
11 changes: 11 additions & 0 deletions google/colab/_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from ipykernel import jsonutil
from ipykernel import zmqshell
from IPython.core import alias
from IPython.core import compilerop
from IPython.core import inputsplitter
from IPython.core import interactiveshell
from IPython.core import oinspect
Expand All @@ -52,6 +53,16 @@ def _show_pip_warning():
class Shell(zmqshell.ZMQInteractiveShell):
"""Shell with additional Colab-specific features."""

def init_instance_attrs(self):
"""Initializes instance attrs.
Since https://github.com/ipython/ipykernel/pull/597 introduces filename
changes for source files which we parse to get execution count, we use the
original CachingCompiler instead of the custom XCachingCompiler.
"""
super().init_instance_attrs()
self.compile = compilerop.CachingCompiler()

def init_events(self):
self.events = EventManager(self, available_events)
self.events.register('pre_execute', self._clear_warning_registry)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Note: these dependency versions should be kept in-sync with the versions
# specified in the docker container requirements files.
'google-auth==2.17.3',
'ipykernel==5.5.6',
'ipykernel==6.21.3',
'ipython==7.34.0',
'notebook==6.5.5',
'pandas==1.5.3',
Expand Down

0 comments on commit 93ce87d

Please sign in to comment.