Bart Dorlandt

@dreamnetworking.nl

(Network) automation above all

As a first in the pydantic series, let's start with the basics. The goal of the whole series is to be able to validate the model as well as being able to generate the same json as the input, to verify we didn't miss anything.

Bild

I've working on parsing a json structure into a pydantic model. I'm planning to write a couple of posts on this. Is this something you've been playing with? Anything specific you ran into? Perhaps I could write about something specific if you have certain interests. Please let me know.

Bild

Poetry had a new release recently, version 2.0. Given the number, this means stuff broke ;) E.g. the poetry shell command is no more. The pyproject.toml is updated and now supporting the project header. (PEP 621) This also meant I had to update my ansible role for poetry (bartdorlandt.poetry).

Bild

Wouldn't it be great if Apple had a decent fix for the #notch on the Macs... Every time I have the Mac disconnected from the external monitor I'm annoyed by it. This time it was enough and I started looking into "fixing" it.

BildBildBild

Another beautiful feature of #task is to include other taskfiles. Especially to have them OS specific where desired. Just include the desired #taskfile. Use `{{OS}}` to make it dynamic, allowing variables or tasks to be OS dependent. Useful for developing on Mac and running on Linux (or pipelines)

BildBildBild

Depending on the pipeline system you're using, you might need to specify the commands to be executed yourself (jenkins, gitlab, ...) Hang on... You just created that beautiful #taskfile to make your life easier... Why not make your pipeline easier, by just executing your tasks...

BildBild

Using parallelisation without thinking! That is what you can achieve with the `deps` keyword in #task. See the example on how to run your #python lint, scan and test in parallel by just running `task check`. No complications, just actions!

Bild

You are expanding your #taskfile and realise that there a couple of tasks with dependencies on a build process. Though you don't want to rebuild it, if nothing changed. #Task got you covered! Using sources and generates to monitor the source files and if the generated file exists.

Bild

How to deal with #task when needing a dynamic variable or one that is stored in a file or from the output of another command... Variables can be assigned using the 'sh' key when assigned a variable. Allowing you to assign the output of any shell command. Lovely

Bild

As mentioned in my previous post, occasionally you'll need to execute a command in multiple directory or differently said, need to execute a #task multiple times. Which may involve directories, files or any action essentially. A for loop is what we need 😀

Bild

You need to run a command for some sub-directories of your project... Doing this with make, you'd need to manually put your logic in to jump back up a dir. No thinking required with #task. Just add an entry to the array, it always starts from the #taskfile location.

Bild

You have this beautiful #Taskfile helping you out. Though some systems use exec1 for a certain task, while the other use exec2. A concrete example could be 'docker-compose' vs 'docker compose'. Here is a way of working with that. ❯ task a -n task: [a] docker compose --help

Bild

The debug capability in vscode/pycharm is great! I can't imagine people debug without it. I still see too many people not using the watch feature though. It is so nice to just have a few things in focus while diving in. Here is my recommendation to check it out, if you aren't using it full time yet

Bild

Did you ever run into a #python project which you wanted to debug, but your breakpoints weren't respected... I had this the other day, having a project with pytest and pytest-cov. Apparently this messes up vscode. Mainly pytest-cov is the blocker. Try this for your launch.json.

Bild