<?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 Sowmya K on Medium]]></title>
        <description><![CDATA[Stories by Sowmya K on Medium]]></description>
        <link>https://medium.com/@sowmyak05?source=rss-91b932565846------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*FbT072izpvi0EM3t.</url>
            <title>Stories by Sowmya K on Medium</title>
            <link>https://medium.com/@sowmyak05?source=rss-91b932565846------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 04:15:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sowmyak05/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[How Harness tests time series ML models]]></title>
            <link>https://medium.com/harness-engineering/how-harness-tests-time-series-ml-models-9104a4aeb4eb?source=rss-91b932565846------2</link>
            <guid isPermaLink="false">https://medium.com/p/9104a4aeb4eb</guid>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[time-series-analysis]]></category>
            <dc:creator><![CDATA[Sowmya K]]></dc:creator>
            <pubDate>Tue, 18 May 2021 05:02:50 GMT</pubDate>
            <atom:updated>2021-05-18T05:02:50.087Z</atom:updated>
            <content:encoded><![CDATA[<p>Anyone who has worked with machine learning models will vouch for the fact that testing them is not an easy task. Not only are there complex logical conditions, there’s an additional dependency of covering a plethora of use cases which can be present as an input. It’s difficult to cover all possible use cases as part of our test framework using the traditional approach. So how do we come up with a practical plan to create our test framework and be confident in any changes we make on it?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8uD0T1P6BXSdgxCMScF5jg.png" /></figure><p>While we have a standard framework [1] to write our tests for backend and UI codebase, there is a lack of standardization for the same for machine learning models. We modified the standardized approach to include validation tests which are specific to our machine learning model to layout a strong foundation for the ML test framework.</p><h3>Unit Tests</h3><p>In any codebase, we need unit tests to ensure its stability and faster debugging. Especially when the project is huge, having proper unit tests is a basic need. Because unit tests are cheaper in terms of run time as well as developer time, we make sure that majority of our tests are unit tests. These tests extensively cover the logical conditions in the codebase as much as possible.</p><p>Let’s take an example below. You’re testing the following code which has a custom implementation of sum of a collection. We need to make sure that we are covering different types of input:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/222acca7143b679d8ffc6954de9e08c3/href">https://medium.com/media/222acca7143b679d8ffc6954de9e08c3/href</a></iframe><blockquote>Note: It may not really possible to cover all possible cases, but the idea is to come as close to it as possible.</blockquote><h3>Validation Tests</h3><p>While unit tests are good for testing individual units of code, it may not be able to cover tests which span across multiple analysis periods. For example, if we want to test if our model catches cyclic events, unit tests might not be the way to go. That’s where validation tests come in.</p><p>Validation tests can also be thought of tests which cover possible dataset types which our model is supposed to handle. In case of Harness, we use the synthetic time series dataset from UCI Machine Learning Repository [2] to validate the performance of our model against this dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CFEY6AVJlvE6DRIo2IZZ8w.png" /><figcaption>Examples of dataset for validation framework</figcaption></figure><p>Harness uses this format to generate datasets for different metric types and depending on the metric type we determine if it needs to be alerted or not. For example, we need to alert on abrupt upshift of error metrics but we don’t need to alert on abrupt upshifts of calls per minute. We create a matrix for metric type and dataset type which looks something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lyq6Q24WBv-JOnXjRdoizw.png" /></figure><p>We keep updating these validation datasets if we come across a unique case which hasn’t been covered before. These tests are run as part of our PR checks to ensure the quality stays up with each merge.</p><h3>Integration Tests</h3><p>This is the final set of tests that we have added to the framework which tests the integration of the ML models with api server and the frontend codebase. We make sure to have minimum tests here which just tests the sanity.</p><p>This set of tests nicely complete the loop for us to have a strong and resilient test framework for machine learning models.</p><blockquote>Thanks for reading!</blockquote><p>References:</p><p>[1] <a href="https://martinfowler.com/articles/practical-test-pyramid.html">https://martinfowler.com/articles/practical-test-pyramid.html</a></p><p>[2] <a href="https://archive.ics.uci.edu/ml/datasets/Synthetic+Control+Chart+Time+Series">UCI Machine Learning Repository</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9104a4aeb4eb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/harness-engineering/how-harness-tests-time-series-ml-models-9104a4aeb4eb">How Harness tests time series ML models</a> was originally published in <a href="https://medium.com/harness-engineering">Harness Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serverless architecture to deploy and run google dataflow pipelines]]></title>
            <link>https://medium.com/harness-engineering/serverless-architecture-to-deploy-and-run-google-dataflow-pipelines-d71ea4a8331b?source=rss-91b932565846------2</link>
            <guid isPermaLink="false">https://medium.com/p/d71ea4a8331b</guid>
            <category><![CDATA[google-dataflow]]></category>
            <category><![CDATA[cloud-scheduler]]></category>
            <category><![CDATA[cloud-functions]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Sowmya K]]></dc:creator>
            <pubDate>Wed, 04 Sep 2019 10:13:57 GMT</pubDate>
            <atom:updated>2020-12-10T14:30:36.568Z</atom:updated>
            <content:encoded><![CDATA[<h3>Serverless architecture to run dataflow pipelines</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*O3bD5BC3haTIY_mAPfh_FQ.png" /><figcaption>Providers for serverless architecture</figcaption></figure><h4>What is serverless architecture?</h4><p>Serverless architecture refers to an infra setup where applications depend either on third party services (BaaS) or on third party stateless compute containers (FaaS) to handle server side logic. (<a href="https://www.simform.com/serverless-architecture-guide/">Refer for a more comprehensive guide to server less architecture</a>)</p><h4>Our use case</h4><p>We at <a href="https://harness.io/">harness</a> use dataflow pipelines to run some of the preprocessing steps for our machine learning models. We needed to run some beam pipelines periodically on the production data.</p><h4>Why serverless?</h4><p>Since beam pipelines are standalone, FaaS seemed to be the right architecture. It was a simple application as all the complex processing was done in the beam pipeline, all the cloud function had to do was trigger it. Additionally, these pipelines need to be triggered once a week or once a month. Having a whole server just to trigger a pipeline seemed to be a waste of resources. With cloud functions, you pay the cost per triggers.</p><p>In this post, I am going to lay out the architecture that worked for us which takes just 4 steps. We majorly use python here, so this blog post will contain python specific code. Also, this writeup assumes basic knowledge on beam pipelines and it’s blocks. If you are not familiar with it, you can follow this <a href="https://towardsdatascience.com/hands-on-apache-beam-building-data-pipelines-in-python-6548898b66a5">post</a>.</p><h3>Step 1: Write a beam pipeline</h3><p>Below is the code for a simple beam pipeline that searches through a list and returns list of words that contain the given substring.</p><pre>import apache_beam as beam</pre><pre>from apache_beam.options.pipeline_options import PipelineOptions<br>from apache_beam.options.pipeline_options import SetupOptions</pre><pre>substring = &#39;o&#39;</pre><pre>class getWordsContaining(beam.DoFn):<br>    def process(self, element):<br>        if substring in element:<br>            yield element<br><br>options = PipelineOptions()<br>options.view_as(SetupOptions).save_main_session = True<br><br>p = beam.Pipeline(options=options)<br><br>cities = p | beam.Create([&#39;hello&#39;, &#39;world&#39;, &#39;ok&#39;, &#39;hi&#39;])<br>cities | beam.ParDo(getWordsContaining())<br><br><br>result = p.run()<br>result.wait_until_finish()</pre><p>Now, suppose we want to parameterise our beam pipeline. We can run that python code with an input parameter: “substring”.</p><h3>Step 2: Create custom template</h3><p>Custom templates can be used if we need to run the same pipeline frequently with same or different parameters without any other code change.</p><p>In this case, we are assuming that we need to use a different substring value every time. To do that, the first step we need to do is add substring as a run-time parameter.</p><pre>class UserOptions(PipelineOptions):<br>    @classmethod<br>    def _add_argparse_args(cls, parser):<br>        parser.add_value_provider_argument(&#39;--substring&#39;, type=string)</pre><p>“add_value_provider_argument” assumes a runtime parameter substring exists.</p><p>To use the added run-time parameter in the DoFn block of pipeline, you need to add an init method that takes a new parameter substring. To access that substring, use substring.get().</p><pre>class getWordsContaining(beam.DoFn):</pre><pre>    def __init__(self, substring):<br>        self.substring = substring</pre><pre>    def process(self, element):<br>        if self.substring.get() in element:<br>            yield element</pre><p>Note that, since this is a run-time parameter, the value will not be accessible in init function. If you use .get() in the init function, it will throw an exception during compilation.</p><p>Now, we need to update the pipeline block where this function is being called.</p><pre>user_options = pipeline_options.view_as(UserOptions)</pre><pre>cities | beam.ParDo(getWordsContaining(user_options.substring))</pre><h4>Save custom template</h4><p>Now, your custom template is ready to be saved. To save your custom template in cloud storage, update PROJECT and BUCKET with your actual project and bucket names. Also, you can add your own TEMPLATE_NAME.</p><pre>python GenerateTSThresholds.py --runner DataflowRunner --project PROJECT --staging_location gs://BUCKET/staging --temp_location gs://BUCKET/temp --template_location gs://BUCKET/templates/TEMPLATE_NAME</pre><p>Once it’s run, you can check at the “template_location” if it is saved or not.</p><h4>Create metadata file</h4><p>For the template to work, you need to create a metadata file for your pipeline specifying the parameters it requires. Make sure to save it with suffix “_metadata” to your template name.</p><pre>{<br>  &quot;description&quot;: &quot;Test pipeline that returns list of words containing substring&quot;,<br>  &quot;name&quot;: &quot;Substring test&quot;,<br>  &quot;parameters&quot;: [<br>    {<br>      &quot;regexes&quot;: [<br>        &quot;^[a-zA-Z]*$&quot;<br>      ],<br>      &quot;name&quot;: &quot;substring&quot;,<br>      &quot;helpText&quot;: &quot;Only alphabetic characters are allowed&quot;,<br>      &quot;label&quot;: &quot;Input substring to match&quot;<br>    }<br>  ]<br>}</pre><p>Copy the metadata file to same gcs bucket:</p><pre>gsutil cp METADATA_FILE gs://BUCKET/templates/</pre><p>You can test the custom template using the directions give <a href="https://cloud.google.com/dataflow/docs/guides/templates/running-templates#custom-templates">here</a>.</p><h3>Step 3: Create cloud function</h3><p>Once, you’ve tested the custom template and it’s working correctly, you can move on to create the cloud function. Since we are heavily dependent on python, we have used the same to create the cloud function.</p><p>You can follow this for the basic setup:</p><p><a href="https://cloud.google.com/functions/docs/quickstart-console#create_a_function">Quickstart: Using the Console | Cloud Functions Documentation | Google Cloud</a></p><p>In the cloud function, we need to create an API that launches the pipeline. Use the below code in main.py.</p><pre>from googleapiclient.discovery import build<br>from oauth2client.client import GoogleCredentials<br><br>def launch_pipeline(request):<br>    credentials = GoogleCredentials.get_application_default()<br>    service = build(&#39;dataflow&#39;, &#39;v1b3&#39;, credentials=credentials)<br><br>    # Update the below four variables to reflect your requirements<br>    JOBNAME = &quot;jobname&quot;<br>    PROJECT = &quot;project&quot;<br>    BUCKET = &quot;bucket&quot;<br>    TEMPLATE = &quot;template&quot;<br><br>    GCSPATH = &quot;gs://{bucket}/templates/{template}&quot;.format(bucket=BUCKET, template=TEMPLATE)<br>    BODY = {<br>        &quot;jobName&quot;: &quot;{jobname}&quot;.format(jobname=JOBNAME),<br>        &quot;parameters&quot;: {<br>            &quot;substring&quot;: &quot;o&quot;<br>        },<br>        &quot;environment&quot;: {<br>            &quot;tempLocation&quot;: &quot;gs://{bucket}/temp&quot;.format(bucket=BUCKET),<br>            &quot;zone&quot;: &quot;us-central1-f&quot;<br>        }<br>    }<br><br>    request = service.projects().templates().launch(projectId=PROJECT, gcsPath=GCSPATH, body=BODY)<br>    response = request.execute()<br><br>    print(response)</pre><p>This gets the credentials of the current project and launches the template. Update the job, project, bucket and template name variables. You can pass the substring variable in the parameters section.</p><p>Add your requirements in requirements.txt file. For this, only apache-beam is required to launch the pipeline.</p><pre>apache-beam[gcp]==2.12.0</pre><p>Update the “function to execute” field and set it to “launch_pipeline”.</p><p>Once you create the pipeline, it’ll take about a minute or two to be ready. You can find the API under the trigger section and test it out.</p><h3>Step 4: Create scheduling job</h3><p>This the easiest step by far. You can use cloud scheduler to periodically schedule your pipeline. Fill out the url that you created from the cloud function and set the frequency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rX7Hg-NqAaGEfR8pX7iXzg.png" /></figure><p>Your pipelines are now up and running. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d71ea4a8331b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/harness-engineering/serverless-architecture-to-deploy-and-run-google-dataflow-pipelines-d71ea4a8331b">Serverless architecture to deploy and run google dataflow pipelines</a> was originally published in <a href="https://medium.com/harness-engineering">Harness Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>