I’m excited to debut
lkml, a pure Python parser for LookML.
You can run
lkml from the command line (it will output a JSON string) or import it as a Python package (it will output a nested dictionary).
@fabio at Looker already built a fantastic, open-source parser in Node, but I find that the Node dependency sometimes makes it difficult to adopt for Python-based workflows that data people are more familiar with.
I decided to embrace the challenge of hand-writing a parser in Python without any external dependencies or libraries.
I didn’t have access to the actual grammar used for LookML, so I reverse engineered it myself. Don’t worry, I’ve tested
lkml on over 160K lines of public LookML I downloaded through the GitHub API and it works like a charm!
lkml is fast too. Excluding file I/O, it parses a typical file in a handful of milliseconds. Based on my tests, it’s at parity with the Node parser.
lkml has a full unit test suite with CI.
lkml is up on pip, so the following command will install it
pip install lkml
Please also check out the project on GitHub for a more detailed description and instructions. Contributions and issues are welcome! If you build anything interesting with this parser, please send me a link!