<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Indrajit on Medium]]></title>
        <description><![CDATA[Stories by Indrajit on Medium]]></description>
        <link>https://medium.com/@rtindru?source=rss-1d1f14299d12------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*GEaSv6tjLX2DVStWKXNpmg.jpeg</url>
            <title>Stories by Indrajit on Medium</title>
            <link>https://medium.com/@rtindru?source=rss-1d1f14299d12------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 21:45:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rtindru/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From pandas  to production ]]></title>
            <link>https://rtindru.medium.com/from-pandas-to-production-e437354ce6dd?source=rss-1d1f14299d12------2</link>
            <guid isPermaLink="false">https://medium.com/p/e437354ce6dd</guid>
            <category><![CDATA[jupyter-notebook]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[mlops]]></category>
            <dc:creator><![CDATA[Indrajit]]></dc:creator>
            <pubDate>Fri, 29 Apr 2022 06:45:06 GMT</pubDate>
            <atom:updated>2022-04-29T23:57:13.679Z</atom:updated>
            <content:encoded><![CDATA[<h4>A step-by-step tutorial to turn your Jupyter ML model into a production-grade machine learning API</h4><p>Running a production-grade machine learning API service is not easy work. Data scientists are experts at developing machine learning models using the typical data science toolbox, i.e. numpy, pandas, scikit-learn to name a few. However, deploying this model to production and exposing it as an API service requires a different set of tools and skills.</p><p>Companies who’s core product is an API have a specialized API engineer roles. API engineers are software engineers who are experienced in developing, maintaining, updating, and optimizing their APIs. Infrastructure engineers are another specialized group of engineers who provision and maintain the cloud infrastructure, i.e. servers, databases, and such, used to serve these APIs. Over the years, product and infrastructure engineers have developed best practices for serving backend services via APIs, most popularly via REST.</p><p>Data scientists can train highly performant ML models using curated datasets on offline python notebooks. The next challenge is in deploying these models to production. Deploying a model consists of numerous steps starting with feature pipelines for online predictions, running the models online to serve predictions using REST APIs, monitoring the API performance, monitoring the health of the underlying servers that run these models, logging requests, responses, predictions, handling errors gracefully, and scaling to meet elastic demand.</p><p>Of course, not all companies may want to hire specialized teams of engineers to go from pandas to production. In this article, I demystify the work required to take an ML model from a Jupyter notebook and build a scaleable maintainable highly performant REST API around it. My hope is that this empowers Data Scientists to deploy and maintain machine learning APIs at scale.</p><h3>1. The ML Model</h3><p>I will use the example of a sentiment analysis model to illustrate these steps. The machine learning problem formulation is quite simple: given a blob of text, detect if the sentiment is positive, somewhat positive, neutral, somewhat negative, or negative.</p><p>We might start by training a machine learning model to do these predictions. I am using <a href="https://www.kaggle.com/shyambhu/sentiment-classification-using-lstm/data">a model trained by Shambu Mukherjee</a> on Kaggle that performs sentiment analysis on a movie reviews dataset.</p><p>Running the notebook, it is easy to train an ML model on the training dataset and run offline inference on a batch of data in the test set. However, machine learning models have very different performance requirements on serving time. These are the kinds of challenges that we will explore in this article.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/53fb4dcde32f3263cf9202e5e3f73bac/href">https://medium.com/media/53fb4dcde32f3263cf9202e5e3f73bac/href</a></iframe><h3>2. API service contract</h3><p>I will be using a model serving framework called BentoML in this notebook. There are many other options for serving ML models in production such as Tensorflow Serving, MLFlow, Kubeflow, and TorchServe to name a few.</p><p>The first step is to define the end-user of this API contract which will be exposed to end users through our service. The goal of the contract is to define the expected input and output format for the API.</p><p>Here’s an example of what that could look like for our sentiment analysis example. I have chosen to implement a bulk inference API, i.e. the user can submit one or more sentiment analysis requests at once. Hence, the expected input is a list of strings. Each string represents a user input that we will run sentiment analysis on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dX5HE0aybey_HcFZfXnFpQ.png" /><figcaption>Send a request to our model API server. This UI is auto-generated by BentoML using swagger</figcaption></figure><p>And here’s the response from our API server. The output is a list of JSON objects with the keys sentiment_score, sentiment, and the text. The indices of the output correspond 1:1 to the indices of the input text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bFvQpeP8vC7hhUe9az3JbQ.png" /><figcaption>API Response from our model server with the predicted sentiment score</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e1d633c6c6ac51cb92396ff20d1c515/href">https://medium.com/media/9e1d633c6c6ac51cb92396ff20d1c515/href</a></iframe><h3>3. Package the model service with Docker</h3><p>This step packages the model service with the trained model from step 1. After we package the API service with the model, we are ready to start serving some requests.</p><p>One common way of distributing this model API server for production deployment, is via Docker containers. And BentoML provides a convenient way to do that.</p><p>Once the model is packaged into an API service, we can start a REST API model server with the BentoService saved above to serve the model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/78dc5c34a17235914f7e689e3f3d5cc8/href">https://medium.com/media/78dc5c34a17235914f7e689e3f3d5cc8/href</a></iframe><h3>4. Error Handling</h3><p>Now that I have a skeleton service in place, I might want to know when my service encounters errors. A good next step would be to use a error monitoring service such as Sentry.io. Sentry provides an easy to use python SDK that can capture runtime errors in the service and display a full stack trace of the error in a nice web UI.</p><p>I have modified the service to deliberately raise an error to illustrate the sentry integration. When I make a request to this service, I expect to get an error response from the API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FmJgFaosMMtMYeYw_Gf-dg.png" /><figcaption>Error response from the API</figcaption></figure><p>Here’s what the error looks like on sentry. You can see a full stack trace of the error below. Sentry is also able to display local variables from the error execution context, which would make it easy to debug issues with input data, for example when the user inputs unexpected or unsupported data formats.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mqVC5zhAFjjyL-XqWlsdOQ.png" /><figcaption>Sentry has captured the error and is displaying the error stack trace along with local variables</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8dbeeaddc473b11a09ae27ce84e442bf/href">https://medium.com/media/8dbeeaddc473b11a09ae27ce84e442bf/href</a></iframe><h3>5. Measure Latency and Throughput</h3><p>Now that the API service is deployed, I would want to start measuring myAPI performance next. Latency and Throughput are two important API metrics that are useful to measure.</p><p>Latency is a measure of how soon can I get my predictions after I send it to my server. It is usually measured in milliseconds. A latency of 150ms to 300ms is generally considered good for web services. However, the latency of a machine learning API will depend on a number of factors such as the kind of inference task being performed, the input batch size, the depth and complexity of the machine learning model, .e.t.c.</p><p>Throughput is a measure of how many API requests the web service can handle concurrently. It is generally measured in requests per second or minute.</p><p>In my example, I plan to use <a href="https://prometheus.io/">Prometheus</a> to instrument latency for our machine learning API. <a href="https://github.com/prometheus">Prometheus</a> is an open-source systems monitoring and alerting toolkit originally built at <a href="https://soundcloud.com/">SoundCloud</a>.</p><p>Let’s modify our API service to measure API latency. We can do this by instrumenting a <a href="https://prometheus.io/docs/concepts/metric_types/#summary">Summary</a> metric on Prometheus to measure the request time for each API request. The summary metric measures both the sum and count of the metric, which can be used to generate average latency and measure quantiles such as <a href="https://howtodiscuss.com/t/what-is-p95/71449">p99 and p95</a> latency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YC0ysyt0Dl5OKGsg84_zkw.png" /><figcaption>Graph showing average latency of</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3FlCjx7psrMa8LcLHqR9PA.png" /><figcaption>Graph showing average latency of the API service in a 1m sliding window</figcaption></figure><p>Prometheus also comes with a few metrics out-of-the-box such as process_cpu_seconds_total, which is an aggregate measure of the total cpu cycles consumed by the API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KzZQYD5PrqXhjBX9FDbiGg.png" /><figcaption>Graph showing total CPU usage by the API server</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/10724f1f422722e30ffc5c5371759c39/href">https://medium.com/media/10724f1f422722e30ffc5c5371759c39/href</a></iframe><h3>6. Instrument custom metrics</h3><p>While metrics such as latency and throughput are standard for web services, I may also be interested in instrumenting domain specific metrics. For example, since our API performs inference on a batch of texts, it might be useful to measure the average length of the texts array for each API request. I can measure this metric by instrumenting a custom summary metric to measure the length of the texts array for each request.</p><p>After instrumenting this request_text_len summary metric, I can use the request_text_len_sum and request_text_len_count variables to plot the average API request text length over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9JeX-_IWm0krXIdFpNaUJw.png" /><figcaption>Graph showing the average API request text length over time</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cff23f885ea3773f811a179ff4639648/href">https://medium.com/media/cff23f885ea3773f811a179ff4639648/href</a></iframe><h3>Let’s recap the frameworks and why we used them</h3><p><a href="https://github.com/bentoml/BentoML"><strong>BentoML</strong></a><strong> for model API serving</strong><br>BentoML is a python framework that makes it super easy to move your ML models as web APIs, so that your users can send data to a web URL and get the predictions of your model as the response!</p><blockquote>BentoML is a framework for serving, managing, and deploying machine learning models. It is aiming to bridge the gap between Data Science and DevOps, and enable teams to deliver prediction services in a fast, repeatable, and scalable way.</blockquote><h4><a href="https://sentry.io/welcome/"><strong>Sentry</strong></a><strong> for monitoring errors</strong></h4><p>The sentry python client is an excellent choice to set up alerts for any unknown errors that might be breaking your API service.</p><blockquote>From error tracking to performance monitoring, developers can see what actually matters, solve quicker, and learn continuously about their applications — from the frontend to the backend.</blockquote><h4>Prometheus for monitoring performance and metrics</h4><p>Designed by <a href="https://soundcloud.com/">SoundCloud</a> to be an open-source monitoring and alerting system, Prometheus is a real-time, time-series database with a robust query language designed to provide aggregate insights from data series while they are collected.</p><p>Here’s the github repository with the jupyter notebook and all the code</p><p><a href="https://github.com/rtindru/pandas_to_production/">GitHub - rtindru/pandas_to_production: What it takes to take to ship an ML model service from a python notebook to a production-grade API</a></p><p>Let me know if you have any comments: <a href="https://www.linkedin.com/in/rtindru/">LinkedIn</a> | <a href="https://twitter.com/rtindru">Twitter</a>: @rtindru</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e437354ce6dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Designing a Python Middleware API Client]]></title>
            <link>https://rtindru.medium.com/python-middleware-api-client-design-patterns-7c4261ecff88?source=rss-1d1f14299d12------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c4261ecff88</guid>
            <category><![CDATA[data-pipeline]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Indrajit]]></dc:creator>
            <pubDate>Mon, 17 May 2021 01:51:13 GMT</pubDate>
            <atom:updated>2021-06-10T20:00:38.553Z</atom:updated>
            <content:encoded><![CDATA[<h4>Design Patterns for Filtering and Wrapping objects</h4><p>In this article, I will be sharing a few real-world design patterns for creating middleware API clients in Python. There are two kinds of interface design patterns I will be sharing examples for two kinds of patterns:</p><ol><li><strong>Patterns for “querying” or “filtering” data</strong> — how do we want the end-user to search for information?</li><li><strong>Patterns for “wrapping” objects</strong> — how do we want the end-user to access the information we serve them?</li></ol><figure><img alt="Python Middleware API" src="https://cdn-images-1.medium.com/max/750/0*NvmSFoycRwSzNFLW" /></figure><blockquote>I wondered if there are any middleware API design best practices that I could learn from. Most of the API design documents on the internet seem to talk about REST or GraphQL Web API design. Although many of the best practices carry over from REST to Middleware, I was curious how other frameworks and libraries had solved this problem. Since I <a href="https://stackoverflow.com/questions/67203608/what-are-some-good-documents-to-read-for-non-web-api-design-for-api-clients-pla">couldn’t find any authoritative articles that spoke about Python API client design</a>, I decided to share my own insights and examples!</blockquote><p><strong>1. Filter Query Interface:</strong> A standard interface and query language for data querying that doesn’t require you to be a SQL pro.<br><strong>2. Wrapper objects</strong>: A set of middleware wrapper classes for abstracting away the complex DB schema, S3 storage details, and ultimately simplifying data access.</p><h3>Filter Query Interface</h3><h4>1) String filters</h4><p>The string paradigm is inspired by the <a href="https://github.com/pandas-dev/pandas/blob/master/pandas/core/frame.py#L3854">Pandas query method</a>, which allows users to type in queries as plain strings using proper syntax notation. The entire query is a string that contains the different subqueries and logical operators. Here’s an example of what that query looks like.</p><pre># Example of the string query patter in Pandas<br>df.query(“origin == ‘JFK’ &amp; carrier == ‘B6’”)</pre><pre>carrier_list = [&quot;B6&quot;, &quot;B7&quot;]</pre><pre>df.query(&#39;carrier == @carrier_list&#39;)</pre><p><strong>Advantages</strong></p><ol><li>Simple and intuitive for the end-user to pass queries.</li><li>Fast to type and query: no other classes or configs are needed to filter.</li><li>Pythonic syntax: we will use python syntax for binary operators like equals, greater, lesser, contains, e.t.c.</li><li>Can combine multiple filters using AND, OR, and other boolean logic.</li></ol><p><strong>Challenges</strong></p><ol><li>Parsing overhead: Supporting string-based querying requires us to establish grammar and use ASTs to parse the query string. This becomes evident when you look at <a href="https://github.com/pandas-dev/pandas/blob/b2a36bdf88f3b838099d77c00b1c102be80bfc6e/pandas/core/computation/eval.py#L164">Pandas’ implementation of the query method.</a></li><li>Type overhead: Typecasting, validation, and conversion for the values supplied inside the string.</li><li>Hard to use variables: since the query is entirely a string, it would be hard to query using runtime variables like “carrier_id = var_1”</li><li>Hard to query against collections like lists and tuples. Since we use strings, it would get tricky to do something like ”carrier_id in [1, 2, 3]”</li><li>Queryable fields are not explicitly declared → the user needs to know what fields are queryable.</li></ol><p><strong>2) List of Filter Dicts or Tuples</strong><br>This paradigm is inspired by <a href="https://pypi.org/project/sqlalchemy-filters/">SQLAlchemy Filters</a>, which uses a list of dicts to apply filters to the dataset. Each dict contains the field name to query by, the operator, and the value to query against.</p><pre># Example of the list of dict pattern in SQLAlchemy Filter<br>filter_spec = [<br> {‘field’: ‘name’, ‘op’: ‘==’, ‘value’: ‘name_1’},<br> {‘field’: ‘age’, ‘op’: ‘in’, ‘value’: (1, 2, 3)},<br>]<br>filtered_query = apply_filters(query, filter_spec)</pre><pre>filter_spec = [<br>    {<br>        &#39;or&#39;: [<br>            {<br>                &#39;and&#39;: [<br>                    {&#39;field&#39;: &#39;field_name&#39;, &#39;op&#39;: &#39;==&#39;, &#39;value&#39;: &#39;field_value&#39;},<br>                    {&#39;field&#39;: &#39;field_2_name&#39;, &#39;op&#39;: &#39;!=&#39;, &#39;value&#39;: &#39;field_2_value&#39;},<br>                ]<br>            },<br>            {<br>                &#39;not&#39;: [<br>                    {&#39;field&#39;: &#39;field_3_name&#39;, &#39;op&#39;: &#39;==&#39;, &#39;value&#39;: &#39;field_3_value&#39;}<br>                ]<br>            },<br>        ],<br>    }<br>]</pre><p><strong>Advantages</strong></p><ol><li>Easy parsing: Easy to validated the operands and operators.</li><li>No type conversions: Data types are preserved.</li><li>Variables can be passed through easily to filter value.</li><li>Easy to pass collections like sets and lists into the filter value.</li></ol><p><strong>Disadvantages</strong></p><ol><li>Verbose: Difficult to type and to use.</li><li>Hard combine filters using boolean logic. All filters are applied using AND logic as a list. We could allow nested declarations to allow boolean logic but it is very confusing to read and use.</li></ol><p><strong>3) Filter Kwargs</strong><br>The <a href="https://docs.djangoproject.com/en/3.2/ref/models/querysets/#field-lookups">Django ORM uses this pattern for field lookups</a> while querying the database. The idea is to use flat kwrags or a kwarg dict to query the data, where the kwarg field names correspond to the field being queried. For advanced operations such as contains in list, or greater than or equal, we modify the field names to include an operand suffix by convention. For example, querying for the field `height` greater than or equal to180cms would be height__gte=180.Here’s what that looks like</p><pre># Django ORM query example<br>q1.exclude(pub_date__gte=datetime.date.today(), pub_id__in=[1, 2, 3])</pre><p><strong>Advantages</strong></p><ol><li>Easy to type and use quickly</li><li>Easy to pass variables, lists, and maintain type names</li><li>Pythonic → can use kwargs dict for filters</li></ol><p><strong>Disadvantages</strong></p><ol><li>Requires conventions for operators like greater than __gt, contains __in, not equals __ne, e.t.c</li><li>Hard to combine multiple filters using boolean logic (AND/OR)</li></ol><p><strong>4. Filter Chaining</strong></p><p>Method chaining is a <a href="https://towardsdatascience.com/the-unreasonable-effectiveness-of-method-chaining-in-pandas-15c2109e3c69">popular implementation in many frameworks like Pandas and Spark</a>.</p><pre># Example from Pandas<br>wine = pd.DataFrame(data.data)<br> .query(“alcohol &gt; 14”)<br> .query(“color_filter == 1”)<br> .sort_values(“alcohol”, ascending=False)</pre><p><a href="https://mail.python.org/pipermail/python-dev/2003-October/038855.html">Unfortunately, Guido, the BDFL of Python, considers this pattern unpythonic.</a></p><p><strong>Advantages</strong></p><ol><li>Chaining gives the end-user flexibility in querying the data in different ways while retaining control of business logic.</li><li>Each .custom_filter method can implement custom business logic, for example, the filter_timestampmethod could implement set a default start and end time, or a default timezone.</li><li>The filter methods could be shared between interfaces through mixins or class inheritance.</li></ol><p><strong>Disadvantages</strong></p><ol><li>Order of filtering may become an issue in some cases.</li><li>Usage of the .filter across the codebase could get inconsistent.</li><li>We cannot control the .filter usage tightly — with great flexibility comes great loss of control.</li><li>Users can chain filters ad-infinitum, which could result in a codebase that is splattered with .filter(x).filter(y). Using this patter would make it hard for us to make changes to the Python Client API, and hard to debug and ensure predictability of results.</li></ol><p><strong>5. Custom method for frequent queries</strong></p><p>This approach stems from the principle of 80/20, 80% of the data access queries are for 20% of the query parameters. What if we could create custom methods to filter by frequently used parameters.</p><pre>q.get_wine_by_color_abv(abv=17, color=&#39;red&#39;)</pre><p><strong>Advantages</strong></p><ol><li>Exposes a fixed limited API to the end-user → better for maintainability of the codebase.</li><li>Simpler to use for the frequently queried data.</li><li>Simpler to implement.</li></ol><p><strong>Disadvantages</strong></p><ol><li>Rigid interface: Filters results cannot be combined.</li><li>Could lead to a large number of custom methods on the query interface.</li><li>Limited functionality: if a custom method does not exist, the end-user needs to go to the database.</li></ol><h3><strong>Wrapper objects</strong></h3><p>The goal of middleware wrapper objects is to present a simplified end-interface for interacting with objects while hiding the complexity of the underlying data stores. I like to think of wrapper objects as a super-smart personal assistant. When you request a dinner reservation, and the assistant will know to look up the restaurant’s contact info, call them up, make a reservation, and share the confirmation with you. The wrapper classes do something similar when the end-user says get_data</p><p>The question of wrapping objects is a simple one: how do we expose attributes from the underlying object on the top-level wrapper? Here are a few options I explored:</p><p><strong>1) List/Dict Mapping</strong></p><p>This idea is inspired by the field declarations used in <a href="https://docs.djangoproject.com/en/3.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.fields">the Django Admin class</a> and <a href="https://docs.djangoproject.com/en/3.2/topics/forms/modelforms/#django.forms.ModelForm">Django ModelForms</a>. These frameworks use a list of field names to create a form based on the underlying field types. The example below shows how we could expose fields on the wrapper object using a dict or list mapping.</p><pre><strong>class</strong> <strong>Author</strong>(object):<br>    name = models.CharField(max_length=100)<br>    title = models.CharField(max_length=3, choices=TITLE_CHOICES)<br>    birth_date = models.DateField(blank=<strong>True</strong>, null=<strong>True</strong>)<br><br><br><strong>class</strong> <strong>AuthorWrapper</strong>(object):<br>    fields = [&#39;name&#39;, &#39;title&#39;, &#39;birth_date&#39;]</pre><pre><br>    def __init__(self, obj):<br>        for f in self.fields:<br>            val = getattr(obj, f)<br>            setattr(self, f, val)</pre><p><strong>2) Explicit Field declarations</strong></p><p>This is also inspired by Django From, Admin, and <a href="https://www.django-rest-framework.org/api-guide/serializers/#modelserializer">Django Rest Framework Serializer</a> class declarations.</p><pre># Object to be wrapped in a serializer<br>class Comment:<br>    def __init__(self, email, content, created=None):<br>        self.email = email<br>        self.content = content<br>        self.created = created or datetime.now() </pre><pre># Wrapper class with explicit field declarations<br>class CommentSerializer(serializers.Serializer): <br>    email_id = serializers.EmailField(source=&#39;email&#39;)  # supports renaming<br>    content = serializers.CharField(max_length=200)<br>    created = serializers.DateTimeField()</pre><p>Here, we need to explicitly declare the fieldset on the wrapper classes. The advantage of this method is that it allows customization and more framework magic via a set of Field classes for various field types. The disadvantage is that it does not reduce boilerplate significantly.</p><h3>3) Property declaration</h3><p>The third option was to define every field using getters or python properties. This would be super explicit and flexible, although we would not save any boilerplate by doing so. Nothing precludes us from doing this in combination with the dict config.</p><pre><strong>class</strong> <strong>Author</strong>(object):<br>    name = models.CharField(max_length=100)<br>    title = models.CharField(max_length=3, choices=TITLE_CHOICES)<br>    birth_date = models.DateField(blank=<strong>True</strong>, null=<strong>True</strong>)<br><br><br><strong>class</strong> <strong>AuthorWrapper</strong>(object):</pre><pre>    def __init__(self, obj):<br>        self.obj = obj  # The wrapped obj</pre><pre>    def get_name(self):<br>        return self.obj.name</pre><pre>    def set_name(self, name):<br>        self.obj.name = name</pre><pre>    name = property(get_name, set_name)</pre><p>Thank you for taking a look at this, I hope these patterns help you in designing great middleware. I welcome edits, suggestions, and any additional ideas you might have!</p><h4>Related Reading</h4><ul><li><a href="https://martinfowler.com/bliki/FluentInterface.html">bliki: FluentInterface</a></li><li><a href="https://python-patterns.guide/gang-of-four/decorator-pattern/#the-decorator-pattern">The Decorator Pattern</a></li><li><a href="https://en.wikipedia.org/wiki/Fluent_interface#Implementation">Fluent interface - Wikipedia</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c4261ecff88" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Three product lessons that could make you a better developer]]></title>
            <link>https://rtindru.medium.com/three-product-lessons-that-could-make-you-a-better-developer-348c0de79c95?source=rss-1d1f14299d12------2</link>
            <guid isPermaLink="false">https://medium.com/p/348c0de79c95</guid>
            <category><![CDATA[skills-development]]></category>
            <category><![CDATA[insights]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[product-management]]></category>
            <dc:creator><![CDATA[Indrajit]]></dc:creator>
            <pubDate>Thu, 18 Feb 2021 06:12:55 GMT</pubDate>
            <atom:updated>2021-02-18T06:21:18.273Z</atom:updated>
            <content:encoded><![CDATA[<h3>Three product insights that could make you a better developer</h3><h4>Sharing my reflections and learnings after working for three years in product management.</h4><p>In 2018, I decided to move from a lead software engineer role to dive into product management. After three years of building and shipping products, I had a chance to reflect on some of the key challenges I’ve had to overcome to excel in my new role. In addition to being a better PM, I think these insights have helped me be a better developer. I thought I’d share my insights and takeaways, in case they help you!</p><h3>#1) Winners take more shots on goal — how I learned to create and share small things of value.</h3><p>I woke up this morning both delighted and surprised. I had received a Youtube comment notification. I was obsessed with improving my productivity in early 2018 and I watched numerous self-help videos on Youtube. As someone obsessed with productivity, I was eager to cut through the intro and get to the insights. So I decided to timestamp these videos and make it easier for myself and others to get to the insights. I left a comment that summarised the key insights and created timestamps for viewers to skip to the right part of the video. Since creating these comments, I’ve noticed thousands of viewers like and hundreds thank me for making their life easier; except muxaffar, he thinks I am wasting my time, haha!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/0*VGQl8sSfqZNHIIzQ" /><figcaption>Timestamps for self-help videos</figcaption></figure><p>Many successful startup founders have a simple idea for entrepreneurs to → <em>keep creating small things of value and put them out there to get feedback from the market</em>. You will be surprised at how much people value your work and delighted by the long-tailed return on your investment. Many of us have interesting thoughts, insights, ideas, products, and code that we could be sharing with the world. It is a uniquely human trait to create things of value and share them, so why not get started!</p><h3>#2) Perfection isn’t always the goal — how I discovered the value of scrappiness and iteration.</h3><p>As an Engineer, I used to define success by shipping perfect code. When I say perfect, I mean simple, elegant, scalable, and bug-free code. I would get upset if the code I shipped caused production issues. I would get annoyed when I pointed out edge cases and my product manager said we could ignore them. I used to recommend that engineering teams always invest in good processes such as design documentation, API contracts, testing infrastructure, and code quality analysis. A quote that I loved to throw around was that engineers should spend 80% of their time in design and documentation, and 20% of their time writing code. I used to actively discouraged hacks and shortcuts. I wanted to deliver every project to perfection, my philosophy at work was “do it right”. However, through my product experience, I have discovered the value of scrappiness and iteration when solving a new problem. I understand the product manager’s obsession for launching MVPs and all the “ship it” memes. I discovered that there’s something worse than buggy code; perfect code that nobody uses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*sg_-ERDDy8Kdx9rY.png" /><figcaption>Progress over perfection!</figcaption></figure><p><strong>Word pun warning</strong>: Let’s segue to talk about Segway. Segway was an incredibly innovative product. When it was conceived and launched, it was way ahead of its time and pushed the boundaries of engineering and transportation. A scooter that could maintain its balance, zoom through pedestrian traffic, and be much more fuel-efficient than a car- what could go wrong? The company had spent over 100 million dollars to build and launch to market. There was just one problem: The world just wasn’t ready for it. There were issues with usability (people were scared by the self-balancing futuristic gizmo), feasibility (governments regulated against their use in public places), and viability (it was too expensive to be a mass-market personal transport vehicle). Perhaps the team should have launched a minimum viable product sooner, instead of launching a perfect product. In other words, it cost Segway $100 million and a huge investment of time and resources to fail. Wouldn’t it be better to have failed faster?</p><p>Perfection is not a good goal in novel situations. When you’re launching a new product, building a new business, solving a new customer problem, or designing a new process, perfection cannot be your primary goal. It cannot be your goal since you don’t know the rules of the game. You don’t know right from wrong, winning from losing. Instead, you want to find out what works, and discover the rules of the game through iteration and feedback. Build, Measure, Learn; value speed and output; iteration over perfection.</p><h3>3) Earn your insights — how to extract value from conversations by asking the right questions.</h3><p>When it comes to learning, developers have it easy — they’ve built incredible communities to share knowledge. Stackoverflow, Github, Medium articles, blog posts, code documentation, Pluralsight, and Youtube are some popular resources that developers use to learn about programming problems and solutions. Moreover, the developer community has invested time and energy in making these answers incredibly easy to search and access. As a developer, I grew comfortable knowing that the answer to all my problems was a quick Google search away, anytime, anyplace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*vBYN1uxFrct8d7oKyylAeg.png" /><figcaption>Ask, listen and learn!</figcaption></figure><p>Unfortunately, solutions to product problems are rarely a google search away. I had to quickly adapt to this new reality. The key challenge I faced in product was to state the problem in simple terms, which made it impossible for me to search for a solution. Also, since product problems are nuanced and contextual, there weren&#39;t any right or wrong answers. The product community relies on a plethora of frameworks and principles to abstract away these nuances. However, to apply these frameworks and principles successfully, I needed to understand the specific contexts in which they were applied successfully and unsuccessfully. All of this is to say that as a product manager, I couldn’t rely on Google in the same way I did as a developer.</p><p>When someone solves a product problem they learn through experience — we call this an “earned insight” in our organization. To uncover these insights, I knew I had to speak with other leaders. I had to ask the right questions to extract value through the conversations. There are lots of good articles on asking good open-ended questions, so I’ll refrain from describing that here. Instead, I want to emphasize the value of careful listening. I was surprised at how much I could learn from each conversation, so long as I asked good questions and listened carefully. Beyond the spoken word, I learned to read between the lines in a conversation. Over time, I started listening for, capturing, and sharing these insights with my team. I learned to value these insights more since they were earned and shared through experience. I realized that I could learn something of value from every single person I met, and in every conversation that I had, so long as I was intentional about it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=348c0de79c95" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Principles of Product Development]]></title>
            <link>https://rtindru.medium.com/principles-of-product-development-13d62e007896?source=rss-1d1f14299d12------2</link>
            <guid isPermaLink="false">https://medium.com/p/13d62e007896</guid>
            <category><![CDATA[lean-startup]]></category>
            <category><![CDATA[product]]></category>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[product-development]]></category>
            <dc:creator><![CDATA[Indrajit]]></dc:creator>
            <pubDate>Fri, 05 Feb 2021 03:08:56 GMT</pubDate>
            <atom:updated>2021-02-05T19:24:51.423Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to build and scale a great product culture at your organization</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ylDEfM0tHStmTARU.jpg" /></figure><h3>The Principles</h3><p>Here are the principles that I shared with my teams and stakeholders. Many of these ideas are inspired by Marty Cagan’s <a href="https://svpg.com/articles/">blog</a> and <a href="https://svpg.com/inspired-how-to-create-products-customers-love/">books</a>, <a href="https://www.intercom.com/resources/books/intercom-product-management">Intercom’s blog on Product</a>, and ideas from the <a href="http://theleanstartup.com/book">Lean Startup</a>. I hope you find this valuable in spreading the product culture in your organization. Leave a comment if you’d like to discuss these ideas further, I’d love to hear what you think!</p><ul><li><strong>We solve problems</strong>: We measure success based on problems solved. We work on products, not projects. Projects are all about output (did we ship the feature?) and Product is all about the outcome (did we solve the problem?).</li><li><strong>We are iterative</strong>: When new information surfaces, we are not afraid to change our plans. Our assumptions may be wrong, requirements could evolve, timelines could change. Updating our plans and communicating them is key. “<em>We don’t start with quality, we end up with it.” — Vince Huang.</em></li><li><strong>We like to ship value fast and frequently</strong> so that we deliver end-user value quickly, and get real user feedback. We endeavor to be creative and find the minimum viable product to ship. If we were building a car, we’d be happy to ship without the air-conditioning, however, we would NOT ship without the wheels.</li><li><strong>We ship incrementally:</strong> We prefer to ship in small incremental pieces, over one large release. Smaller releases are more efficient, predictable, and result in a higher quality of delivery.</li><li><strong>We tackle risks early:</strong> New problems, technologies, and solutions introduce risk. Our goal is to identify and tackle these risks early through prototype testing before we build the final product. We test our ideas through prototypes, surveys, false-door tests, A/B tests, and any other means of rapid testing.</li><li><strong>We work collaboratively, side-by-side:</strong> We need to bring Product, Design, Stakeholders, and Engineering to the table at the same time, not one after the other. <br>“In strong teams, product, design, and engineering work side by side, in a give‐and‐take way, to come up with technology‐powered solutions that our customers love and that work for our business.” — excerpt from Marty Cagan, INSPIRED.</li><li><strong>We validate our ideas early and frequently:</strong> Validate your solutions early and often. Most products fail because customer validation happens way too late, or after launch.</li><li><strong>We are focused: </strong>High utilization is not the same as high performance. We believe that fewer and focused projects will get done faster and better.</li><li><strong>We stay the course:</strong> There are two fundamental truths about Product Development that require us to stay the course in order to solve customer problems. The first truth is that at least half of our ideas are just not going to work. The second truth is that it takes several iterations to get the solution that solves the customer problem and delivers business value. We call that time-to-money.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3941y-KSg56iVigA.png" /></figure><h3>Communicating the process</h3><p>My goal was to get the product team and business teams to understand and internalize these principles. This meant that communicating this process effectively was super important. From past experience, I knew that it would not be enough to publish an internal document and expect the teams to read and understand. So I decided to use an active approach to drive engagement and discussion. I scheduled a meeting to discuss these principles and requested the product managers to bring examples from Springboard, or past project experiences to enrich the discussion. What followed was a great conversation and alignment within the product team. As a next step, we did the same with stakeholders outside the product team. We used examples of projects that we’d collaborated on to discuss whether we had or failed to apply some of these principles. This was a crucial step in beginning to build a great product culture in our organization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*MJzauKxCzBqYO2ke" /></figure><h3>Let’s talk about why</h3><p>I lead the product team at Springboard, an online learning bootcamp based out of the Silicon Valley. As our business grew, we hired a number of business and operations team leaders across the organization. Many of the new hires had not worked with product teams before, which made quarterly planning and cross-team collaboration a seriously (un)fun activity, LOL.</p><p>One of the important problems that every product leader needs to solve is scaling the product culture at their organization. A common joke in Product circles is that everybody defines the role of a product manager differently. Imagine what it is like for outside stakeholders and business team leaders. In order to collaborate across functions effectively, product managers have to explain how they work and how to work effectively with them.</p><p>I started to define and scale the product culture at our organization. The obvious answer to the scaling problem was introducing new processes. I don’t like processes that fail to explain why they exist. I believe that principles should precede processes. Starting with principles ensures that processes make sense when they are introduced.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13d62e007896" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>