Cancellation Token Pattern in Python

Hello! 👋 The Cancellation Token Pattern article is a pattern inspired by C#’s CancellationToken struct and Golang’s context package. The main idea of the pattern is to allow the user of an API to cancel its operations, but in order for this pattern to work, the API must be written with the cancellation token pattern in mind. To use the pattern, you need a class that represents a cancellation token. Here’s my simple version:...

March 9, 2024 · 3 min · Denis Nutiu

Idempotency in Your API

Introduction Idempotency is a crucial property in the world of APIs, ensuring that operations can be applied multiple times without changing the result. In this post, we’ll explore six effective strategies to achieve idempotency in your API, drawing inspiration from real-world examples and distributed systems principles. Idempotency Explained The light switch analogy is often used to explain idempotence. Consider a light switch in a room. The operation of turning the light switch on or off is idempotent....

November 11, 2023 · 4 min · Denis Nutiu

Windows Task Scheduler - Quick Start

Introduction Hello everyone 👋, This is a quick post about the windows task scheduler, if you’re a Software Developer using Windows the task scheduler is a great tool to automate tasks. I see it as a combination of cron and systemd (if you’re a Linux user you know what I’m talking about). For my personal use case, I use the task scheduler to download more images from the internet to improve a machine learning model used to classify images....

November 11, 2023 · 3 min · Denis Nutiu

Project Showcase: Image Tagging

Hello there 👋, This is a showcase of a project I’ve been working on for the past weeks. It’s a simple cross-platform desktop application that allows you to tag images using a machine learning model that I’ve trained. It is written in C# using Avalonia UI, and it uses the FastAI library for the machine learning part, the model is then converted to ONNX. The application is available for Windows, Linux and MacOS....

September 12, 2023 · 1 min · Denis Nutiu

Tracing Node.js APIs with OpenTelemetry

Hello everyone 👋, In this article, we’ll instrument a simple Node.js API with OpenTelemetry traces. OpenTelemetry is the new standard for distributed tracing and metrics. Trace data is used to monitor and troubleshoot complex distributed systems. At the end of this article, we’ll have a Node.js API that is instrumented with OpenTelemetry and we’ll be able to see the traces in Grafana Tempo: The API Let’s start by setting up our NodeJS project by installing the dependencies:...

August 7, 2023 · 7 min · Denis Nutiu

Using an ONNX Resnet model in Java

Hello everyone! 👋 This is a follow-up post to the previous one, long story short I started taking the course from fast.ai to learn more about Deep Learning. I’ve built a simple Image Tagging model using the Resnet architecture (don’t worry about the paper I did not read it, GitHub Copilot suggested it while writing this blog post). FastAI is a high-level Python library that allows you to train complex ML models really fast and efficiently....

July 4, 2023 · 7 min · Denis Nutiu

Image tagging with Deep Learning

Hello everyone 👋, I’ve been playing with FastAI and deep learning for a week or so and I’ve decided to combine my passion for software with my passion for photography. I’m working on an app or maybe a library that allows you to generate tags for a photo. For an amateur photographer like me it’s quite useful as I don’t always have inspiration to write tags for my photos and sometimes the tags I write are inconsistent....

July 2, 2023 · 3 min · Denis Nutiu

Deploy a FastAI model with FastAPI

Hello everyone 👋, In this quick post I’ll show you how to deploy a FastAI model using FastAPI. It’s a follow-up to my previous post from here and it is partially based on this FastAI lecture: Exporting the Model Before we create the API, we need to export the model as a pickle file. Add learn.export("<path>/cat_or_dog.pkl") with the full absolute export path at the end of the script: # ... learn = vision_learner(dls, resnet34, metrics=error_rate) learn....

June 21, 2023 · 2 min · Denis Nutiu

FastAI GPU Support

Hello everyone 👋, This is my first blog post about AI, it’s a quick post on how to enable GPU support for the FastAI library. I have avoided getting into AI for some time now, I thought that it would involve lots of complicated math, and I was not sure that it would be worth the effort, I did not get very good grates in my college math classes 😅....

June 20, 2023 · 3 min · Denis Nutiu

Overflowing Buckets

Hello everyone 👋, Today I want to share with you a problem I’ve encountered along my journey. The problem is fairly simple: You have a finite number of water units. You have a finite number of buckets. You need to distribute the water units into the buckets. Each bucket has a maximum capacity. When a bucket is full, the water overflows into the next two buckets by splitting evenly. You need to print the number of the buckets that are full....

June 15, 2023 · 3 min · Denis Nutiu