<?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 Gireesh Puthumana on Medium]]></title>
        <description><![CDATA[Stories by Gireesh Puthumana on Medium]]></description>
        <link>https://medium.com/@gireeshputhumana?source=rss-51d199e20097------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*7EljHx3aUVjgzixORAeKbA.jpeg</url>
            <title>Stories by Gireesh Puthumana on Medium</title>
            <link>https://medium.com/@gireeshputhumana?source=rss-51d199e20097------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 05:24:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gireeshputhumana/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[Thinking of ML on Snowpark? Think Refract by Fosfor!]]></title>
            <link>https://medium.com/@gireeshputhumana/thinking-of-ml-on-snowpark-think-refract-by-fosfor-cf8e54ad9221?source=rss-51d199e20097------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf8e54ad9221</guid>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[snowpark]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Gireesh Puthumana]]></dc:creator>
            <pubDate>Sun, 19 Feb 2023 18:26:05 GMT</pubDate>
            <atom:updated>2023-02-20T16:23:07.240Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why Snowpark?</h3><p>Snowflake has recently introduced <a href="https://www.snowflake.com/en/data-cloud/snowpark/">Snowpark</a>, the developer framework, that allows developers to write code in their preferred language and run that code directly on Snowflake. Developers can now use Snowpark APIs from their applications or even better — create UDFs or stored procedures that executes completely on the Snowflake server. This means a very big deal as you can see, the data stays in Snowflake and the code goes to it. Or as Snowflake says “Rather than moving between disparate systems, your data &amp; code lives in a single highly secured system”.</p><p>As shown in the short 2 mins video on <a href="https://www.snowflake.com/en/data-cloud/snowpark/">Snowpark</a> page, some sample workload that can be completely pushed to the Snowflake engine are: data augmentation, transformation, machine learning &amp; business logics. Of course these are very broad topics with lots of meats and potatoes within each. In this blog, let’s dig deep into the machine learning workloads and see how to do it most efficiently on Snowpark.</p><h3>Machine Learning on Snowpark</h3><p>The number of steps involved in a ML project lifecycle varies between enterprises and it is mostly influenced by the organization’s overall ML maturity &amp; the influence of internal or external governance bodies. But for the ease of this discussion, let’s consider the following as the most important &amp; common stages of an ML project.</p><ol><li>Exploratory data analysis</li><li>Data preparation</li><li>Model training</li><li>Model explanation</li><li>Scoring</li><li>Drift monitoring</li></ol><p>When we set out to do machine learning on Snowpark, it’s imperative to make sure all these critical steps are pushed to Snowpark.</p><h3>Refract by Fosfor</h3><p><a href="https://www.fosfor.com/refract/">Refract</a> by <a href="https://www.fosfor.com/">Fosfor</a> is a comprehensive machine learning platform that simplify each stages of ML lifecycle to make the ML adoption by organizations easier, faster &amp; simpler. And when it comes to Machine learning on Snowpark, Refract takes care of everything that needs to be taken care of and more. Let’s see how.</p><p><strong>Exploratory data analysis</strong>: Refract comes with a built in augmented data catalog that can be used by the data scientists to search and discover all key data assets in the organization. The catalog automatically generates detailed data profiling &amp; quality reports at each column level and also spots &amp; plots relationships between tables automatically. This makes the life of the data scientists easy to understand the data better &amp; deeper. And the best part, Refract pushes the data profiling &amp; quality workload on Snowflake.</p><p><strong>Data preparation:</strong> Refract comes with an easy click through data preparation UI that supports more than 200+ mostly used steps to prepare data for Machine learning. Functions like missing values treatment, feature scaling, field encoding, deduplication, Synthetic Minority Oversampling Technique (SMOTE) etc. comes out of the box saving the data scientists a lot of time. Once they are done with the quick try out of those functions on the sample data on Refract UI, users can “publish” the steps to the whole dataset which Refract then pushes to Snowpark automatically.</p><p><strong>Model training &amp; scoring:</strong> Refract comes with a variety of developer friendly IDEs such as VSCode, Jupyter, JupyterLab, Zeppelin etc. which are pre-configured with Snowpark libraries &amp; connections. Training &amp; scoring UDFs can be created from these workbenches. Refract also creates a bunch of supporting UDFs on Snowpark beforehand, to help the data scientists during training &amp; scoring steps. For example Refract’s <em>model_metrics</em> UDF can be used to automatically calculate all the metrics around the trained ML model (different scores, confusion matrix, ROC/AUC curve etc). Only this metrics statistics are then downloaded back to Refract to register the trained model.</p><p>Neither the data nor the model is downloaded to Refract. The trained model completely lives inside Snowflake and Refract only soft refers to it from its Model registry page.</p><p><strong>Model explanation:</strong> Refract’s <em>model_metrics</em> UDF mentioned in the above step also generates explanations on Snowpark and returns that too as part of metrics statistics. Refract uses this information and shows the model explanations in its UI along side each model.</p><p><strong>Drift monitoring:</strong> Refract also creates <em>drift_monitoring</em> UDF in Snowpark which keeps tab of possible drifts and periodically logs the information on the metadata table. This information also is read back by Refract and it displays against the registered model.</p><p>In summary, when we think of moving the ML workload to Snowpark, it’s crucial to think of <strong>pushing all key stages and not just the training/scoring</strong> parts, as otherwise, we will still need to move a lot of data in &amp; out of Snowflake which defeats the purpose of why we set out to do Snowpark adoption in the first place. <a href="https://www.fosfor.com/refract/">Refract by Fosfor</a> helps organizations to migrate every stages of the ML lifecycle to Snowpark.</p><p>Now, let’s say, as the leader of your business or function, you want to take the ML projects to Snowpark and reap all the benefits that comes along with it. You still have one more barrier to cross — convincing the developers to use it. Changes are often painful but the good news is, there are ways to make this move easier.</p><h3><strong>Removing the developer friction:</strong></h3><ol><li>The language: Snowpark support the common languages such as Python / Java / Scala to make it easier for developers</li><li>The IDE: Using a familiar user interface often solves half the problem. Sometimes the ML platform limits the users on the IDE, but Refract comes with a choice of IDEs such as Jupyter, Jupyterlab, Zeppelin, VSCode, RStudio etc. which are loved by the developers.</li><li>Code snippets: Refract comes with up to 15 Snowpark code snippets to make it easier to for developers to get started on Snowpark. Snippets include: creating &amp; closing of sessions, creation &amp; calling of Snowpark UDFs &amp; stored procedures, stages listing/deletion etc. Developers can click to add a particular code snippet to the IDE and make minor changes to fit it to their requirements.</li></ol><p>If you are already on the Snowflake ecosystem, Snowpark opens up a great opportunity to unify all your data transformation &amp; machine learning projects from disparate systems to the trusted Snowflake engine, that removes huge data transfers and thereby reduces cost &amp; improves performance. Refract by Fosfor helps you in that journey by optimizing each stage of ML project lifecycle towards Snowpark, while making the switch easy &amp; painless for the developers.</p><p>Thinking about Machine Learning in Snowpark, think now further. <a href="https://www.fosfor.com/book-a-demo/?product=Refract">Book a demo</a> today!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf8e54ad9221" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Refract by Fosfor hands-on with Car Evaluation Dataset — Part 1 — Data preparation & Model training]]></title>
            <link>https://medium.com/@gireeshputhumana/refract-by-fosfor-hands-on-with-car-evaluation-dataset-part-1-data-preparation-model-training-8e04db7b84b2?source=rss-51d199e20097------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e04db7b84b2</guid>
            <category><![CDATA[refract]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[mlops-platform]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[fosfor]]></category>
            <dc:creator><![CDATA[Gireesh Puthumana]]></dc:creator>
            <pubDate>Tue, 31 May 2022 03:15:34 GMT</pubDate>
            <atom:updated>2022-06-23T14:57:52.823Z</atom:updated>
            <content:encoded><![CDATA[<h3>Refract by Fosfor hands-on with Car Evaluation Dataset — Part 1 — Data preparation &amp; Model training</h3><p>Hey there, today we are going to see how easy it is to train &amp; operationalize a machine learning model at production scale using Refract by Fosfor. We are not talking about the product concepts or features here. Rather, we are gonna jump straight into an example to see how much efforts from the data scientists and the MLOps engineers are saved by Refract. If you haven’t already, do visit <a href="https://www.fosfor.com/">Fosfor</a> product suite page and then the <a href="https://www.fosfor.com/refract/">Refract</a> page to get yourself familiar with the product.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tr-DcNNKDSE23FTgVwpIlw.jpeg" /></figure><p>We will use this <a href="https://archive.ics.uci.edu/ml/datasets/car+evaluation">car evaluation data set</a> for this tryout. In this blog, we’ll use:</p><ul><li>Refract’s data preparation module to prepare the data set for model training</li><li>Refract’s customizable coding workbench to train the ML model</li></ul><p>I’ll follow up this blog with the part 2, where we’ll see more about operationalizing the trained ML model.</p><p>Okay, let’s get started by creating a new project in Refract.</p><p>(This may look like a long one, but don’t worry, it’s mostly the screenshots at each step 🙂)</p><h3>Data Preparation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gH3EX9M5eL6FOjpCZ5FS0w.png" /><figcaption>Create new project</figcaption></figure><p>Create a new project by clicking on the left top tile. Open the new project, go to the “Data” tab, click on “External File” and upload the data set. Data can be previewed on the right side.</p><p>Now, let’s start playing around with the data. Click on the “Create Lens” link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WdC5DfaaQ7Tk5Y7wMmnGlQ.png" /><figcaption>Upload car evaluation data set</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CT5VrLrUsBQw8eidtXn7nQ.png" /><figcaption>Data preparation (Lens) page</figcaption></figure><p>We get an excel like view of the data where we can do the assisted data wrangling to prepare it before training the ML model. Let’s start by renaming the columns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6V5TMaQEqasNpikGSCnnBg.png" /><figcaption>Rename columns</figcaption></figure><p>All columns are now properly named. Let’s take a look at the quick data profiling displayed just below the column names. For example on the “Class” column, it shows 70% of records have value “unacc”. 22.24% records have “acc”, 4% have “good” and 3.76% has “very good”. Let’s see more detailed data profiling of each column. Click on the “Profile” tab to see more detailed insights about the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3kNqqEDHSmTldfbqDkqdBQ.png" /><figcaption>Data profiling displayed below column title</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w1_9KGGJ1EY1SyI7Y8nJ9g.png" /><figcaption>Column wise detailed data profiling</figcaption></figure><p>Now, let’s encode the columns to numeric values. Data preparation steps like this are available out of the box and can be done in a few click. Let’s start by finding the right function to use.</p><p>On the left side, there’s button “Add a new step”, and the down arrow next to it shows different categories of steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*DTh0nwuwDdGqmYw0LgEzmA.png" /><figcaption>Categories of steps</figcaption></figure><p>Click on “Data cleaning &amp; formatting” category to list all available steps under it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/311/1*3Z819gyPya8EFF6BzBzo6A.png" /><figcaption>Available steps under “Data cleaning &amp; formatting”</figcaption></figure><p>Click on “Encoding” step</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/311/1*QzJElqNGtaHzA97B0g7_sQ.png" /><figcaption>Encoding step</figcaption></figure><p>Let’s do the label encoding on all columns. Select and click on “Process” to apply the encoding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kKrq8eckZyqPltq1QvCtJQ.png" /><figcaption>Data after label encoding on all columns</figcaption></figure><p>The new encoded columns will now be added along with the original columns. They will be named “label_encoded_&lt;column-name&gt;” by default. Let’s rename them to a “&lt;column-name&gt;_num” format.</p><p>Note the new steps are recorded on the left panel, as and when we play around with the data.</p><p>We don’t need those original columns any more. So drop them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*agtEBrfKkXxBMt1W77ELqQ.png" /><figcaption>Drop columns that are no longer needed</figcaption></figure><p>Here’s how our final data look.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nEmuJkTqX7cocy_HkdurPA.png" /><figcaption>Final prepared data</figcaption></figure><p>Note: Don’t worry about how the profile (under the column title) is looking now. It’s trying to create the range of values as the new encoded columns here are numeric type. We can change the data type to String to get the earlier profile view. Like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*rbVhLvqu0kYORYAMBwfbcQ.png" /><figcaption>Change column data type</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*hAfHxt_G9xd5TGAPPC3pzA.png" /><figcaption>Profile after changing to String type</figcaption></figure><p>But we don’t really need to do that. Numeric column type is what we need. So just delete the convert-to-string step from the left panel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*ZoAq7IRZjIlOvP-NV9PuLw.png" /><figcaption>Delete a step</figcaption></figure><p>Take a note of other handy options available here. For example, we can select any step in between and just run till that point to get back to any earlier stage and make changes.</p><p>Finally let’s click on the “Run” button at the top right corner to apply the steps in to the entire data set. It then goes into a “Running” status and then to “Completed” status.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*utr6pV9lTEeyA_oD043PKQ.png" /><figcaption>Data preps steps — applying to entire data set</figcaption></figure><p>Once completed, go back to the “Data” tab on the left to see the new prepared data set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E9KVV1GxnMnTQwvpZHWMLA.png" /><figcaption>New prepared dataset created</figcaption></figure><p>Let’s rename it to “car_new.csv”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*98BC1HHr6eHcQcZQFM2osg.png" /><figcaption>Rename the new dataset</figcaption></figure><p>Our data set is now ready for model training and we <strong>saved a bunch of coding</strong> in data exploration &amp; data preparation.</p><h3>Model Training Workbench</h3><p>Now that we have prepared the data, let’s head straight into the “Notebook” menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*Fu41VjK-RqbWTwlQj2n3eg.png" /><figcaption>Getting started with Notebooks</figcaption></figure><p>As the first step, let’s connect to GitHub (this is an optional step), to make sure all the code we do here in Refract is versioned and pushed to the Git repository. So let’s click on third tile above to connect to our GitHub repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*DBIgdiyH9Jf1VV2-0dJCow.png" /><figcaption>Configure git repository</figcaption></figure><p>Note that we can point any repository in GitHub, GitLab or BitBucket (public or private instances).</p><p>As the next step, let’s create a customized environment to work on. Click on “Use Template” option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*Fu41VjK-RqbWTwlQj2n3eg.png" /><figcaption>Getting started with Notebooks</figcaption></figure><p>Refract then shows us all pre-built templates available that we can get started with. We can choose different IDE’s like Jupyter, Jupyter Lab, Zeppelin, R Studio, SAS Studio, VS Code etc. to work with.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k8jgp_KXGZ1njvLbvUdgNA.png" /><figcaption>Pre-built coding templates</figcaption></figure><p>Let’s create a new custom template. Click on “Create Template” on the top left.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_KPGqL3bq49cfI8ekPOi5w.png" /><figcaption>Create a new custom template</figcaption></figure><p>We can select a base template on which we can do the customizations. Here, let’s choose Jupyter IDE and the pre-built template “Python-3.7”.</p><p>Next, let’s choose how much horse power we need while training the ML model. For this use case, 2 cores + 4 Gigs are more than enough.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*-rqvGIjaFAUMQpvOAo4lNQ.png" /><figcaption>Choose the infrastructure resource requirement</figcaption></figure><p>Next, let’s further customize it with some packages we are intending to use. Refract helps us with a type ahead search for packages and also with the available versions of them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*Sy_0-bO0ftXE8EHfLT6jeA.png" /><figcaption>Select libraries and versions from PIP, Git or Conda</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*hQWJTg_xsgBLazGzK-SVDg.png" /><figcaption>All required packages added</figcaption></figure><p>Our new customized template “CarSalePredictionTemplate” is now ready to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nuptA_W3RjAWqHX2uTZddQ.png" /><figcaption>New custom template (bottom left) added</figcaption></figure><p>Click on the new template to launch it. Refract will now launch a new container in the underlying Kubernetes engine with all the customizations we configured on this template. This container is created dedicatedly for the logged-in user to use — very much like their personal computer — but fully governed at the same time.</p><p>It takes a few seconds before it’s launched and ready to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*W4q5rF-HLigx1NBxqa8XvQ.png" /><figcaption>Launching new model training workbench</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*OrGo6ec48YspK7JWPgx_lg.png" /><figcaption>Jupyter container is now ready to use</figcaption></figure><p>Now let’s start writing the code for model training finally commit and push the code to our code repository in Github.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RrCOXwMNU868mHcbzgVudQ.png" /><figcaption>Push Notebook to Git repository</figcaption></figure><p>Let’s verify in GitHub once to make sure the code is pushed properly.</p><p>Yep, it looks great.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*VAedAgZs9-pGiKNxRdbM9Q.png" /><figcaption>Notebook code is now pushed to GitHub repository</figcaption></figure><p>Once the we are done with the coding, we can stop the running template by clicking on the “Stop container” button from “Running Template” tab. This will stop the running container and free up the resources back to the Kubernetes cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PVkFw61itp5kB6WYAkMNgA.png" /><figcaption>Stop running template</figcaption></figure><p>In this example, we have seen how easy is it to prepare the data in Refract using an easy &amp; intuitive spreadsheet like GUI. We have also seen the powerful customization &amp; flexibility we can leverage while coding on our favorite IDE.</p><p>In the next part of this blog, we’ll see how easily we can register a trained ML model, deploy it as an API for easy consumption and how can we do the post deployment model monitoring.</p><p>Leave your comments on what you think. If you are interested to learn more about Refract, feel free to request a demo and/or a free trial access from <a href="https://www.fosfor.com/book-a-demo/?product=Refract">here</a>.</p><p>See you all in part 2.</p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e04db7b84b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building the Fitness Challenge App with Appwrite]]></title>
            <link>https://medium.com/@gireeshputhumana/building-the-fitness-challenge-app-with-appwrite-367286790f64?source=rss-51d199e20097------2</link>
            <guid isPermaLink="false">https://medium.com/p/367286790f64</guid>
            <category><![CDATA[appwrite]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[cloud-functions]]></category>
            <dc:creator><![CDATA[Gireesh Puthumana]]></dc:creator>
            <pubDate>Sat, 30 Oct 2021 18:57:15 GMT</pubDate>
            <atom:updated>2021-10-30T18:57:15.557Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://appwrite.io/">Appwrite</a> is one of those best things happening in the open source today. If you haven’t heard about it yet, it’s an end-to-end backend as a service tool that offers simple REST API’s and SDKs to work with, while abstracting all the complexities of hosting and managing your backend services &amp; DB’s.</p><p>If you are familiar with Firebase, Appwrite is very similar - plus it’s open source. I guess they must be working on a fully hosted &amp; supported enterprise SAAS offering too, but you can always self-host it in your own infrastructure. It covers everything from user management &amp; authentication, backend database, backend storage, server side functions and more. With the 10M seed funding raised in September’21 and a 13k+ stars on <a href="https://github.com/appwrite/appwrite">Github</a>, it sure is just getting started.</p><p>I loved Firebase for its simplicity. The backend-as-a-service products such as Firebase helps users iterate ideas into working prototypes, and then to full blown products, much faster. They help save a good 30-40% of efforts, if not more. The only cause of worry (if you care) is - <em>they do too much</em> without you really have much control over. Which is a good thing initially, but as your product grows, you may want to have finer controls, where you can go ahead and tweak a few things as needed, rather than waiting at the mercy of Firebase to implement the features you are desperately waiting for. Also the cost of those services starts pretty low, but can shoot up really fast as the traffic grows.</p><p>The search for a Firebase alternative is what landed me on Appwrite. I went ahead and gave it a try using the Flutter SDK to see how it actually performs, and so far… <em>I’m lovin it…</em></p><p>If you are a developer and want to see how it all comes together, read on..</p><h3><strong>Fitness challenge App</strong></h3><p>The idea is to create a simple fitness challenge app in Flutter where users can register themself, create new challenges on the daily physical activities such as - total calories burned or the total steps taken. User then can then invite friends to participate in the challenge and see who’s leading. The activities are taken from Apple Health for now and Google Fit integration is to be done later. You can find the app source code <a href="https://github.com/gireeshp/fitness_challenge">here</a> and the readme has more details including all initial setup to be done on the Appwrite console.</p><p>In this article, let me explain a few cool features of Appwrite I used to build this app.</p><h4>Appwrite service</h4><p>A new Appwrite service class is created to do all the backend activities including user login, registration, database read/writes.</p><p>Service initialization block which creates account &amp; database objects once which will be reused throughout the app. It also defines all the collection ids used in the app:</p><pre>import ‘package:appwrite/appwrite.dart’;</pre><pre>final appWriteEndPoint = ‘https://localhost/v1&#39;;<br>final projectId = ‘616e3d7396bfb’;</pre><pre>final userCollectionId = &#39;617497ffb09f7&#39;;<br>final userActivitiesCollectionId = &#39;6174984332af8&#39;;<br>final challengesCollectionId = &#39;617872e12c3d8&#39;;<br>final leaderboardCollectionId = &#39;617873ddacaec&#39;;</pre><pre>final uuid = const Uuid();</pre><pre>final Client _client = Client();<br>late Account _account;<br>late Database _database;</pre><pre>_client.setEndpoint(appWriteEndPoint)<br>   .setProject(projectId)<br>   .setSelfSigned(status: true);</pre><pre>_account = Account(_client);<br>_database = Database(_client);</pre><h4>New user registration</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*eTYkMArpwNOzkZ8Z6KOd0A.png" /><figcaption>Sign up page</figcaption></figure><p>Users can register themselves by providing the name, email and password. Here’s how the signup is done using Appwrite flutter SDK. It creates a new user “account”.</p><pre>signUp({required String email,<br>  required String password,<br>  required String name}) async {</pre><pre>  Future result =<br>  _account.create(email: email, password: password, name: name);<br>  <br>  await result.then((response) {<br>    debugPrint(&#39;Signup done&#39;);<br>  }).catchError((error) {<br>    debugPrint(&#39;Error while signing up&#39;);<br>    throw (error);<br>  });<br>}</pre><p><strong>Create the user profile document in user collection upon a new user registration</strong></p><p>Here comes the Appwrite server side Functions which can be triggered on various different types of events such as account.create, session.create, account.update, collections.create and many more. It can also be scheduled using a cron expression or can be triggered via client SDKs.</p><p>Here’s the server side function using Python SDK.</p><pre>import os<br>import json</pre><pre>from appwrite.client import Client<br>from appwrite.services.database import Database<br>user_collection_id = &quot;617497ffb09f7&quot;</pre><pre>def init_client():<br>   # Initialize the Appwrite client<br>   client = Client()<br>   client.set_endpoint(os.getenv(&quot;APPWRITE_ENDPOINT&quot;))<br>   client.set_project(os.getenv(&quot;APPWRITE_FUNCTION_PROJECT_ID&quot;))<br>   client.set_key(os.getenv(&quot;APPWRITE_API_KEY&quot;))<br>   return client</pre><pre>def main():<br>   payload = json.loads(os.getenv(&quot;APPWRITE_FUNCTION_EVENT_DATA&quot;))</pre><pre>   userId = payload[&quot;$id&quot;]<br>   userName = payload[&quot;name&quot;]<br>   email = payload[&quot;email&quot;]</pre><pre>   client = init_client()<br>   database = Database(client)</pre><pre>   database.create_document(user_collection_id, <br>      {&#39;user_id&#39;: userId, <br>      &#39;user_name&#39;: userName, <br>      &#39;email&#39;: email<br>      }, <br>      read=[&#39;*&#39;], write=[&#39;*&#39;])</pre><pre>if __name__ == &quot;__main__&quot;:<br>   main()</pre><p>More details about it including how to setup can be found <a href="https://github.com/gireeshp/fitness_challenge/tree/master/functions/create_user_profile">here</a>.</p><h4>User login</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*PE1KsUtqPOlqYChaYtaiiQ.png" /><figcaption>Login page</figcaption></figure><p>Here’s the sign in block. It creates a new “session” for the user.</p><pre>signIn({required String email, required String password}) async {</pre><pre>  Future result = <br>    _account.createSession (email: email, password:password);</pre><pre>  await result.then((response) {<br>    debugPrint(&#39;Logged in&#39;);<br>    Session session = response;<br>    _loggedInUserId = session.userId;<br>  }).catchError((error) {<br>    debugPrint(&#39;Error while signing in&#39;);<br>    throw (error);<br>  });<br>}</pre><h4>Displaying challenges the user is participating in</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*hWQO_GmZNuB_x69xtRh6wQ.png" /><figcaption>Your challenges page</figcaption></figure><p>Here’s the code block to read from leaderboard table with the filter for the logged in user.</p><pre>Future&lt;DocumentList&gt; getUserChallenges() async {<br>   DocumentList docList = await _database.listDocuments(<br>   collectionId: leaderboardCollectionId,<br>   filters: [&#39;user_id=$_loggedInUserId&#39;],<br>   );<br>}</pre><p>Building the list view widget to display the above data:</p><pre>return FutureBuilder&lt;DocumentList&gt;(<br>   future: appwriteService.getUserChallenges(),<br>   builder: (BuildContext context, <br>      AsyncSnapshot&lt;DocumentList&gt;<br>      docList) {</pre><pre>      if (docList.connectionState == ConnectionState.none <br>         &amp;&amp; docList.hasData == false) {<br>         debugPrint(&#39;No data&#39;);<br>         return Container();<br>      } else {<br>         return ListView.builder(<br>            itemCount:docList.data == null ? 0 <br>               : docList.data?.documents.length,<br>            itemBuilder: (BuildContext context, int index) {<br>               Document? doc = docList.data?.documents[index];<br>               return ChallengeListTile(<br>                  icon: Icons.sports,<br>                  challengeName: doc?.data[&#39;challenge_name&#39;],<br>                  yourRank: doc?.data[&#39;rank&#39;],<br>                  measureType: doc?.data[&#39;measure_type&#39;],<br>                  challengeId: doc?.data[&#39;challenge_id&#39;],<br>               );<br>            }<br>         );<br>      }<br>   },<br>);</pre><pre>// ChallengeListTile is not shown here. You can find it in the Github repo.</pre><h4>See the leaderboard inside the selected challenge</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/293/1*D3D7KAxgn8nh0M-QGkjjyg.png" /><figcaption>Leaderboard page</figcaption></figure><p>Read leaderboard data for the selected challenge id</p><pre>Future&lt;DocumentList&gt; getLeaderBoard(String challengeId) async {<br>   debugPrint(&#39;Challenge id is: $challengeId&#39;);<br>   DocumentList docList = await _database.listDocuments(<br>      collectionId: leaderboardCollectionId,<br>      filters: [&#39;challenge_id=$challengeId&#39;],<br>   );<br>   return docList;<br>}</pre><pre>// Displaying the leaderboard using FutureBuilder is not shown here. You can find it in the Github repo.</pre><h4>Inviting friends to the challenge</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/293/1*b5BLz9wDnyHWa7OtpNPfzQ.png" /><figcaption>Invite friends to challenge</figcaption></figure><pre>inviteUserToChallenge({<br>   required String email,<br>   required String challengeId,<br>   required String challengeName,<br>   required String measureType,<br>}) async {</pre><pre>try {<br>   DocumentList docList = await _database.listDocuments(<br>      collectionId: userCollectionId,<br>      filters: [&#39;email=$email&#39;],<br>      limit: 1,<br>      );<br>   if (docList.documents.isEmpty) {<br>      throw (Exception(&quot;Invited user doesn&#39;t exist&quot;));<br>   }</pre><pre>   String userId = docList.documents[0].data[&#39;user_id&#39;];<br>   String userName = docList.documents[0].data[&#39;user_name&#39;];<br>   debugPrint(&#39;User id is: $userId&#39;);<br>   Document userChallengeDoc = await _database<br>      .createDocument(<br>      collectionId: leaderboardCollectionId,<br>      data: {<br>         &#39;challenge_id&#39;: challengeId,<br>         &#39;challenge_name&#39;: challengeName,<br>         &#39;user_id&#39;: userId,<br>         &#39;user_name&#39;: userName,<br>         &#39;email&#39;: email,<br>         &#39;rank&#39;: 0,<br>         &#39;measure_type&#39;: measureType,<br>         &#39;value&#39;: 0<br>      },<br>      read: [&#39;*&#39;],<br>      write: [&#39;*&#39;],<br>   );</pre><pre>   debugPrint(&#39;User challenge doc created&#39;);<br>} catch (e) {<br>   debugPrint(&#39;Error while creating new challenge&#39;);<br>   throw (e.toString());<br>}</pre><pre>}</pre><h4>Uploading user activity details</h4><p>Clicking on the “Sync Health Data” button in the challenges listing page sync the health records from Apple Health. More details about how to set Apple Health permissions can be found in the <a href="https://github.com/gireeshp/fitness_challenge">Github repo</a>. Here’s the code block for reading from Apple Health and write to user_activities collection.</p><pre>synchHealthData() async {<br>    List&lt;HealthDataPoint&gt; _healthDataList = [];</pre><pre>   List&lt;HealthDataType&gt; types = [<br>      HealthDataType.STEPS,<br>      HealthDataType.BLOOD_GLUCOSE,<br>      HealthDataType.ACTIVE_ENERGY_BURNED,<br>   ];</pre><pre>   // Start date and end date is hard coded for now. <br>   //It should be   adjusted to read only incremental data<br>   DateTime startDate = DateTime(2020, 11, 07, 0, 0, 0);<br>   DateTime endDate = DateTime(2025, 11, 07, 23, 59, 59);</pre><pre>   HealthFactory health = HealthFactory();<br>   bool accessWasGranted = await health.requestAuthorization(types);</pre><pre>   if (accessWasGranted) {<br>      try {<br>         List&lt;HealthDataPoint&gt; healthData =<br>             await health.getHealthDataFromTypes(startDate, <br>                endDate, types);<br>         _healthDataList.addAll(healthData);</pre><pre>         _healthDataList = HealthFactory.removeDuplicates<br>          (_healthDataList);</pre><pre>         _healthDataList.forEach((x) {<br>            createUserActivity(<br>            _loggedInUserId, x.type.toString(), x.value.round());<br>         });</pre><pre>         int lastSyncTime = DateTime.now().millisecondsSinceEpoch;<br>         Document updatedUserDoc = await _database.updateDocument(<br>            collectionId: userCollectionId,<br>            documentId: _loggedInUserDocId,<br>            data: {&#39;health_last_sync&#39;: lastSyncTime},<br>         );<br>      } catch (e) {<br>         debugPrint(e.toString());<br>      }<br>    } else {<br>      debugPrint(&#39;Authorization was not granted&#39;);<br>    }<br>}</pre><pre>createUserActivity(String userId, <br>      String measureType, int value) async {<br>    try {<br>     Document userActivityDoc = await _database.createDocument(<br>        collectionId: userActivitiesCollectionId,<br>        data: {&#39;user_id&#39;: userId, &#39;measure_type&#39;: measureType,<br>             &#39;value&#39;: value},<br>        read: [&#39;*&#39;],<br>        write: [&#39;*&#39;],<br>      );<br>    } catch (e) {<br>      debugPrint(&#39;Error while creating user activity document&#39;);<br>      throw (e.toString());<br>    }<br>}</pre><p><strong>Calculating the rank based on the user activity data using the Appwrite Server side functions.</strong></p><p>Now that the user activities are synced, a server side function is used to calculate the leaderboard for each challenge.</p><ul><li>It first reads from all user activities and creates the activity scores</li><li>It then loops through all challenges, looks up all who are participating in it and based on the measure type for the challenge, calculates the ranking of the players</li></ul><p>Here’s the code block for that. Details about how to set it up in Appwrite console can be found <a href="https://github.com/gireeshp/fitness_challenge/tree/master/functions/calculate_leaderboard">here</a>.</p><pre>import os<br>import json</pre><pre>from appwrite.client import Client<br>from appwrite.services.database import Database</pre><pre>user_collection_id = &quot;617497ffb09f7&quot;<br>challenges_collection_id = &quot;617872e12c3d8&quot;<br>user_activities_collection_id = &quot;6174984332af8&quot;<br>leaderboard_collection_id = &quot;617873ddacaec&quot;</pre><pre>def init_client():<br>    # Initialize the Appwrite client<br>    client = Client()<br>    client.set_endpoint(os.getenv(&quot;APPWRITE_ENDPOINT&quot;))<br>    client.set_project(os.getenv(&quot;APPWRITE_FUNCTION_PROJECT_ID&quot;))<br>    client.set_key(os.getenv(&quot;APPWRITE_API_KEY&quot;))</pre><pre>    return client</pre><pre>def main():<br>    client = init_client()<br>    database = Database(client)</pre><pre>    # Get all users and calculate their activity scores<br>    userActivityScores = dict()<br>    res1 = database.list_documents(user_collection_id)<br>    for userDoc in res1[&quot;documents&quot;]:<br>        userId = userDoc[&quot;user_id&quot;]<br>        # Calculate activity score for the user<br>        activityScores = dict()</pre><pre>        res2 = database.list_documents<br>            (user_activities_collection_id, <br>            filters=[f&quot;user_id={userId}&quot;])<br>        for activityDoc in res2[&quot;documents&quot;]:<br>            activityType = activityDoc[&quot;measure_type&quot;<br>                           [len(&quot;HealthDataType.&quot;):]<br>            value = activityDoc[&quot;value&quot;]<br>            if activityType in activityScores:<br>                activityScores[activityType] += value<br>            else:<br>                activityScores[activityType] = value</pre><pre>        userActivityScores[userId] = activityScores</pre><pre>    # Get all unique challenge ids<br>    res3 = database.list_documents(challenges_collection_id)<br>    for challengeDoc in res3[&quot;documents&quot;]:<br>        challengeId = challengeDoc[&quot;challenge_id&quot;]<br>        measureType = challengeDoc[&quot;measure_type&quot;<br>           [len(&quot;MeasureType.&quot;):].upper()<br>        challengeName = challengeDoc[&quot;challenge_name&quot;]</pre><pre>        # Now list of users participating in that challenge<br>        leaderboardDict = dict()<br>        res4 = database.list_documents(leaderboard_collection_id,<br>           filters=[f&quot;challenge_id={challengeId}&quot;])<br>        for userDoc in res4[&quot;documents&quot;]:<br>            userId = userDoc[&quot;user_id&quot;]<br>            print (userId)<br>            if userId in userActivityScores:<br>                userActivityScoreDict = userActivityScores[userId]<br>                if measureType in userActivityScoreDict:<br>                    leaderboardDict[userId] = <br>                        userActivityScores[userId][measureType]</pre><pre>        # Now sort the leaderboard based on the activity values<br>        sorted_leaderboard = sorted(leaderboardDict.items(),<br>                  key=lambda x: x[1], reverse=True)</pre><pre>        # Now update the rank of the users in the challenge<br>        rank = 0<br>        for leader in sorted_leaderboard:<br>            rank += 1<br>            res5 = database.list_documents<br>                   (leaderboard_collection_id, <br>                    filters=[f&quot;user_id={leader[0]}&quot;, <br>                             f&quot;challenge_id={challengeId}&quot;],<br>                    limit=1)<br>            docId = res5[&quot;documents&quot;][0][&quot;$id&quot;]<br>            database.update_document(leaderboard_collection_id,<br>                    docId, {&quot;rank&quot;: rank})<br>    <br>if __name__ == &quot;__main__&quot;:<br>    main()</pre><h4>What’s next</h4><p>The app is far from complete and need to build all the below features. Most of them can be done using Appwrite’s back end services.</p><ul><li>User authentication with Other OAuth providers (Google, Facebook, Twitter etc.) using Appwrite’s built-in OAuth2 integration</li><li>Email verification using Appwrite’e email verification feature<br> Password recovery using Appwrite’s password recovery feature</li><li>Store user profile picture using the Appwrite Storage service</li><li>Add a user to the challenge only after their confirmation (currently they are added by default when invited)</li><li>Better UI :)</li><li>Start date &amp; end date for challenges and declaration of winners</li><li>Option to choose other health data types in challenge — currently only Steps-count and Active-energy-burned are considered for challenge</li><li>Integration with Google Fit (currently integrated with Apple Health only)</li><li>Sync health data incrementally and automatically (without specific button click)</li><li>Generate QR code for challenge join invitation links using Appwrite’s Avatars/QR service</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=367286790f64" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Azure Data Factory and the ecosystem paradox]]></title>
            <link>https://medium.com/@gireeshputhumana/the-azure-data-factory-and-the-ecosystem-paradox-2f8ca9bdf729?source=rss-51d199e20097------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f8ca9bdf729</guid>
            <category><![CDATA[multi-cloud]]></category>
            <category><![CDATA[adf]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[aws-glue]]></category>
            <category><![CDATA[azure-data-factory]]></category>
            <dc:creator><![CDATA[Gireesh Puthumana]]></dc:creator>
            <pubDate>Mon, 19 Jul 2021 15:18:18 GMT</pubDate>
            <atom:updated>2021-07-19T15:18:18.033Z</atom:updated>
            <content:encoded><![CDATA[<p>The Azure Data Factory (ADF) is a great tool for data loading, transformation &amp; orchestration. It is easy to use, powerful, well integrated with other Azure services and has DataOps baked in with Azure DevOps. Though it’s not as matured &amp; feature rich compared to other industry leading ETL tools such as Talend or Informatica, it is definitely one of the front runner ETL tool option to consider, when you are in the Azure eco system already.</p><p>By this time, you may be waiting for that “however..” Let me explain that with the Apple ecosystem analogy.</p><p>You may have heard how the Apple ecosystem is designed to make it hard for the user to ever leave it. The more Apple products &amp; services you use, it is harder for you to get out. It’s like Apple is building those big invisible walls around you without you noticing. Don’t take me wrong. More often than not, they are the best products and services in the industry — hands down. So you don’t really have to get out of the eco system and can stay in there happily as long as you don’t mind that extra premium price you pay.</p><p>The cloud eco systems are very similar. Once you are in, everything is so well inter-connected &amp; integrated. More services you use, the whole experience makes it harder to leave. The difference though is, we are talking about a $3500 hit (give or take) + some initial personal getting-used-to-hardship to move away from Apple products for an individual user. But for an organization, it’s millions of dollars of blood, sweat &amp; tears moving away from a cloud. If you haven’t read <a href="https://a16z.com/2021/05/27/cost-of-cloud-paradox-market-cap-cloud-lifecycle-scale-growth-repatriation-optimization/">this brilliant article</a> by Sarah Wang &amp; Martin Casado, please do so. It wonderfully explains why it’s important to <strong>not</strong> get married to any cloud and how thinking &amp; planning about repatriation up front, is of utmost importance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sE0sFbuoTNMwm-mEkIKNnQ.jpeg" /><figcaption>Are you ready to leave the cloud?</figcaption></figure><p>With that context, let’s look at the types of cloud services and their impact on repatriation. For the ease of discussion, let’s consider the following types of services — Infrastructure related services, data/storage related services &amp; the “code” related services. Infrastructure related services such as virtual machines, networks, load balancers etc. are <em>comparatively</em> the easiest to replace. The data/storage related services like cloud storages, DBs etc. involves one time big effort to move huge data around, but it’s still easier. It’s the third type — “code”, the hardest nut to crack. And the more native the “code” is to the cloud engine, the harder it is to move away from. Examples of this type are: Azure data factory, AWS Glue, Azure ML, AWS Sagemaker, Azure Functions, AWS Lambda etc. And even in this list, the Azure Data Factory &amp; AWS Glue are the hardest to move away from, thanks to their easy no-code native ETL engines.</p><p>The total number of ETL jobs in an organization typically ranges from a few hundreds to tens of thousands depending on its size. Switching the ETL tool in most scenarios means re-writing all those ETL jobs. While there are some tools focusing on automating such conversions between the ETL tools, in most of the cases, it’s simply the hard manual labor for many months to get the job done.</p><p>What would have been nice is, if ADF generates some common code for all data flows &amp; pipeline created in it. And provide the user an easy option to download them when they are moving away from ADF. The customers then can deploy those code in the new environment directly without being forced to migrate them manually. This, in no way, is an “unrealistic” wish. Some new age cloud agnostic ETL tools do this already. One such example is LTI’s <a href="https://mosaic.lntinfotech.com/mosaic-decisions/">Mosaic Decisions</a>. Had a customer decide to leave it, Mosaic Decisions provides the download of all the ETL jobs ever created on it in simple Java &amp; Spark code base. Customer can easily deploy those on any Spark environment. And in the cloud repatriation scenarios, such cloud agnostic tools make it easy for the customer to simply lift and shift the complete ETL code base between clouds or even better — back to on-premise.</p><p>Let me conclude.</p><p>Know that, it’s very likely that, you will want to move away from the cloud one day. The code you are developing today shouldn’t make your life terrible when you do. So plan ahead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7iem3UcZ5QoPqZN1_0pFcQ.jpeg" /><figcaption>Make sure you are not locked in</figcaption></figure><p>By the way, did I tell you that while ADF has good integrations with other Azure services, it doesn’t support simple data writing operations into AWS S3/Redshift, Google Cloud storage/BigQuery etc? It allows reading from all these, but doesn’t support writing. Which means, if you ever decide to try out some AWS/Google cloud services later and want to push your data there, ADF sure doesn’t have your back. And <a href="https://feedback.azure.com/forums/270578-data-factory/suggestions/36280996-amazon-s3-sink">here’s</a> users requesting this feature from 2018 and Microsoft is in no mood to implement these. Wonder why? :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f8ca9bdf729" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>