metriql/metriql-lookml

Support downloading files as a zip file

buremba opened this issue · 4 comments

We will call this library from our web app and let people generate LookML projects locally if they wish so. In order to integrate with the web app, the users need to be able to download the LookML files as a zip file. Here is how it looks like: https://cln.sh/wVY9s9

We can have a command-line argument called --stdout that outputs a zip file to stdout so that we can call the Python library from our application or the users can run the following command:

metriql-looker --stdout > files.zip

If the app is run by the web app how will you make sure that the folder / Zipfile created is unique? The caller will have responsibility of assigning unique name? When you say "outputs a zip file to stdout" you mean it will output the zip file to root folder?

We should not be creating any files, instead, the Python script will print out the zip file content to stdout so that we read the content in our web app and stream it to the web browser.

Here is an example in Python: https://stackoverflow.com/questions/55514745/how-to-stream-from-zipfile-how-to-zip-on-the-fly

When we build the project, it will work just like gzip command in bash: https://serverfault.com/questions/366388/how-to-zip-the-standard-output-of-a-process

Our app will create a subprocess by running this Python library, and reads the output:

  1. If it writes to stdout, the app reads the contents, creates a zip file on the file with a name and lets the browser download the file.
  2. If the script runs into an error, it will write to stderr so that our app understands that there is an error and reads the content to show the error message to the end-user.

We have already done something similar for our Tableau integration so I'm re-assigning this one to myself.

waiting for #10