Kartones Blog

Be the change you want to see in this world

BazelCon 2022 Community Day Bootcamp

Last week the BazelCon 2022 took place, and before the main conference there was an extra Community Day. I assisted to the Beginner Track of the Community Day, where we did two workshops, one about basic Bazel concepts and another about writing rules.

Despite the great instructors that we had, at times the instructions on the repository of the first workshop felt a bit incomplete. It wasn't long nor complex, but took more effort to understand what exactly we were supposed to do than actually doing it. Later I discovered that the slides were actually meant to be the main driver, instead of the repo's README file that we followed. And there was also some unused code. So I've forked and cleaned both the repository, by removing all unused code and adding slightly better instructions, and the slides themselves, cleaning unused bits and properly linking the exercise names and numbers to the matching repo ones.

You can find the updated slides here and my forked repo at https://github.com/kartones-forks/bazel-bootcamp.

Book Review: Python testing with Pytest


Python testing with Pytest book cover

Title: Python testing with Pytest, 2nd Edition

Author(s): Brian Okken

I've been a long time listener of the Python Bytes podcast (paused it at the moment because I do less Python), so I was very interested in reading Brian's pytest book.

Containing more than 250 pages, it covers a wide array of topics around testing, and not only specific to the pytest framework. The author provides a small project with which to iterate adding all kind of tests and configurations: unit testing, integration testing, coverage, tox (including how to use it from Github Actions), debugging via pdb, virtual environments, how to install pytest plugins, ...

Having a chapter dedicated to configuration is really good, helps a lot to have all the files and formats you can configure pytest with in a single place, so you can compare and decide which one suits you best. And during our read, we will find that it is full of good practices and tips, like the author’s method of feature prioritization, based on 5 factors, to decide what to test first or to test more in depth, or how to structure your code, or advices on how and what to test. Everything using clear explanations and simple yet effective examples.

If I had to mention something that could be improved, I can only think about the mocking chapter. Considering that mock testing is a quite important pillar, chapter 10 feels a bit short. It doesn't explains too much the topic, at least compared with other chapters where we get a detailed introduction of what we will be using. And the example of mocking is a bit uncommon, albeit understandable in the sense that in the sample code the API layer is really thin. I would have prioritized testing the business layer (API layer here) before the presentation layer (CLI here), as that would contain all business logic and often use other services and objects, but I get that the example project is better suited for CLI unit tests with a mocked API. I advise to also read realpython.com's tutorial about the mock library if you want a deep dive into mocking in Python.

I’ve used pytest for a few years and yet I learned some new tricks and details here and there, plus I reinforced my knowledge of other areas like parametrization and fixtures. I really liked the content and I prefer using pytest over unittest, so I totally recommended this book to anyone interested in testing in Python.

Course Review: Kubernetes - The Documentary

When I saw at LinkedIn Learning a course titled Kubernetes: The Documentary it surely sparked my curiosity. After watching it, the name says it all: this is not a course at all, it is a very light documentary. And despite its 55 minutes of duration, it is way longer than it should.

"History is written by the winners" they say. You'll learn that Docker revolutionized the tech world by providing everyone with an easy to use container system, and that the next step was container orchestration. Three contestants (Docker Swarm, Mesos and Kubernetes)... and a long sequence of interviews about how hard it was to do it, how much effort the original team put on building K8s, and how amazing it was since it was announced and released and exploded in popularity. And how it has conquered the world (as of 2022), of course. But, if I'm correct, there is a single mention of what made Kubernetes better than the other contestants. Apart from the fact that it came from Google.

Don't get me wrong, it is still interesting, but I was expecting more information about how it compared with the others, and based on the documentary looks like mostly because it was from Google and, done with hard work (probably also the case for the folks building Docker Swarm!). High production values but shallow.

Course Review: Building with Bazel

Building with Bazel, from Ray Wenderlich, is a free 90 minutes course to learn about Bazel, the build system that Google open-sourced around 2016 and that it is as powerful as initially complex to learn. During the course we'll learn the basic concepts: Workspaces, build files, actions, rules, what is the Starlark language, running tests... All of them via basic but easy to understand examples. We'll also get briefly introduced to distributed builds.

It is a brief but good overview, you can't beat the price, and really can't complain about missing contents. But if I could improve something, the focus on Android and iOS systems doesn't covers the full picture. That said, it is also true that Bazel support for web, at least as of late 2022, feels still quite beta, having to rely a lot on Aspect rule-sets instead of on the built-ins (especially if you use Typescript).

Audiobook Review: Algorithms at Work


Algorithms at Work audiobook cover

Title: Algorithms at Work

Author(s): Brian Christian, Tom Griffiths

With around 5 hours of content, with this audiobook we'll learn about the following topics:

  • Distributed systems
  • Queueing theory
  • Concurrency & coordination
  • Consensus algorithms (Paxos & Raft)
  • Networks & hierarchies, including decentralized network structures
  • Action & reaction (game theory)

The selection is quite nice, but what I liked most is that each topic is presented with very easy to understand real world examples. Sometimes there are also purely technical explanations, but for example learning about game theory with a professional poker player, or about distributed systems with how the CERN manages multi-year and insanely huge data projects, while coordinating thousands of scientists, feels really refreshing and very interesting and different.

It doesn't covers everything, choosing instead in some topics a fragment and zooming in, but it felt like a nice refresher compared with a more traditional Distributed Systems book. And in fact I learned new things, like the Stackelberg competition model.

Previous entries