3 ms·
Alright I'm really curious on the use case of this. Is it for debugging assistance or anything else?
by Something1234 3y ago
Alright I'm really curious on the use case of this. Is it for debugging assistance or anything else?
- bsimpson 3y agoThey get deployed into a Colab cell or Google Drive. It's nice to be able to see what version is there without running anything.
- Something1234 3y agoThere's an api to update a Colab cell publicly available? That's wild. I thought for sure it would be locked down.
- bsimpson 3y agoBest solution I've found is to paste the whole thing into a cell with this header #@title Give your cell a headline %%js_module where js_module is defined here: # Copyright 2023 Google LLC. # SPDX-License-Identifier: Apache-2.0 from IPython.core.display import display, HTML from IPython.core.magic import register_cell_magic import time @register_cell_magic def js_module(line, cell): if cell.startswith('http'): src, hash = cell.split('#') if '#' in cell else [cell, ''] timestamp = time.time() if 'cachebust' in line else '' display(HTML( "<script type = 'module' src = '{src}?{timestamp}'></script>".format(src = src, hash = hash, timestamp = timestamp) )) else: display(HTML( "<script type = 'module'>{cell}</script>".format(cell = cell) )) The #@title lets you collapse the cell, so the JavaScript isn't showing. Colab has a strong philosophy of ensuring the user can see everything they're running, so I don't think there's a better way to encapsulate the bundled JS.