Skip to content
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

Add a Redash extension system based on Python entrypoints. #348

Merged
merged 1 commit into from
Mar 23, 2018

Conversation

jezdez
Copy link

@jezdez jezdez commented Feb 28, 2018

This is along the lines of what Flask does for CLI plugins:

http://flask.pocoo.org/docs/0.12/cli/#cli-plugins

The API allows specifying Python callbacks that receive the
Redash Flask app as the only argument and allow extending
the Redash process with the usual Flask API as needed. This
does not cover front-end specific extensions (yet).

@arikfr
Copy link

arikfr commented Feb 28, 2018

Something like this was on mind for sometime now. At first I was thinking to use it for query runners, to move them to separate packages. But it can be great for extending the app in general, as you did here.

You're welcome to push this upstream.

@jezdez
Copy link
Author

jezdez commented Feb 28, 2018

Yay!

@arikfr
Copy link

arikfr commented Feb 28, 2018

Next thing is to find a good way to extend the UI, so you can move your custom stuff to extensions.

It easy enough to add new components and pages with the current setup (as it takes all pages/components from a specific folder and loads them). But the bigger thing is to be able to override existing UI elements (or extend them).

It might be possible with Angular's DI, but I prefer not to rely on it, as I hope one day to move away from Angular.

@jezdez
Copy link
Author

jezdez commented Feb 28, 2018

@arikfr Yeah, I was thinking of adding support for another redash.static entrypoint next to the redash.extensions one which would be called as part of the webpack build process. The entrypoint callbacks would return lists of filepaths, that are then copied into a temporary location that webpack will be configured to pick up during the build process.

I think that's easy enough to accomplish. Would you only limit the folders to copy files to components and pages? Or just do a merge of the client/app directory with whatever static extension would return?

I realize that this mixes Python code with front-end stuff, and may be the wrong way to do this. Can you think of a JS-native way to extend the client?

@jezdez
Copy link
Author

jezdez commented Feb 28, 2018

@arikfr Oh, BTW, in case you saw the second commit to this PR, here's the first use case to use the extension API, for a simple thing with just one entrypoint for now to fix #37: https://github.com/mozilla/redash-stmo

@jezdez
Copy link
Author

jezdez commented Feb 28, 2018

@arikfr Opened getredash#2354 with just the extension bit.

@bealdav
Copy link

bealdav commented Mar 1, 2018

as I hope one day to move away from Angular.

@arikfr please could you tell more on this topic : abstract front end layer, vue.js ?

Thanks

@arikfr
Copy link

arikfr commented Mar 5, 2018

I realize that this mixes Python code with front-end stuff, and may be the wrong way to do this. Can you think of a JS-native way to extend the client?

I guess there is a similar way to leverage npm to deliver frontend extensions, but as I think about this maybe entrypoints is the right way to go. The benefit of using entrypoints for this is that we have a single way of building extensions, and that a single extension can bring in its own backend code and frontend code.

Or maybe support both ways for frontend developers?

Anyway, for entrypoints, the way it could work is that we will have a script that iterates over the entrypoints and returns additional paths to use in the webpack build process. I'm not even sure we will need to copy them, might be able to use as is.

Need to think about this a bit more and see how it will work with the webpack build process to make sure it creates a good enough workflow for deployment and development.


As a side note, some of the features in dockerflow like detection of missing migrations and structured logging are useful upstream. I wonder if we should use dockerflow as a whole in upsrteam or just copy those parts...

@jezdez
Copy link
Author

jezdez commented Mar 5, 2018

@washort I've updated the PR to only install redash-stmo, since the extension PR was merged upstream.

@jezdez
Copy link
Author

jezdez commented Mar 5, 2018 via email

@jezdez jezdez force-pushed the master branch 2 times, most recently from 4ae2fe6 to 80d9ab6 Compare March 5, 2018 21:35
@washort
Copy link

washort commented Mar 5, 2018

r+

@rafrombrc rafrombrc added this to the 13 milestone Mar 21, 2018
@washort washort force-pushed the extensions branch 2 times, most recently from 2e9dc70 to f8ac54e Compare March 21, 2018 17:04
In the long run we'll be able to install additional dependencies by
having an own Dockerfile to build images based on the Redash image
but that installs additional Python dependencies. But until we have
a fork with lots of changes ourselves we need to do it this way.

Redash-stmo contains the ability to hook up our own Dockerflow
library.

Refs #13
Refs #37
@washort washort merged commit cb90254 into master Mar 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants