PyTest, coverage reports and Gitlab runners

A friend of mine says that he doesn't need tests, he just writes bug-free code. Everyone thinks that his or her code is without bugs, while I think that a bunch of non-trivial amount of code almost definitely contains a bug or two, if not tested properly. And even then, one cannot be sure that no hidden bug lurks somewhere. I was not always like that. Once upon a time I too thought that testing is a waste of time. Why would you test something if you just know it works? Such is the current state in research, good software development practices are rarely followed and it is up to the few of us to try and force the good practices throughout the research organizations.

I am still learning about what can and should be done. Testing is one of the things I try to enforce with fellow researchers and students, when working on common projects. The other ones are: automation, documentation, and reproducibility. In this post I will describe our testing set-up I established. Since we work mainly with Python, we use popular PyTest framework for testing and the pytest-cov, a PyTest plug-in using coverage for measuring the code coverage of Python programs. After the test coverage report generation, the html report is uploaded to a self-hosted Minio instance for viewing.

Read more…

Mysterious nginx upstream errors

For easier web app deploy we use the following stack

  1. Ubuntu server
  2. Docker
  3. Containerized Nginx proxy with Letsencrypt companion
  4. Containerized Web app

Docker simplifies the web app development by enabling us, the developers, to pin the majority of the software dependencies versions, and, further, to have the exact same dependencies during development as for the deploy. This greatly reduces the "it works on my machine" moments. Those moments do not go away fully, because we usually do not specify the version of every last dependency used, however, they become really rare. One thing we do not test in development, though, is the web app operation when coupled with Nginx. And that sometimes leads to unexpected problems, such as the random upstream errors I will describe in next few lines.

Read more…

Python and tricky function arguments

Python allowed me to write several pieces of useful software using drastically smaller number of lines required at some other languages. My first programming steps were in Java, during the Introduction to programming course at the Faculty of Mathematics and Physics, Ljubljana. Java and I didn't get along well. I enjoyed the course but writing Java code didn't really inspire me. The second year, however, our tutors upgraded to Python. Now that felt pretty good. I felt much more comfortable writing small scripts in Python than Java and used Python and it's ecosystem in other courses as well. Python code, however, sometimes behaves in a way that seems buggy at first, unless you know what is happening.

Read more…

Hello world!

So here it goes, my first post on my first blog. The goal of this blog is to document the things I learn related to technology, software development, artificial intelligence, project management and soft skills. Occasionally I will add a thought or two about life in general.

Read more…