Package: ibis-vega-transform
ibis-vega-transformA JupyterLab extension for performing Vega transforms lazily using Ibis.Python evaluation of Vega transforms using Ibis expressions.For inspiration, seehttps://github.com/jakevdp/altair-transformThis extension is composed of a Python package namedibis-vega-transformfor the server extension and a NPM package namedibis-vega-transformfor the frontend extension.RequirementsJupyterLab >= 3.0Getting startedpipinstallibis-vega-transformThen in a notebook, import the Python package and pass in an ibis expression
to a Altair chart:importaltairasaltimportibis_vega_transformimportibisimportpandasaspdsource=pd.DataFrame({'a':['A','B','C','D','E','F','G','H','I'],'b':[28,55,43,91,81,53,19,87,52]})# or ibis.pandas if ibis version < 1.4connection=ibis.backends.pandas.connect({'source':source})table=connection.table('source')alt.Chart(table).mark_bar().encode(x='a',y='b')Check out the notebooks in the./examples/directory to see
some options using interactive charts and the OmniSci backend.UsageImportingibis_vega_transformsets thealtairrenderer and data transformer to"ibis". It also monkeypatches the Ibis chart constructor to handleibisexpressions.Now, whenever you pass anibisexpression to a chart constructor, it will use the custom ibis renderer, which pushes all data aggregates to ibis, instead of in the browser.You can also set a debug flag, to have it instead pull in the first N rows of the ibis expression and use the default renderer. This is useful to see how the default pipeline would have rendered your chart. If you are getting some error, I reccomend setting this first to see if the error was on the Altair side or on theibis-vega-transformside. If the fallback chart rendered correctly, it means the error is in this codebase. If it's wrong, then the error is in your code or in altair or in Vega.# enable fallback modeibis_vega_transform.set_fallback(True)# disable fallback mode (the default)ibis_vega_transform.set_fallback(False)TracingIf you want to see traces of the interactions for debugging and performance analysis,
install thejaeger-all-in-onebinary and thejupyterlab-server-proxylab extension to see the Jaeger icon in the launcher.condainstalljaeger-cconda-forge
jupyterlabextensioninstalljupyterlab-server-proxy-saulshanabrookThe Jaeger server won't actually be started until a HTTP request is sent to it,
so before you run your visualization, click the "Jaeger" icon in the JupyterLab launcher or go to/jaegerto open the UI. Then run your visualization and you should see the traces appear in Jaeger.You also will likely have to increase the max UDP packet size on your OS toaccomdate for the large logs:Mac# Edit nowsudosysctlnet.inet.udp.maxdgram=200000# Edit on restartechonet.inet.udp.maxdgram=200000|sudotee-a/etc/sysctl.confTroubleshootIf you are seeing the frontend extension, but it is not working, check
that the server extension is enabled:jupyterserverextensionlistIf the server extension is installed and enabled, but you are not seeing
the frontend extension, check the frontend extension is installed:jupyterlabextensionlistContributingDevelopment installNote: You will need NodeJS to build the extension package.Thejlpmcommand is JupyterLab's pinned version ofyarnthat is installed with JupyterLab. You may useyarnornpmin lieu ofjlpmbelow.# Clone the repo to your local environmentgitclonegit@github.com:Quansight/ibis-vega-transform.git# Change directory to the ibis-vega-transform directory and# Create a conda environmentcdibis-vega-transform
condaenvcreate-fbinder/environment.yml
condaactivateibis-vega-transform# Install package in development modepipinstall-e.# Link your development version of the extension with JupyterLabjupyterlabextensiondevelop.--overwrite# Rebuild extension Typescript source after making changesjlpmrunbuildYou can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.# Watch the source directory in one terminal, automatically rebuilding when neededjlpmrunwatch# Run JupyterLab in another terminaljupyterlabWith the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).By default, thejlpm run buildcommand generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command:jupyterlabbuild--minimize=FalseA pre-commit hook is installed usig Husky (Git > 2.13 is required!) to format files.Run the formatting tools at any time using:blackibis_vega_transform
jlpmrunprettierTracingWe are usingjupyter-jaegerto trace each interaction
for benchmarking.Uninstallpipuninstallibis-vega-transform