Hi Team, Is there a way to add the the kedro-viz i...
# questions
s
Hi Team, Is there a way to add the the kedro-viz interactive graph to a static website? I found the kedro-static-viz plugin, but it doesn't work with 0.18.3. Looking at the
kedro-viz/readme
it suggests using a standalone React component with the
pipeline.json
as prop. I tried it, but couldn't get it to work - I am not familiar with React. Do you have a simple example using a static website or do you need a proper React environment? Many thanks
d
this is the recommended way, there isn’t anything simple for python programmers out of the box yet
s
OK - at least I am on the right path. Will wrestle with React and html some more. Do you know of any project that uses this as example?
t
hi Sean. take a look a this repo: https://github.com/tynandebold/kedro-viz-standalone
K 1
d
Thanks @Tynan
πŸ‘ 1
t
s
Many thanks @Tynan
πŸ‘ 1
t
let me know if you need anymore help with it
πŸ‘ 1
a
This is really awesome, but i'm a little lost (I know next to nothing about react / frontend )
Is the idea here that you can do:
kedro viz --save-file=pipeline.json
and then you somehow use that
pipeline.json
w/ a copy of the contents of https://github.com/tynandebold/kedro-viz-standalone somewhere ? tand then somehow use that json file in a directory w/
s
Hi Andrew, its been a while, but if I remember correctly the kedro-viz-standalone is a react component so the easiest way to get going is to install node.js as an environment and then you can run it easily. And yes, you load a pipeline json file as input to show the interactive graph. I managed to export/build the above then to a static file to include in a simple documentation. I am not a react/frontend person myself so it involved a bit of learning... Try
npm start
in the root dir after install node.js and it should show the react component in your browser with the demo data. to then import your own data (
pipeline.json
)change
import { demo } from "./demo";
to
var demo = require('./pipeline.json');
a
ok so this depends on a running npm instance somewhere ?
This wouldn't help create something like static html/css/js ?
I know https://github.com/WaylonWalker/kedro-static-viz exists but it is abandoned
so ive been keeping an eye out for a replacement
t
@Andrew Stewart could you give more context on what you're trying to achieve? i'll be better able to assist you if you do πŸ™‚
a
Of course. Let's say I want to setup a GitHub Action that generates a static form of the kedro-viz site which I can then serve via GitHub Pages
Hey @Tynan just curious if any thoughts on what I said above ?
t
sorry for the delay! what you said above sounds doable. will the GitHub action run from a repo that's a Kedro project? if so, you may be able to run
kedro viz --save-file
in the action, save that to a known location in the repo, and then serve a React application via GitHub pages that uses that save data to populate Kedrp-Viz
a
Interesting
So I guess that react app would be just kind of a loading shell ?
like I imagine it could all just be in a single html file (or maybe an html file + some js files) that could be reused to load any dump from
kedro viz --save-file
?
t
yes, exactly right
a
Got it. Sounds like this could potentially make for a nice little plugin.
I'd be interested in taking a stab at that - though I know next to nothing about front end stuff (js package mgmt etc).. if you happen to be able to point me to anything that might help get me started, would be appreciated.
t
yeah that should work. that's how i'm hosting that other Viz instance. you should be able to do the same
a
Pretty cool!
Got a question on this if anyone here knows the answer. Let's say I want to serve the
build
directory not as a web root but as a subdirectory of some larger site. By default all the paths are absolute to the web root. I found some guidance on how to modify that behavior : https://stackoverflow.com/questions/51692588/react-js-running-npm-run-build-with-custom-paths It sorta works but I suspect there are some things in the code that are basically hard-coded to absolutes? I know next to nothing about frontend programming, so I'm trying to poke around it but so much of this kind of logic seems to be built into the actual package build tooling.