Posts

Showing posts from October, 2021

Python Decorator for Azure App Insights

Image
Image by Andrea Piacquadio from pexels.com In enterprise solutions, we must create the log (traces) and performance tracking entries. This can be a complicated task, especially in a multi-service cloud environment. In this blog, we will show you how to do this with Python decorator writing traces to Azure Application Insights . Azure Application Insights is the Azure de facto resource for telemetry, monitoring, observability. Traces, exceptions, event logs, etc. are captured in App Insights . And, it provides a very comprehensive query language, Kusto Query Language (KQL). Python is the primary programming language for Azure Machine Learning (AML) . There are a lot of samples and documents on Python SDK for AML .  Even Guido van Rossum came out of retirement to join Microsoft. ( Creator of Python joins Microsoft, prompting speculation ) With these ( Python &  Azure App Insights ) said, let's get to the core of this blog. Here we have a very tiny Azure Function written in

My First Encounter with Azure Durable Function

Image
pexels image from Arina Krasnikova Recently, I need to have an orchestrator in Azure Function App to monitor the status of a long-running job. Azure Duration Function comes in handy. In this blog, I am going to simplify the use case to focus solely on how Duration Function works.  User Case: A long-running job is executed and we need to monitor its status and log this status in a database. Referencing the diagram above. This is where the Duration Function is executed. (A) fx is an  Azure Function where the job is started. Following that, it makes a IDurableOrchestrationClient.StartNewAsync call to start a new Duration Function . We have the Job-Id and the expiration time in the context of this function. Essentially, Duration Function is an internal HTTP endpoint in Azure Function App . It looks like this [FunctionName("JobMonitoring")] public async Task RunMonitor( [OrchestrationTrigger] IDurableOrchestrationContext context) { ... } (B) Here

A Novel written by friend

Image
  Corinth 2642 AD A few days back, I have finished reading this novel . As a matter of fact, this is the first one that is written by a friend. Interestingly, the kind of feeling is completely different when reading a novel that is written by a friend. (Not giving out too much away about this novel). Do you think mother Earth is still habitable in the future? How is life is going to be like? How do people travel?  This novel is written by a former defense can aerospace journalist. I get a sense of how it is going to be like in the future. I have learned to treasure what I have now, especially our nicely bound books. By the way, my family members treasure books a lot. We plastic wrap our books (you may be able to tell from the picture above), no dog ears, do not press hard on the spine of the books and handle them with clean hands.  When I was reading this novel (and I am going to read it again), apart from fascinating with the author's imaginations on how the future will be like,

Back to Office After 18 months of working from home

Image
  After 18 months of working from home, I have the opportunity to return to campus today. Actually, I have never step into this campus yet. During the pandemic, we have moved to a newly constructed campus at Mountain View, California. My colleague was so kind to get me a tour, and I am impressed. It is beautiful. Words cannot describe the kind of feeling that I have when I was on campus after working from home for more than 18 months. I have lunch with my team, and my manager brought us delicious homemade vegetarian biryani. :-) Everything on campus is great. My employee badge is activated, all my belongings are moved (from the old office), and the opportunity to meet face-to-face with my teammates.

Google Translate Python API

Image
  Images by Christina Morillo from pexels.com There are many translation services, and Google 's is one of the most commonly used services. Let's try out its Python API . The package is googletrans . The documentation can be found at py-googletrans.pdf . Supported Languages import googletrans print(googletrans.LANGUAGES) print(len(googletrans.LANGUAGES)) lists 107 supported languages. Language Detection from googletrans import Translator translator = Translator() english_text = "Tyson Fury got up twice from the canvas to win it." dt_en = translator.detect(english_text) print(dt_en) gives us Detected(lang=en, confidence=1) translator = Translator() japanese_text = "タイソンフューリーはそれを獲得するためにキャンバスから2回起きました." dt_ja = translator.detect(japanese_text) print(dt_ja) gives us Detected(lang=ja, confidence=1) These are too easy for googletrans :-) Let's try more complicated things. translator = Translator() mixed_text = ( "タイソンフューリーはそれを獲得するためにキャンバスから2回起きまし

Generating Test Data with Faker

Image
Images by kevin-ku-92347 from pexels.com Very often, we need to generate test data for testing purposes. I use Faker quite a bit since I am working on Machine Learning and Data Science projects often. Unfortunately, I ended up having to rewrite code with it to generate data for different projects. I have the aspiration to write a wrapper around it that allows me to generate different data for each column in a pandas' DataFrame. I was procrastinating on this idea for years now, and I have decided to put an end to it. So, it is the inception of a Faker-enabled Data Generator, FDG . MVP A definition file to define the column names, and the kind of data that we wish to generate. A list of column names and what is the faker function to call for each column. A list of rows definition Number of rows to generate (count) locale (optional, Defaults to "en_US") seed (optional) - this is useful if we want to generate the same set of data from each run. columns (optional) - any colum