Culture, Build

Reviving EveGenie—or, What Happens When a Container Solutions Engineer Gets 'Play Time'

Container Solutions is a consulting company that focuses on Cloud Native transformations. Working as a Cloud Native engineer here means you get assigned to work on projects for particular clients. When you finish one project, you are moved to the next one.

However …

LegoPlayTime

Because of our organisational culture, we always make sure that you have some time in between to chill out. So instead of starting a new project the day after finishing the old one, you get a few days, or even weeks, to build, test, or learn anything you want.

During that time we test new Cloud Native tools, contribute to some open-source projects, create some on our own, or whatever geeks like to do. So I’d like to tell you what I’ve been doing for the last few weeks, while waiting to start a new, inspiring project.

All About Eve

I would like to tell you about something called EveGenie. But first, I need to give you a little bit of context. So let’s talk about Python Eve first.

Eve was created by Nicola Iarocci. It’s REST-centered API framework built on top of Flask. What’s great about it is that it’s extremely easy to build a complete API with it; all you need to kickstart it is run a MongoDB server and two Python files (app.py, which in most basic setup contains four lines of code, and settings.py, which define the endpoints, database connection, and extra configuration if you need it).

Simplicity is the first selling point of Eve but make no mistake—it does not limit you at all. It is very feature rich. It offers most of the things you would expect from an API: full range of CRUD operations, filtering, sorting, pagination, conditional requests, data validation, and so on. Plus, since it’s built on top of Flask, most Flask add-ons should work with Eve too.

So the thing to remember is that Python Eve is a really nice framework for building APIs. If you want to know more about Eve, feel free to check it out here. But now, I want to tell you about a tool that makes building API with Eve even simpler.

A Time-Saving Tool

When I joined Container Solutions, the first project I was assigned was for a company that had a prototype API built with Python Eve. The client wanted me to build a complete, production-grade solution for their needs based on that. It was a really nice journey and I got to like Eve a lot.

But one thing that is still time-consuming is creating a schema for the data you want to have in the API. If you have more than 10 different endpoints, each containing dozens of objects —and especially during the prototyping phase—that schema changes. Then, you have to do a lot of small, but time-consuming changes:

‘Please change that variable to be integer instead of string.’

‘Please change the name of that variable.’

‘Please change those 17 variables to have not prefix X but … ‘

You know what I mean.

EveGenie to the rescue! The tool allows you to automate and speed up that schema-building process a lot. What it does is it takes a JSON file with your data and generates settings.py file for you automatically. So rather than spending an hour in a text editor, copy/pasting variable names which you got in Lucidchart, you can do it in no time!

Let’s see an example. Let’s say you got JSON from one development team with this data.

You would have to spend quite some time to build settings.py based on that. And now imagine: You have six more teams sending you their JSON files too. You’re done for a week! Unless you use EveGenie—then it takes you a few minutes.

To reiterate it: EveGenie just generates settings.py for you, so the only thing you need to do is:


python geneve.py your_data.json
    

And the second later, get ready to use your settings.py file.

Awesome? Cool? Great? I know! There is only one problem: EveGenie is deprecated since 2014. Well, it was, before I revivified it.

And that’s why I’m writing this blog post: To let you know, it’s there for you to save you some time.

EveGenie Lives!

So, there were two problems I worked on during my ‘play time’ at Container Solutions between projects. One, that Python Eve evolved quite a lot since 2014, but the file that the last version of EveGenie generated was no longer valid for the latest version of Eve.

And two, that Eve was built in Python 2 (and didn’t work with 3.0 and up). Eve still works with Python 2 but it’s really recommended to use Python 3 (and that’s not only the case for Eve, but in general).

Solving the first problem wasn’t rocket science. The settings.py file is being built by EveGenie based on the Jinja template, so I simply updated the template so that the generated file is compatible with the latest versions of Eve.

Making it compatible with Python 3, though was a little bit more complicated. Among the things that needed to be fixed: Data types changes (unicode type is no longer available, NoneType becomes type(None) ), data types method changes (.iteritems() becomes .items() ), and module import changes.

So I’ve spent some time to find all the deprecated code and here we are: EveGenie lives!

I still need to put some work in it. I only fixed the code itself and quickly updated README, but docs and build process are still on the to-do list. Nevertheless, I hope you’ll find it useful and if you see anything that concerns you, feel free to raise a GitHub issue.

Feature image by Ryan Quintal on Unsplash

 

Do you also want to have some "play time" for yourself between projects? At Container Solutions we provide a happy workplace where our engineers can learn, practice and experiment new things!

Check out our openings and maybe you can be one of us soon!

hiring.png

 

 

Comments
Leave your Comment