pyLookML

  • 13 April 2020
  • 0 replies
  • 265 views

Userlevel 2

I’d like to announce the release of pyLookML, the batteries included toolkit for scripting LookML.

It leverages the awesome lkml parser written by Josh Temple, but expands on it by offering an OO interface, integration with github or any git service, scripting syntax, convenience functions / macros, querying views for fields with specific parameter conditions, child-dependency tracing and more.

You can get started by doing pip install lookml (create it in a virutalenv of course!)

Visit the project documentation here

Here is an example script solving the age old EAV schema issue: here

Here is a short cookbook of things you can do with it: here

And of course, let me know if you have any questions!

File bugs and feature requests here


Here is a small code sample demonstrating some of what’s possible:


import lookml

proj = lookml.Project(
repo= "llooker/pyLookMLExample",
access_token="your_github_access_token",
#Optional args for the deploy URL (for deploying directly to production mode)
,looker_host="https://mylooker.looker.com/"
,looker_project_name="my_project"
)

viewFile = proj.file('01_order_items.view.lkml')
order_items = viewFile.views.order_items

for field in order_items.sale_price.children():
print(field.__ref__)

>>> ${min_sale_price}
>>> ${max_sale_price}
>>> ${total_sale_price}
>>> ${average_sale_price}

...#Change something
order_items.id.primary_key = 'no'
#writes back to github
proj.put(viewFile)
#hits the deploy url
proj.deploy()

Will follow up here with additional recipes and blocks over time you can start adding to your workflows!


0 replies

Be the first to reply!

Reply