-
Notifications
You must be signed in to change notification settings - Fork 0
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
could kuzu work with quarto-live leveraging kuzu-wasm? #1
Comments
Hi @Analect, I'm very happy to discuss this topic with you.
I'm happy to help you solve this issue, and I'll dive deeper into Quarto. After my exam tomorrow, I'll give you a more detailed explanation. |
Great @DylanShang. Good luck with your exam! |
Hi @Analect
Currently, there are a few limitations:
The good news is that I should have successfully integrated Quarto, yFiles-Jupyter-Graphs, and Kuzu. I'll publish code in few days and mention you. However, there are some limitations:
At last, I will keep you informed of any developments regarding quarto in this issue |
@DylanShang ... great progress. Thanks for the update. I hadn't realised that there was that limitation on the yFiles widget. It's hard to find good visualisation solutions for graphs that don't require a running server, per kuzu-explorer or Neo4j Browser. Maybe something like pyvis can work in a wasm context ... was looking here, here and here for inspiration. |
@Analect At present, pyvis does seem to be the best option, and it can also run on WebAssembly. Could you share your use case and requirements? I can look for alternatives if there is a better fit. |
@DylanShang ... sorry for the delay in getting back to you. I've created a partly worked-through example use-case here: https://analect.github.io/quarto-graph-experiments/docs/demo/kuzu-use.html There are other resources on this documentation site too ... but the idea is get a kuzu / pyvis example working the in the kuzu-use.qmd The quarto doc site, as part of pre-render scripts, scrapes metadata (the yaml part at the top of each qmd and ipynb doc), pushes these to csv files in the While there are various things I want to do with this meta-data, one of the basic use-cases I have is to be able to render a quarto document and use the graph model to give context to related content, akin to functionality in obsidian, per this example. So, in my use case, I would look to run a basic cypher query that brings back the current document and maybe display other documents that have common categories. I will play around with this ... but the main need I have is to get kuzu, working with something pyvis, while leveraging either pyodide or quarto-live extensions of quarto. In the mocked-up doc site, I have included other examples from Github where the authors are pushing the boundaries in terms of adding graph visualisations to documents. In most cases, these are getting created by either R or Python code-blocks that get executed at render-time ... rather than leveraging wasm ... which is what I'm trying to do with my use-case. Does this make sense? |
Hi, @Analect |
Hi @DylanShang. Reverting back to the mock-up site I set up, as you said, neither of the approaches in cell 1 (akin to what Ibis are doing here) or cell 2 (leveraging micropip) are working per the rendered qmd at https://analect.github.io/quarto-graph-experiments/docs/demo/kuzu-use.html. This is the underlying code. I suppose the first approach might work if |
Hi @Analect Additionally, I’ve deployed the JupyterLite console version with Quarto; The underlying code is here. If you encounter any issues, try clearing all caches for the site first. And sorry for the misunderstanding caused by my explanation. What I meant by a method similar to Ibis was referring to this style of presentation. Compare with Quarto-live, I think Quarto-live does have a better presentation for blog. I think the main issue right now is that PyVis cannot render on Quarto-live(The code runs without errors, but the output appears blank) , and I suspect this might be related to issues #7 and #44. This is the code I tried failed in Quarto-live but successfully in jupyterlite import micropip
await micropip.install("pyvis")
import pandas as pd
import numpy as np
import networkx as nx
from IPython.display import display, HTML
import matplotlib.pyplot as plt
data = [{'Circuit': 'html', 'Description':1, 'Duration':10.2, 'Source':'Westchester', 'Destination':'Davie', 'Picklist':1000, 'Postlist':50000.2},
{'Circuit': 'html', 'Description':2, 'Duration':12.1, 'Source':'Westchester', 'Destination':'Davie', 'Picklist':3000, 'Postlist':40000.1},
{'Circuit': 'html', 'Description':3, 'Duration':11.3, 'Source':'Westchester', 'Destination':'Davie', 'Picklist':7000, 'Postlist':50000.2},
{'Circuit': 'html', 'Description':3, 'Duration':8.1, 'Source':'West', 'Destination':'San Bernardino', 'Picklist':3000, 'Postlist':40000.0},
{'Circuit': '.net', 'Description':4, 'Duration':6.2, 'Source':'Queens', 'Destination':'San Bernardino', 'Picklist':5000, 'Postlist':6000.1},
{'Circuit': '.net', 'Description':3, 'Duration':20.1, 'Source':'Queens', 'Destination':'Los Angeles', 'Picklist':5000, 'Postlist':4000.1},
{'Circuit': '.net', 'Description':2, 'Duration':15.5, 'Source':'Brooklyn', 'Destination':'San Francisco', 'Picklist':5000, 'Postlist':9000.3},
{'Circuit': '.net', 'Description':4, 'Duration':7.7, 'Source':'Brooklyn', 'Destination':'Davie', 'Picklist':6000, 'Postlist':10000},
{'Circuit': '.net', 'Description':4, 'Duration':7.7, 'Source':'Los Angeles', 'Destination':'Westchester', 'Picklist':6000, 'Postlist':10000},
{'Circuit': '.net', 'Description':4, 'Duration':7.7, 'Source':'San Bernardino', 'Destination':'Westchester', 'Picklist':6000, 'Postlist':10000}]
df = pd.DataFrame(data)
G = nx.from_pandas_edgelist(df, source='Source', target='Destination', edge_attr='Picklist')
from pyvis.network import Network
g = Network(notebook=True, cdn_resources='remote')
g.from_nx(G)
html = g.generate_html(notebook=True)
HTML(f'<div style="height:{g.height}">{html}</div>', metadata={"isolated": True}) Perhaps we should track this issue or use a method like quarto-example if it suits. Alternatively, we could try to find another visualization library that works properly on Quarto-live. |
@DylanShang . Thanks alot for your efforts. By any chance, does leverage iPython
|
Sorry, I got failed. The result is still empty. You can also try it here with above code. It seems like it has be blocked. Maybe we could post a issue first? And I need few days to know why. |
Tried putting all your code into a single pyodide cell ... and get back |
You can enable it by using coi-serviceworker or host in Netlify and use this config in root And you may need to host kuzu js/wasm in your own domain and change the URL in kuzu_wasm |
@DylanShang ... great. I'll admit, this cross-origin stuff bamboozles me! |
Hi, @Analect Here is demo, and the underlying code Make sure:
Let me know if you have any issue! |
@DylanShang ... thanks alot. I will try this. A quick question - with these changes, is it still necessary to host this on netlify or can it work on github pages with this Just a broader question, what is involved in generating one of these pyarrow wheel files. Is that the one coming from here? Is this necessary, since pyarrow is now a dependency of pandas? Will this enable |
I know this sounds paradoxical, but Cross-Origin Isolation complicates our deployment process. This is because multi-threaded WebAssembly depends on workers, and workers require SharedArrayBuffer for communication. However, SharedArrayBuffer necessitates Cross-Origin Isolation. Enabling Cross-Origin Isolation prevents us from requesting JavaScript files from non-same-origin sites, so for now, my solution is to host kuzu-wasm on our own site.
|
I think so! The upshot is that I end up with the various files I think I require in gh-pages/dist/package, but somehow, per the image below, they are not discoverable. I'm also not clear if I should be adding this directly into my |
@Analect Don't worry it, I'll take a detailed look at your project |
@DylanShang ... thanks alot for your help in trouble-shooting that. I emulated your changes and got it to work my end too. In terms of an automated way of running this in future, to reflect any updated to your kuzu_wasm tooling, would you recommend that I try to get this functioning in a github-actions script or is it better to build up-front in the repo using a Makefile and then pushing that github, which mimics what we (you) have had to do to get this working. Did you plan to roll kuzu_wasm into its own whl, which would get added to the requirements.txt?
I will experiment around with the pyvis / kuzu combination as a means for exploring a documentation site. By any chance, have you seen any working examples of graphs that have 'clickable' events? Where clicking on the node would take you to a different URL within a documentation site, for example. I notice this PR within pyvis, but it seems that the project is no longer actively maintained. Thanks again for your help with this. It's been instructive. |
Hi @Analect,
|
@DylanShang ... you are right. I'm probably not being clear. Setting aside the obsidian use-case, I am actually more interested in the dynamic graph generation via quarto-live cells, which would allow one to explore many different cypher queries on a data-set that gets dynamically updated, when a documentation site renders, for instance. Per this issue, the devs at However, per the third cell, I'm unable to get the |
Hi, @Analect
This is because the file systems in kuzu-wasm and pyodide are separate now. |
Ah OK @DylanShang . Now it's clear. The other thing that I was toying with was to
In terms of your interirm solution above ...
... can this be modified to handle a whole folder (rather than a single file, as required by the kuzu database specification) ... or does one need to recurse through the folder to perform a |
Sorry about that, kuzu-wasm is still at version 0.4.2, and the httpfs extension is not supported in this version. I've been working all day on resolving file transfer issues between Pyodide and kuzu-wasm, but I seem to be stuck at the moment, and it might take some time to solve this. Therefore, I strongly recommend using the method I mentioned earlier. You can replicate what you've done in
This might be quite cumbersome, but it's the only solution I have at the moment. I will explore further to support more import methods. |
I think I have to upgrade the version of kuzu within kuzu-wasm to achieve backward compatibility with kuzu's storage filesystem so we can use different versions of kuzu files directly. But this might take a long time. |
@DylanShang. I noticed you were able to get the latest kuzu version working at unswdb/kuzu-wasm. Does that mean there is now a mechanism to pull in a pre-formed kuzudb rather than having to recreate it within the kuzu VFS from files? For you kuzu shell , is it possible to get this into a console like ibis have done with jupyterlite. Thanks for your efforts. |
Hi, @Analect . Thank you for your continued interest.
Do you mean this? |
@DylanShang ... thanks for your great progress on this. I look forward to working with your solution. Ref. the REPL, you are right, I had forgotten that implementation, per 2 below. I think it still leverages your old approach, but I expect that will alter as your new mechanism gets implemented. I note how Ibis use I can see the attraction of the jupyterlite REPL, but directly accessing a kuzu shell, per 3 above, particularly if you could pre-wire it to an on-disk kuzudb (as per your work above) would be handy ... in order to be able to directly run cypher queries without any of the boiler-plate set-up required for the REPL. Is it straight-forward to be able to drop the shell into a |
@Analect Do you mean embed kuzu-shell into a qmd file? |
Hi, @Analect I made a docker image so everyone could embed their KuzuDB files or other data into the wasm. Usage is here. In this example, all the files in the data folder will be mapped into the root directory of wasm'VFS. A new wasm package will output to Also, I found out that kuzu's db file system is not backward compatible, so specific kuzu-wasm can only read the db files created by specific kuzu python. Current kuzu-wasm use the latest storage_version (v32). So you have to use the kuzu python with v32 storage_version. The way to show storage_version is here. Another thing is according to this, I got a new way to add the hyperlink in pyvis. Feel free to ask me if there are other questions! |
@DylanShang ... we exchanged messages on the kuzu discussion. I'm interested in your thoughts on the following:
await pyodide_js.loadPackage("https://storage.googleapis.com/ibis-wasm-wheels/pyarrow-16.0.0.dev2661%2Bg9bddb87fd-cp311-cp311-emscripten_3_1_46_wasm32.whl")
in a similar way to how you use it in your kuzu-use.ipynb demo notebook.Anyway, I appreciate your thoughts on these matters. Thanks. Colum
The text was updated successfully, but these errors were encountered: