<?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 AmritKmr on Medium]]></title>
        <description><![CDATA[Stories by AmritKmr on Medium]]></description>
        <link>https://medium.com/@amritkmr4272?source=rss-8b3118e8137d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Hya_bucRTIQoWqt1Ef6Zpw.jpeg</url>
            <title>Stories by AmritKmr on Medium</title>
            <link>https://medium.com/@amritkmr4272?source=rss-8b3118e8137d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 03:51:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amritkmr4272/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[Engineering with Claude Code: Architectural Insights from Anthropic’s Expert Courses]]></title>
            <link>https://medium.com/design-bootcamp/engineering-with-claude-code-architectural-insights-from-anthropics-expert-courses-693d5dd2d5f1?source=rss-8b3118e8137d------2</link>
            <guid isPermaLink="false">https://medium.com/p/693d5dd2d5f1</guid>
            <category><![CDATA[anthropic-claude-code]]></category>
            <category><![CDATA[llm-engineering]]></category>
            <category><![CDATA[anthropic-claude]]></category>
            <category><![CDATA[claude-code-tips]]></category>
            <category><![CDATA[llm-production]]></category>
            <dc:creator><![CDATA[AmritKmr]]></dc:creator>
            <pubDate>Mon, 13 Jul 2026 17:31:38 GMT</pubDate>
            <atom:updated>2026-07-14T10:59:44.320Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>How to move past basic prompting and master context optimization, deterministic lifecycle hooks, and agentic delegation patterns.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BoHWxWydKcSErvPbmyTWoQ.png" /></figure><p>Let’s be honest: just about everyone knows how to prompt a chatbot to generate a simple script or debug an error. But moving from casual sandbox chats to building predictable, enterprise-grade workflows with modern developer tools like Claude Code requires a completely different mindset.</p><p>To build production-grade setups, you have to look past the chat interface and understand the underlying mechanics of agentic systems. After diving deep into Anthropic’s advanced curriculum — covering everything from <em>Claude Code 101</em> and <em>Claude Platform 101</em> to <em>MCP Advanced Topics</em> and <em>Intro to Subagents</em> — I compiled the most impactful engineering patterns and architectural guardrails I uncovered. Here is how to actually take control of the platform.</p><h3>A. Rethinking the Context Window</h3><blockquote>Context Isn’t a Passive Bucket</blockquote><p>We often visualize the context window as a passive bucket waiting to be filled. Mechanically, however, every action taken during a development session — user prompts, massive codebase reads, tool calls, and verbose tool outputs — rapidly eats away at this finite memory space. Because space is finite, optimizing how you allocate it is one of the most critical skills an AI engineer can master.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9aMNi0JeRusMpWx1OVW1UQ.jpeg" /><figcaption>Figure 1: How running tool calls and system operations dynamically deplete your memory space.</figcaption></figure><p><strong>Taming the Context Beast: Compaction, Caching, and Archival</strong></p><p>When your context window approaches its structural limit, Claude automatically triggers server-side <strong>compaction</strong>. <strong>Compaction</strong> summarizes important semantic details while entirely removing historical, unnecessary tool call results to reclaim free space.</p><p>The catch? Auto-compaction is a lossy process — lean on it too heavily, and you risk losing crucial project nuances. Instead of relying on the defaults, you should proactively design around these four architectural patterns:</p><ol><li><strong>Just-in-Time Context:</strong> Avoid loading an entire directory or codebase upfront. Load only what the agent absolutely requires <em>now</em>, and give it the autonomy to pull more data via local tools only when explicitly requested.</li><li><strong>Server-Side Compaction Control:</strong> In high-volume production API environments, you can explicitly manage histories by injecting a context_management key into your message requests holding an edit with a &quot;type&quot;: &quot;compact&quot;. This forces an elegant server-side compression loop without breaking the session.</li><li><strong>Prompt Caching:</strong> Mark stable, rarely changing components of your request — such as rigid tool definitions, structural system prompts, or colossal reference documentation — as cached. This allows you to reuse them across subsequent calls at a fraction of standard latency and cost.</li><li><strong>The Memory Tool Primitive:</strong> For critical context that must persist across completely separate user sessions (such as explicit user preferences or running project notes), Anthropic provides the <strong>memory tool primitive</strong>. Here, Claude reads and writes directly to a dedicated local or database directory via native tool calls. Anthropic auto-injects an internal system instruction forcing Claude to check this directory before initiating any work, bypassing session limits entirely.</li></ol><p><strong>Pro-Tip for Local Dev Workflows:</strong> Run the manual /compact command when working on a long, specific feature to trim historical fat. Use the /clear command when transitioning to a brand-new feature to guarantee that the previous conversation&#39;s bias does not bleed into your new environment.</p><h3><strong>2.</strong> Fine-Tuning the Engine — Temperature &amp; Routing</h3><blockquote>The Creativity Dial</blockquote><p>Controlling output variance is critical when moving from sandbox prototyping to production.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FCt0HBodjZ08Og_BhKxNLw.png" /><figcaption>Figure 2: How temperature scales token selection probabilities from deterministic to random.</figcaption></figure><p>Adjusting the temperature changes token distribution curves. At low values (near 0.0), the model aggressively picks the mathematically highest-probability token, creating highly deterministic results. High values (near 1.0) distribute probabilities evenly for creative variety.</p><p><strong>Selecting the Right Temperature Matrix</strong></p><p>To make this practical, different tasks dictate entirely separate ranges:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uDDMGSHntl8KY5NEDC_zOQ.png" /><figcaption>Figure 3: Mapping temperature thresholds to specific business applications</figcaption></figure><p><strong>Model Routing &amp; Adaptive Thinking</strong></p><p>In high-scale systems, routing different tasks to different models under a single workflow endpoint saves immense cost: classify files rapidly using <strong><em>Haiku</em></strong>, draft messages using <strong><em>Sonnet</em></strong>, and reserve heavy lifting like complex analysis for <strong><em>Opus</em></strong>. Furthermore, with <strong>Opus 4.7</strong>, thinking is entirely adaptive — the model dynamically determines its own token reasoning budget based on the complexity of the problem.</p><h3>3. Mastering Subagents &amp; Skills</h3><blockquote>When Subagents Shine (and When They Hurt)</blockquote><p>Subagents run in parallel with your main agent but maintain completely isolated context windows. They are phenomenal when exploration can be entirely decoupled from execution (e.g., querying an architecture layout and passing a single crisp answer back to the main thread).</p><p><strong>Review with a Subagent</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*M4aTQUMdvmJcYfmG6tL0Ig.png" /><figcaption>Figure 4: Coding Review with a subagent</figcaption></figure><p>Before you push a PR, ask Claude to use a subagent to review your changes. A reviewer sub-agent sees the changes in a separate context. It runs git diff, reads the modified files, and applies its specialized review criteria without the history of how the code was written.</p><ul><li>The subagent runs in its own context window with fresh eyes — it doesn’t carry the bias of the main agent that just spent the session writing the code.</li><li>When creating a code-reviewer subagent, restrict it to <strong>read-only </strong>tools. A reviewer should flag issues, not edit files.</li><li>Claude reviews code more effectively when the code is presented as being authored by someone else.</li></ul><p>However, the courses explicitly highlighted configurations where subagents fail:</p><ul><li><strong>Expert Claims Add No Value:</strong> Prompting a subagent with&quot;you are a python expect&quot;provides zero lift — Claude already possesses that baseline data.</li><li><strong>Sequential Pipelines Break:</strong> Forcing a linear chain where Agent A finds a bug, Agent B debugs it, and Agent C fixes it frequently fails because software engineering steps are deeply interdependent.</li><li><strong>Test Runners Degrade Performance:</strong> Shielding full test outputs behind subagents actually harms diagnostics; benchmarks show test-runner subagent patterns perform worse across configurations.</li></ul><h4>Proactive Delegation &amp; Lifecycles</h4><p>You can scoped subagents at a <strong>Project-level</strong> or <strong>User-level</strong>. To force the primary agent to delegate automatically without manual prompt triggers, inject the phrase &quot;proactively&quot; directly into your subagent’s metadata description block.</p><pre>name: code_reviewer<br>description: Proactively suggest running this agent after major code changes...</pre><h4>Skills vs. Tools vs. MCP</h4><p>A major point of clarity from the courses was defining the exact boundaries of extensions:</p><blockquote><em>💡</em> <em>“</em><strong><em>Tools</em></strong><em> are for your stuff, </em><strong><em>Skills</em></strong><em> are for your processes, and </em><strong><em>MCP</em></strong><em> is for everyone else’s stuff.”</em></blockquote><p><strong>Skills</strong> are on-demand folders of markdown instructions (SKILL.md) that activate automatically only when Claude detects a situational process match. They keep context lean because only their names and descriptions are indexed at startup.</p><blockquote><strong><em>The /commit-push-pr Skill<br></em></strong>The /commit-push-pr skill handles the commit, push, and PR creation all in one step. Instead of doing each manually, just run the skill &amp; Claude takes care of it.</blockquote><h3>4. Operational Automation &amp; Security using Hooks</h3><blockquote>Deterministic Lifecycles</blockquote><p>Claude Code allows developers to inject deterministic scripts at exact points in its runtime lifecycle via PreToolUse and PostToolUse hooks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ouWKj8K0SdVa32loHjJ07Q.png" /><figcaption>Figure 5: The deterministic execution order of hooks surrounding tool operations.</figcaption></figure><p>Common production use cases include automated formatting right after an edit tool exits, compliance logging, or preventing dangerous operations on production files.</p><p>Hooks are defined in Claude settings files. You can add them to:</p><ul><li>Global — <strong>~/.claude/settings.json</strong> (affects all projects)</li><li>Project — <strong>.claude/settings.json</strong> (shared with team)</li><li>Project (not committed) — <strong>.claude/settings.local.json</strong> (personal settings)</li></ul><p><strong>Securing the Pipeline</strong></p><p>Because hooks execute commands automatically, hardening them against vulnerabilities is paramount.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*UtGHvOT5AgK3DNT9CSNWEQ.png" /><figcaption>Figure 6: Five core security rules for writing safe development hooks.</figcaption></figure><p>A standout operational takeaway is using <strong>absolute paths</strong>(rather than relative paths) for scripts to stop path interception. Because absolute paths make sharing static files across diverse teammate environments challenging, the recommended best practice is tracking a settings.example.json containing a $PWD placeholder in your repository, then running a setup script (npm run setup) to programmatically output a machine-specific, uncommitted settings.local.json file.</p><h3>5. The Model Context Protocol (MCP) Ecosystem</h3><blockquote>Bridging Models and Data</blockquote><p>The Model Context Protocol establishes an open standard for how an AI client coordinates with decoupled, external servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VHvJQSPepZkd-FZQcOHKbA.png" /><figcaption>Figure 7: The structural lifecycle of an MCP tool call request.</figcaption></figure><p>When constructing an MCP Server, you rely on three core pillars:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3wlrL9o4zJ2lQA1-ElLWFg.png" /><figcaption>Figure 8: The foundational architectural elements of an MCP server implementation.</figcaption></figure><ul><li><strong>Tools (Model-controlled):</strong> Given to provide new capabilities; Claude decides exactly when to call them.</li><li><strong>Resources (App-controlled):</strong> Used strictly for pulling raw data or adding context directly into your application’s UI layer.</li><li><strong>Prompts (User-controlled):</strong> Predefined, thoroughly tested workflows anchored to user-initiated actions like slash commands or button clicks.</li></ul><blockquote><strong>Advanced Concept: Sampling</strong></blockquote><blockquote>One of the most powerful advanced patterns is <strong>Sampling</strong>, which shifts the financial and computational burden of token generation. Instead of an MCP server directly calling an LLM API itself, it passes a structured sampling request back to the host client. The client invokes its own connection to Claude and returns the response, meaning public server creators don’t have to manage API keys or take on expensive text-generation costs for external users.</blockquote><h3>Conclusion</h3><p>Stepping out of basic chat paradigms and stepping into adaptive token management, automated hook constraints, isolated subagents, and standardizing connections through MCP represents the modern threshold of AI engineering. Building software alongside Claude isn’t just about crafting a better prompt — it’s about building robust, secure architectures.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=693d5dd2d5f1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/design-bootcamp/engineering-with-claude-code-architectural-insights-from-anthropics-expert-courses-693d5dd2d5f1">Engineering with Claude Code: Architectural Insights from Anthropic’s Expert Courses</a> was originally published in <a href="https://medium.com/design-bootcamp">Bootcamp</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Notebooks to Pipelines: My GSoC’25 Journey Modernizing Kubeflow Kale with KFPv2 and…]]></title>
            <link>https://medium.com/@amritkmr4272/from-notebooks-to-pipelines-my-gsoc25-journey-modernizing-kubeflow-kale-with-kfpv2-and-e098f194208c?source=rss-8b3118e8137d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e098f194208c</guid>
            <category><![CDATA[kubeflow-kale]]></category>
            <category><![CDATA[gsoc-2025]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[google-summer-of-code]]></category>
            <category><![CDATA[kubeflow]]></category>
            <dc:creator><![CDATA[AmritKmr]]></dc:creator>
            <pubDate>Sun, 31 Aug 2025 11:30:09 GMT</pubDate>
            <atom:updated>2025-11-29T18:53:55.012Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*AsZ5MZ91-O1_PcAK_06eaw.jpeg" /></figure><h3>From Notebooks to Pipelines: My GSoC’25 Journey Modernizing Kubeflow Kale with KFPv2 and Jupyterlabv4</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*30zEKZ27CcehzntK0IQWSA.png" /></figure><p>When I first applied for Google Summer of Code 2025, I knew I wanted to work on something that would challenge me while making a meaningful impact on the machine learning community. My master’s dissertation at Newcastle University involved extensive work with MLOps and distributed training pipelines, which naturally led me to explore Kubeflow’s ecosystem during my research engineering role. What I didn’t expect was to find myself completely rebuilding the backend architecture of Kubeflow Kale, a project that helps data scientists convert Jupyter notebook into production-ready ML pipelines.</p><h3><em>The Problem: A Deprecated Foundation</em></h3><p>Kubeflow Kale had a fundamental problem that threatened its future viability. The entire system was built on KFPv1 (Kubeflow Pipelines v1), which had been deprecated and was incompatible with the newer, more robust KFPv2. This wasn’t just a minor version update — it represented a complete architectural shift in how machine learning pipelines are authored and executed.</p><p>The old system’s limitations were clear:</p><ul><li><strong>Tied to deprecated technology</strong>: Built entirely on KFPv1 SDK, now unsupported</li><li><strong>Limited backend flexibility</strong>: YAML generation was locked to Argo Workflows engine</li><li><strong>Direct YAML generation</strong>: Bypassed modern pipeline authoring patterns</li><li><strong>Poor metadata integration</strong>: Lacked robust artifact tracking and lineage</li></ul><h3>Understanding the New Paradigm</h3><p>KFPv2 introduced a fundamentally different approach. Instead of directly generating YAML files, it embraces a Python-centric authoring experience using decorators like @dsl.component and @dsl.pipeline. The workflow now requires generating a Python DSL script first, which then gets compiled into a platform-neutral Intermediate Representation (IR) YAML.</p><p>This change brought several advantages:</p><ul><li><strong>Python-centric authoring</strong>: Uses decorators like @dsl.component and @dsl.pipeline for cleaner code</li><li><strong>Automated YAML generation</strong>: Creates platform-neutral Intermediate Representation (IR) YAML</li><li><strong>Better metadata integration</strong>: Automatic ML Metadata registration with rich lineage tracking</li><li><strong>Type-safe artifact systems</strong>: First-class support for Model, Dataset, HTML, andMetrics artifacts</li><li><strong>Improved storage performance</strong>: Native cloud storage support (S3, GCS) instead of shared volumes</li><li><strong>Backend flexibility</strong>: IR YAML can run on any KFP-compliant backend</li></ul><h3>The Technical Challenge</h3><p>My mentors, Stefano Fioravanzo and Eder Ignatowicz, helped me understand that this wasn’t just about updating APIs — it was about rethinking how notebook cells translate into pipeline components. The core challenge was creating a new templating system that could intelligently convert annotated Jupyter notebooks into valid KFPv2 DSL Python scripts. Initially, we decided to create a POC extension, just to understand the workflow with new Jupyterv4 and KFPv2.</p><p>I chose Jinja2 for the templating engine because of its flexibility and robust template inheritance features. The new workflow I implemented follows these steps:</p><ol><li><strong>Parse the annotated notebook</strong> and extract cell metadata and dependencies</li><li><strong>Generate a Python DSL script</strong> using Jinja2 templates that conform to KFPv2 standards</li><li><strong>Use KFPv2’s Compiler</strong> to automatically convert the script into IR YAML</li><li><strong>Upload and execute</strong> the compiled pipeline on Kubeflow Pipelines</li></ol><p>Each step presented its own challenges. For instance, handling data persistence between pipeline steps required completely rethinking how variables and artifacts flow through the system. In KFPv1, we used marshal and persistent volume claims. KFPv2’s artifact system is more sophisticated but requires careful type management and metadata tracking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m6Hvi1pf7jZFDo9NioPsxg.png" /><figcaption>New Kale’s Extension UI enabling one-click notebook-to-pipeline deployment</figcaption></figure><h3>An Accomplished Marathon</h3><p>What the demo video don’t capture is the hundreds of hours spent in debugging. Moving from a working KFPv1 system to KFPv2 meant encountering errors at every layer of the stack. Some days I’d fix one package dependency error only to discover five more compatibility issues.</p><p>The frontend presented its own challenges. The existing JupyterLab plugin was built with older versions of TypeScript and React components. I ended up fixing approximately 250–300 errors related to deprecated Material-UI components, validation checks, and type definitions. Each error felt like solving a puzzle piece, and slowly the bigger picture started coming together.</p><p>There were moments of frustration when a pipeline would fail silently, or when the frontend would crash on seemingly simple operations. But there were also breakthrough moments — like the first time I saw a notebook successfully converted to a KFPv2 pipeline, or when the pipeline graph finally displayed correctly in the Kubeflow UI.</p><h3>The Breakthrough Moment 💡</h3><p>The real validation came when I created my first end-to-end demo. I took a simple machine learning workflow — loading data, training a model, and evaluating results — and watched it seamlessly convert from a Jupyter notebook into a full Kubeflow pipeline.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FZowhjOubxmM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DZowhjOubxmM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FZowhjOubxmM%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/be24813ad1bdd862106f8d20a33c3a46/href">https://medium.com/media/be24813ad1bdd862106f8d20a33c3a46/href</a></iframe><p>You can see this demo in action<a href="https://www.youtube.com/watch?v=ZowhjOubxmM"> here</a>. What might look like a simple interface hiding a complex transformation represents days of architectural work. Every click in that interface triggers the entire pipeline conversion process I’d rebuilt from the ground up.</p><h3>Beyond the Code ✨</h3><p>Working on Kale taught me that open source development is as much about communication and documentation as it is about coding. I spent considerable time creating comprehensive README files, architectural documentation, and bug tracking systems for future contributors.</p><p>One of my proudest achievements was getting the backend PR merged into the main repository. This wasn’t just about code review — it required explaining complex architectural decisions to maintainers who understood the system’s history and requirements better than anyone.</p><p>The project also taught me about the broader ML ecosystem. Kubeflow isn’t just about running pipelines; it’s about creating reproducible, scalable machine learning workflows that teams can rely on. Every design decision needed to consider not just technical requirements but also user experience for data scientists who might be new to containerized workflows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KgwD9ViJLUDalv0PvCfRcw.png" /></figure><h3>Current State and What’s Next</h3><p>The project has reached a significant milestone with the <strong>backend PR successfully merged</strong> into the main repository. The core functionality for converting notebooks to KFPv2 DSL scripts and compiling them to YAML is complete and working. The frontend JupyterLab plugin is functional for existing workflows, though still under active development.</p><p><strong>What’s been completed:</strong></p><ul><li>Complete backend rewrite for KFPv2 compatibility</li><li>Jinja2 templating system for DSL generation</li><li>Integration with KFPv2 SDK compiler</li><li>Functional JupyterLab plugin interface</li><li>Resolution of 250–300+ legacy compatibility issues</li></ul><p><strong>Currently pending issues:</strong></p><ol><li>Fix Progress bar in left panel during compile and run.</li><li>Fix opening of tag editor after clicking edit pencil icon above cells.</li><li>Fix weakmap warning related in InlineMetadata.tsx which gets displayed while toggling the kale icon to enable state. It can be skipped for now in UI.</li><li>Fix Kale icon in LeftPanel</li><li>Fix building and packaging of labextension related with package.json, pyproject.toml, and tsconfig.json</li></ol><p><strong>What’s left to do:</strong></p><ul><li>Finalize the frontend PR (currently in v2.0-frontend-dev branch) with bug-fixes</li><li>Prepare for community release and broader adoption</li></ul><p>The foundation is solid, and Kale now has a modern, maintainable architecture that can evolve with the Kubeflow ecosystem. More importantly, the project maintains its core promise: data scientists can continue working in the notebook environment they love while automatically getting the benefits of production-ready ML pipelines. The complexity is hidden behind a simple interface, but the underlying system is now built on solid, future-proof foundations.</p><h3>What I Learned through GSoC</h3><p>This GSoC project taught me that sometimes the most valuable contributions aren’t about adding new features — they’re about modernizing existing systems to ensure they remain viable. It’s unglamorous work that users might never directly notice, but it’s essential for the long-term health of open source projects.</p><p>I also learned the importance of understanding not just what you’re building, but why it matters. Kale exists because there’s a real gap between notebook-driven experimentation and production ML systems. Bridging that gap requires both technical sophistication and deep empathy for user workflows.</p><p>The project pushed me to think about software architecture in new ways. When you’re rebuilding a system that people depend on, every decision carries weight. You can’t just make it work — you have to make it work reliably, maintainable, and in a way that other contributors can understand and extend.</p><h3><strong>Looking Forward </strong>👨‍💻</h3><p>The work isn’t finished. The frontend still needs refinement, and we’re planning comprehensive testing across different environments. But the foundation is solid. Kale now has a modern, maintainable architecture that can evolve with the Kubeflow ecosystem.</p><p>More importantly, the project maintains its core promise: data scientists can continue working in the notebook environment they love while automatically getting the benefits of production-ready ML pipelines. The complexity is hidden behind a simple interface, but the underlying system is now built on solid, future-proof foundations.</p><blockquote>Check out the <a href="https://github.com/kubeflow-kale/kale"><strong>repository</strong></a> and our updated <a href="https://github.com/kubeflow-kale/kale/blob/v2.0-frontend-dev/README.md"><strong>README</strong></a> to get started.</blockquote><p>Working on open-source infrastructure might not always be the flashiest work, but it’s some of the most impactful. Every improvement to tools like Kale helps thousands of data scientists move faster from idea to production. And in a field moving as quickly as machine learning, that acceleration matters. See you next time!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e098f194208c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unleashing the Power of ML and LLM Models on NVIDIA Jetson Orin]]></title>
            <link>https://medium.com/@amritkmr4272/unleashing-the-power-of-ml-and-llm-models-on-nvidia-jetson-orin-6ff0b512d2dc?source=rss-8b3118e8137d------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ff0b512d2dc</guid>
            <category><![CDATA[model-quantization]]></category>
            <category><![CDATA[edge-ai]]></category>
            <category><![CDATA[nvidia-jetson]]></category>
            <category><![CDATA[llms-on-edge]]></category>
            <category><![CDATA[tensorrt-optimization]]></category>
            <dc:creator><![CDATA[AmritKmr]]></dc:creator>
            <pubDate>Thu, 03 Apr 2025 14:58:04 GMT</pubDate>
            <atom:updated>2025-04-03T14:58:04.320Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4HKuphDvBGspvcbbKk3XMg.jpeg" /></figure><p>In the rapidly evolving landscape of edge AI, the NVIDIA Jetson Orin has emerged as a powerhouse for deploying machine learning and large language models in resource-constrained environments. As organizations increasingly push AI capabilities to the edge, understanding how to optimize model performance on these specialized devices becomes crucial. Based on my hands-on experience benchmarking various models on the Jetson platform, I’ll share insights on deployment strategies, quantization techniques, and performance optimization approaches.</p><p><strong>The Edge AI Revolution and Jetson Orin</strong></p><p>The NVIDIA Jetson Orin represents a significant leap in edge computing capabilities, offering datacenter-class AI performance in a compact form factor. With up to 275 TOPS of AI performance, it enables sophisticated machine learning workloads that were previously confined to cloud environments.</p><p>What makes the Jetson Orin particularly compelling is its ability to run models locally, reducing latency, addressing privacy concerns, and enabling operation in environments with limited connectivity. From autonomous robots to smart cameras and industrial automation, the applications are vast and growing.</p><h3>Setting Up Your Jetson Orin for ML Development</h3><p>Before diving into optimization techniques, proper setup is essential. The Jetson platform uses JetPack SDK, NVIDIA’s comprehensive solution that includes:</p><ul><li>Ubuntu-based Linux OS</li><li>CUDA-X libraries for accelerated computing</li><li>Tools for AI and computer vision</li><li>The latest CUDA, cuDNN, and TensorRT packages</li></ul><p>After installing JetPack, you’ll want to set up your preferred ML frameworks. The most common choices are:</p><ul><li>PyTorch (with torchvision for computer vision tasks)</li><li>TensorFlow/Keras</li><li>ONNX Runtime</li></ul><p>For PyTorch users, NVIDIA provides optimized wheels specifically for Jetson devices, significantly improving performance over standard builds.</p><h3>Optimizing Models for Jetson: The Quantization Advantage</h3><p>One of the most powerful techniques for improving inference performance on edge devices is quantization. This process reduces the precision of a model’s weights and activations, decreasing memory requirements and computational demands while maintaining reasonable accuracy.</p><h4>FP16 Precision</h4><p>The most straightforward optimization is moving from FP32 (32-bit floating point) to FP16 (16-bit floating point) and implementing FP16 precision is relatively simple with TensorRT:</p><pre>dummy_input = torch.randn(1, 3, 224, 224).cuda()<br>trt_model = torch2trt(<br>        model,<br>        [dummy_input],<br>        fp16_mode=fp16,<br>        max_workspace_size=1 &lt;&lt; 30,<br>    )</pre><p>This simple change can nearly double inference speed while having minimal impact on accuracy for many vision models. For even greater performance gains, INT8 quantization reduces precision further to 8-bit integers. This requires calibration using representative data to determine appropriate scaling factors. INT8 can deliver 2–4x performance improvements over FP32, though with a slightly greater accuracy trade-off.</p><h3>TensorRT: The Secret Weapon for Jetson Performance</h3><p>NVIDIA’s TensorRT is a high-performance deep learning inference optimizer and runtime that performs several crucial optimizations:</p><ol><li><strong>Layer and tensor fusion</strong> — Combining operations to reduce memory transfers</li><li><strong>Kernel auto-tuning</strong> — Selecting the most efficient GPU kernels</li><li><strong>Dynamic tensor memory</strong> — Minimizing memory footprint</li><li><strong>Multi-stream execution</strong> — Enabling parallelism</li></ol><p>The improvement from PyTorch to TensorRT is substantial, often yielding 3–5x performance gains on Jetson hardware.</p><h3>Real-world Performance Considerations</h3><p>When deploying models on Jetson Orin, it’s important to understand the practical performance-power tradeoffs. For real-time applications like computer vision, several key factors emerge:</p><ul><li><strong>Model Architecture Impact</strong>: Lighter models like SqueezeNet and MobileNetV3 achieve significantly higher FPS than heavier models like ResNet50.</li><li><strong>Diminishing Returns</strong>: Beyond certain FPS thresholds, power consumption increases dramatically with minimal performance gains.</li><li><strong>TensorRT Advantage</strong>: TensorRT-optimized models consistently outperform their native framework counterparts.</li></ul><h3>Deploying LLMs on Jetson Orin</h3><p>Deploying Large Language Models (LLMs) on Jetson Orin presents unique challenges and opportunities.</p><p>For LLMs, the key considerations include:</p><h4>Model Compression Techniques:</h4><ul><li><strong>Quantization</strong>: 4-bit and 8-bit quantization can make larger language models feasible on edge devices</li><li><strong>Pruning</strong>: Removing less important weights to reduce model size</li><li><strong>Knowledge Distillation</strong>: Training smaller “student” models to mimic larger “teacher” models</li></ul><h4>Optimization Libraries:</h4><ul><li><strong>NVIDIA TensorRT-LLM</strong>: Specialized for optimizing LLMs on NVIDIA hardware</li><li><strong>ONNX Runtime</strong>: Provides edge-optimized inference</li></ul><h4>Practical LLM Deployment Options</h4><p>For Jetson Orin, smaller LLMs in the 1–7B parameter range are most practical. Models like:</p><ul><li>Llama 2 7B (quantized to INT8)</li><li>Phi-2 (2.7B parameters)</li><li>Gemma 2B</li></ul><p>These can be deployed using libraries like TensorRT-LLM with appropriate quantization, enabling impressive performance for tasks like text generation, translation, and question answering directly on the edge device.</p><h3>Power Management and Thermal Considerations</h3><p>As demonstrated in my benchmarking script, power monitoring is crucial for edge deployments. The jtop library provides real-time power statistics:</p><pre>with jtop() as jetson:<br>    # Record power usage during inference<br>    power_readings.append(jetson.stats[&#39;Power TOT&#39;])</pre><p>For deployment in production environments, consider:</p><ol><li><strong>Power Modes</strong>: Jetson Orin supports different power modes that can be selected based on performance requirements</li><li><strong>Thermal Management</strong>: Proper cooling solutions are essential for sustained performance</li><li><strong>Scheduling</strong>: Intelligent scheduling of inference tasks can optimize power usage</li></ol><h3>Conclusion: The Future of Edge AI with Jetson Orin</h3><p>The NVIDIA Jetson Orin represents a significant step forward in Edge AI capabilities. Through careful optimization using techniques like quantization and frameworks like TensorRT, developers can deploy sophisticated ML and even LLM models in edge environments with impressive performance.</p><p>As Edge AI continues to evolve, the ability to run complex models locally will enable new applications across industries. The benchmarking approach demonstrated in my script provides a foundation for understanding the performance-power tradeoffs essential for successful edge deployments.</p><p>Whether you’re developing computer vision applications, natural language processing systems, or other AI solutions, the Jetson Orin platform combined with proper optimization techniques offers a powerful platform for bringing intelligence to the edge.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ff0b512d2dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Model Serving at Scale: A Deep Dive into KServe and Kubeflow]]></title>
            <link>https://medium.com/@amritkmr4272/model-serving-at-scale-a-deep-dive-into-kserve-and-kubeflow-b05bfa3c004b?source=rss-8b3118e8137d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b05bfa3c004b</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[kserve]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[kubeflow]]></category>
            <category><![CDATA[ml-engineering]]></category>
            <dc:creator><![CDATA[AmritKmr]]></dc:creator>
            <pubDate>Mon, 03 Feb 2025 17:13:37 GMT</pubDate>
            <atom:updated>2025-02-03T17:24:48.421Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tLJ2p4dRBTslQha7NGOPlQ.png" /></figure><p>In the modern ML ecosystem, deploying models efficiently and at scale remains a significant challenge. Organizations need robust platforms and tools to efficiently manage their ML workflows from development to production. While training models have become increasingly streamlined, serving them in production with high availability, scalability, and monitoring capabilities requires robust infrastructure. This article explores how Kubeflow and KServe work together to create a comprehensive solution for machine learning operations at scale.</p><h3>Understanding Kubeflow</h3><p>Kubeflow represents a significant advancement in the MLOps space, serving as a comprehensive platform for building and deploying machine learning workflows on Kubernetes. At its core, Kubeflow aims to make deployments of ML workflows on Kubernetes simple, portable, and scalable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A-y9S51-HUgydNxzKxvp7g.jpeg" /><figcaption>Kubeflow Ecosystem</figcaption></figure><h3>The Kubeflow Architecture</h3><p>Kubeflow operates as a cloud-native platform that brings together several key components essential for ML operations:</p><ol><li><strong>Pipeline Management</strong>: Kubeflow provides a robust pipeline system for creating and managing end-to-end ML workflows. These pipelines enable organizations to automate the entire ML lifecycle, from data preparation to model training and deployment.</li><li><strong>Notebook Environments</strong>: The platform includes integrated Jupyter notebooks that allow data scientists to develop and test models in an environment that seamlessly connects with other Kubeflow components.</li><li><strong>Training Operators</strong>: Kubeflow supports distributed training through various frameworks, including TensorFlow, PyTorch, and XGBoost, making it possible to train models efficiently at scale.</li><li><strong>Experiment Tracking</strong>: The platform offers capabilities for tracking experiments, enabling teams to monitor and compare different model versions and training runs.</li></ol><h3>Benefits of Kubeflow</h3><p>The platform delivers several key advantages for organizations:</p><ul><li><strong>Standardization</strong>: Kubeflow provides a standardized approach to ML workflows across different cloud providers and on-premises environments.</li><li><strong>Reproducibility</strong>: The platform ensures that ML workflows are reproducible, making it easier to maintain consistency across different environments.</li><li><strong>Scalability</strong>: Built on Kubernetes, Kubeflow inherits its robust scaling capabilities, allowing organizations to handle varying workload demands efficiently.</li><li><strong>Collaboration</strong>: The integrated environment facilitates better collaboration between data scientists, ML engineers, and operations teams.</li></ul><h3>Kubeflow Components in the ML Lifecycle</h3><p>Kubeflow provides a comprehensive suite of components that support different stages of the machine learning lifecycle:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q3l8RbtBsnv5Mv1POQuHMQ.jpeg" /></figure><h4>1. Jupyter Notebooks for Development</h4><p>The Jupyter Notebooks component enables data scientists to:</p><ul><li>Create and share documents containing live code</li><li>Perform interactive data analysis</li><li>Develop and test models in an isolated environment</li><li>Integrate with version control systems</li></ul><h4>2. Pipeline Orchestration</h4><p>Kubeflow Pipelines offers:</p><ul><li>A platform for building and deploying portable, scalable ML workflows</li><li>Component-based architecture for reusable workflow elements</li><li>Visual interface for pipeline creation and monitoring</li><li>Integration with various ML frameworks and tools</li></ul><h4>3. Training Service</h4><p>The training component provides:</p><ul><li>Distributed training capabilities for deep learning models</li><li>Support for popular frameworks like TensorFlow, PyTorch, and XGBoost</li><li>Resource optimization for training jobs</li><li>Hyperparameter tuning functionality</li></ul><h4>4. Model Management</h4><p>Kubeflow’s model management capabilities include:</p><ul><li>Version control for ML models</li><li>Model metadata tracking</li><li>Artifact storage and retrieval</li><li>Model lineage tracking</li></ul><h4>5. Experiment Tracking</h4><p>The experimentation framework enables:</p><ul><li>Systematic recording of training runs</li><li>Comparison of different model versions</li><li>Parameter and metric logging</li><li>Results visualization and analysis</li></ul><h3>KServe: Enhanced Model Serving</h3><p>While Kubeflow provides the foundation for ML workflows, KServe focuses specifically on the model serving aspect, offering advanced capabilities for deploying and managing models in production environments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*DzBoxxNRH9daSl97gjgw2g.png" /></figure><h3>KServe Architecture and Integration</h3><p>KServe integrates seamlessly with Kubeflow while providing specialized features for model serving:</p><ul><li><strong>Serverless Architecture</strong>: KServe leverages Kubernetes-native serverless frameworks to enable efficient resource utilization.</li><li><strong>Multi-Framework Support</strong>: The platform supports multiple ML frameworks, allowing organizations to serve models from different environments consistently.</li><li><strong>Inference Graph</strong>: KServe enables the creation of complex inference patterns, including model chaining and en-sembling.</li></ul><h3>Advanced Serving Capabilities</h3><p>KServe excels in providing sophisticated model-serving features:</p><ol><li><strong>Intelligent Resource Management</strong>: The platform optimizes resource allocation across multiple models, ensuring efficient utilization while maintaining performance standards.</li><li><strong>Dynamic Scaling</strong>: KServe implements auto-scaling capabilities that respond to real-time demand, automatically adjusting resources to maintain optimal performance while controlling costs.</li><li><strong>Deployment Strategies</strong>: The platform supports advanced deployment patterns such as:</li></ol><ul><li>Canary deployments for testing new versions</li><li>Blue-green deployments for zero-downtime updates</li><li>Model versioning for maintaining multiple variants</li></ul><p><strong>Performance Optimization</strong>: KServe incorporates various techniques to enhance serving performance:</p><ul><li>Request batching and caching</li><li>GPU acceleration support</li><li>Optimized model loading and unloading</li><li>Traffic management and load balancing</li></ul><h3>Why Combine KServe with Kubeflow? (A match made in cloud heaven!)</h3><p>Kubeflow, the machine learning toolkit for Kubernetes, provides a complete ML platform. When combined with KServe, it offers:</p><ol><li>End-to-end ML workflow management</li><li>Seamless integration between model training and serving</li><li>Unified infrastructure for both development and production</li><li>Consistent experience across cloud providers and on-premises deployments</li></ol><h3>Best Practices and Production Considerations (Because Nobody Likes a Model Behaving Badly!)</h3><ol><li><strong>Resource Management</strong></li></ol><ul><li>Properly size resource requests and limits.</li><li>Implement horizontal pod autoscaling.</li><li>Use node affinity for GPU workloads.</li></ul><p>2. <strong>Security (Better Safe than Sorry!)</strong></p><ul><li>Implement RBAC policies.</li><li>Secure model artifacts.</li><li>Use network policies to control traffic.</li></ul><p>3.<strong> Monitoring and Observability (Use Prometheus &amp; Grafana)</strong></p><ul><li>Set up comprehensive metrics collection</li><li>Implement request logging</li><li>Configure alerts for critical metrics</li></ul><h3>Setting Up the Infrastructure (Time to Get Your Kube On!)</h3><p>To get started with Kubeflow &amp; KServe, you’ll need to follow these steps (don’t worry, we won’t make you jump through hoops… just yaml files or commands):</p><blockquote><strong>Prerequisites -<br></strong>· 32 GB of RAM recommended<br>· 16 CPU cores recommended<br>·kind 0.26+<br>·docker<br>· Linux kernel subsystem changes to support many pods<br>sudo sysctl fs.inotify.max_user_instances=2280</blockquote><h3>Install with a single command</h3><h4>Create kind cluster:</h4><pre>cat &lt;&lt;EOF | kind create cluster --name=kubeflow --config=-<br>kind: Cluster<br>apiVersion: kind.x-k8s.io/v1alpha4<br>nodes:<br>- role: control-plane<br>  image: kindest/node:v1.32.0@sha256:c48c62eac5da28cdadcf560d1d8616cfa6783b58f0d94cf63ad1bf49600cb027<br>  kubeadmConfigPatches:<br>  - |<br>    kind: ClusterConfiguration<br>    apiServer:<br>      extraArgs:<br>        &quot;service-account-issuer&quot;: &quot;kubernetes.default.svc&quot;<br>        &quot;service-account-signing-key-file&quot;: &quot;/etc/kubernetes/pki/sa.key&quot;<br>EOF</pre><h4><strong>Save kubeconfig:</strong></h4><pre>kind get kubeconfig --name kubeflow &gt; /tmp/kubeflow-config<br>export KUBECONFIG=/tmp/kubeflow-config</pre><h4>Create a Secret based on existing credentials in order to pull the images:</h4><pre>docker login<br><br>kubectl create secret generic regcred \<br>    --from-file=.dockerconfigjson=$HOME/.docker/config.json \<br>    --type=kubernetes.io/dockerconfigjson</pre><p>You can install all Kubeflow official components provided in the repository <a href="https://github.com/kubeflow/manifests"><strong>Link</strong></a>(residing under apps) and all common services (residing under common) using the following command:</p><pre>while ! kustomize build example | kubectl apply --server-side --force-conflicts -f -; do echo &quot;Retrying to apply resources&quot;; sleep 20; done</pre><p>Congratulations! You can now start experimenting and running your end-to-end ML workflows with Kubeflow.</p><h3>Key Takeaways and Challenges</h3><ul><li><strong>Infrastructure Foundation Matters — </strong>The success of your model serving architecture heavily depends on your infrastructure setup. My experience shows that investing time in properly configuring your Kubernetes cluster pays dividends in the long run. This includes careful consideration of resource allocation, network policies, and security configurations.</li><li><strong>Scalability Is More Than Just Numbers — </strong>While KServe provides excellent automatic scaling capabilities, effective scalability encompasses more than just handling increased load. The ability to scale to zero during quiet periods has shown significant cost savings in production environments, sometimes reducing infrastructure costs by up to 40%.</li><li><strong>Monitoring Drives Success — </strong>Comprehensive monitoring has proven to be the cornerstone of successful model-serving implementations. Organizations that implement detailed monitoring from day one gain invaluable insights into their model’s performance, resource utilization, and potential bottlenecks. This proactive approach to monitoring helps prevent issues before they impact production services.</li><li>Although I have provided just a single way of installation, there are 2 more options. One is the <strong>individual components and services installation</strong>(which I had to follow as my system config was less than the pre-prerequisite!), and the other is the <strong>Packaged Distributions </strong>for cloud providers.</li></ul><h3>Conclusion (All’s Well That Serves Well!)</h3><p>KServe with Kubeflow provides a robust platform for serving ML models at scale. By following the best practices and leveraging the platform’s features, organizations can build reliable, scalable, and maintainable ML model-serving infrastructure. Remember, in the world of model serving, it’s not just about keeping up with the Kubernetes — it’s about serving with style!</p><h3>Additional Resources (Because Knowledge is Power, and Power Needs Proper Distribution!)</h3><ul><li>KServe Documentation: [<a href="https://kserve.github.io/website/">https://kserve.github.io/website/</a>]</li><li>Kubeflow Documentation: [<a href="https://www.kubeflow.org/docs/">https://www.kubeflow.org/docs/</a>]</li><li>GitHub Repository: [<a href="https://github.com/kserve/kserve">https://github.com/kserve/kserve</a>]</li><li>Kubeflow manifest: [<a href="https://github.com/kubeflow/manifests">https://github.com/kubeflow/manifests</a>]</li></ul><p>Remember: May the Kube be with you! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b05bfa3c004b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Big Data ETL with AWS Glue]]></title>
            <link>https://medium.com/@amritkmr4272/big-data-etl-with-aws-glue-88f7dc741773?source=rss-8b3118e8137d------2</link>
            <guid isPermaLink="false">https://medium.com/p/88f7dc741773</guid>
            <category><![CDATA[pyspark]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[glue-job]]></category>
            <dc:creator><![CDATA[AmritKmr]]></dc:creator>
            <pubDate>Wed, 30 Aug 2023 14:25:37 GMT</pubDate>
            <atom:updated>2023-08-30T14:25:37.534Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*6qhadgNloHlilszkvtN6Ag.png" /></figure><p>When it comes to loading Big Data from an S3 bucket to a DynamoDB Table, conventional lambda and/or python scripts will fail to deliver because of the prolonged processing time and high volumes.</p><p>To dig deep for an efficient process, I explored AWS Glue. Several ETL tools are available in the market today with multiple features for analytic processes. Nonetheless, I realized AWS Glue has better integration with other AWS services and in some cases where highly sensitive data is being processed. It provides a more secure solution than a 3rd party integration, especially if your application and data architecture are hosted on AWS.</p><p>Best part of this is AWS Glue Studio. It is a visual interface provided by AWS that makes it even easier for non-technical users to work with data using AWS Glue. It’s like having a user-friendly workshop where you can assemble and fine-tune your data processes without needing to write complex code.</p><p>This tutorial illustrates a step-by-step process on how to set up a AWS Glue job using crawlers. But before doing it, let’s talk about the problem once.</p><h3><strong>Overview</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-40v6_e04n7DDY8eJdFQUg.jpeg" /><figcaption><strong>Architecture Diagram</strong></figcaption></figure><p>The given solution provides the implementation walkthrough to setup and load Big Data from an S3 bucket to a DynamoDB Table via AWS Console. Most of the backend APIs need to load vast amounts of data as a source for providing the solutions in easy to develop and highly efficient databases.</p><h4><strong>What is Glue Job?</strong></h4><p>AWS Glue is a server-less data integration service that makes it easy for analytics users to discover, prepare, move, and integrate data from multiple sources. With AWS Glue, you can discover and connect to more than 70 diverse data sources and manage your data in a centralized data catalog.</p><p>A great alternative to conventional ETL tools is AWS Glue, especially if your application and data architecture are hosted on AWS. You can read more about glue jobs here — <a href="https://docs.aws.amazon.com/glue/latest/dg/what-is-glue.html"><strong>AWS Glue jobs</strong></a><strong>. [1]</strong></p><p>Spark Glue jobs are developed with a master-worker architecture where big chunks of task are divided into smaller chunks and assigned to worker nodes by the master. For a detailed information on master-worker architecture, check out <a href="https://medium.com/@vikalprusia/master-worker-architecture-unleashing-the-power-of-parallel-processing-eed241da30a"><strong>Master Worker Architecture: Unleashing the Power of Parallel Processing</strong></a><strong>. [2]</strong></p><p>With the ability to scale on demand, AWS Glue helps you focus on high-value activities that maximize the value of your data. It scales for any data size, and supports all data types and schema variances. To increase agility and optimize costs, AWS Glue provides built-in high availability and pay-as-you-go billing.</p><p>For pricing information, see <a href="https://aws.amazon.com/glue/pricing"><strong>AWS Glue pricing</strong></a><strong>. [3]</strong></p><h4><strong>AWS Glue Studio –</strong></h4><p>AWS Glue Studio is a graphical user interface that makes it simple to develop, perform, and monitor data integration processes in AWS Glue. AWS Glue’s serverless ETL engine is built on Apache Spark, and it allows you to graphically create workflows for data transformation and execute them without any issues. For more information, see <a href="https://docs.aws.amazon.com/glue/latest/ug/what-is-glue-studio.html"><strong>What is AWS Glue Studio</strong></a><strong>. [4]</strong></p><h3><strong>Solution Walkthrough</strong></h3><p>For illustration of the glue job here, an uncompressed csv file of around 1174 records is used with 10 number of columns and column named “Company” is the partition key of the file. You can use any file as per your convenience.</p><blockquote><strong><em>Pre-requisites</em></strong></blockquote><blockquote>· Set up IAM (Identity and Access Management) permissions for AWS Glue, DynamoDB and S3 access.</blockquote><blockquote>· Setup source destination as s3 bucket. Create a new folder in the bucket and upload the source CSV file.</blockquote><blockquote>· Setup the DynamoDB table. Enter the table name and partition key of your database and keep the rest of the table settings as Default.</blockquote><h4><strong>Step-1 Setup the AWS Glue Catalog Database</strong></h4><h4><strong>AWS Glue Database</strong></h4><p>Tables in your database can include data from several data sources. This information can consist of relational tables from Amazon Relational Database Service and objects from Amazon Simple Storage Service (Amazon S3).</p><ul><li>Go to the AWS Glue console and click on “<strong><em>Databases”</em></strong> in the side-pane under <strong>“<em>Data catalog”</em></strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WYHecp2Y407aaXgx637q1w.png" /></figure><ul><li>Click on <strong>“<em>Add database”</em></strong>, fill the Name in Database details and finally click on <strong>“<em>Create database”</em></strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xWSoOkUUm2lHMWTHgLGJcw.png" /></figure><h4><strong>Step-2 Setup and run Glue Crawlers</strong></h4><h4><strong>AWS Glue Crawlers –</strong></h4><p>A crawler can scan numerous data stores in a single request. The crawler generates or updates one or more tables in your Data Catalog. It stores the latest metadata including size of the data, row count, schema and many more from the database. AWS has provided the independence to run it on demand or on a schedule as well. If by any chance that the crawler reads the data type as different than the intended type, then you can edit the schema and keep it as per requirements.</p><ul><li>As the Glue database is successfully created, now it’s time to run the crawler and fill the metadata details in a table inside the database.</li><li>On the left-pane of Glue console, click on <strong>“<em>Crawlers”</em></strong><em> </em>under <em>Data Catalog </em>and click on <strong>“<em>Create Crawler”</em></strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A5wdAS1eEOXGFd96h8pHjg.png" /></figure><ul><li>Enter the Crawler name and click on <strong><em>“Next”</em></strong>. You can put tags if needed.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sXtecJTJ18ea--5mLFU0wg.png" /></figure><ul><li>You’ll need to add a data source. Here, the data source is an s3 bucket. Click on <strong><em>“Add a data source”</em></strong> and the window to add the s3 will open.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6n8k75UiAOSbQ5bbP-Y6UA.png" /></figure><ul><li>Choose Data Source as S3 and add the S3 path. Make sure to add a <strong><em>“/”</em></strong> at the end of the path. For subsequent crawler runs, we have the liberty to choose any 3 options provided, either to crawl all sub-folders, crawl new sub-folders or based on events.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*diXWYc9p6sn01m1eFcvrpA.png" /></figure><h4><strong>AWS Glue Custom Classifiers –</strong></h4><p>A classifier checks whether a given file is in a format the crawler can handle. If it is, the classifier creates a schema in the form of a StructType object that matches the data format.</p><ul><li>Adding a custom classifier is optional. If needed, you can expand the custom classifiers tab and click on Add classifier. A new tab will open, in which you’ll need to fill the Classifier name and type. You can keep a different delimiter, quote symbol, column headings and process options as per requirement.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ilHWti-b6Z6IJVZYn_Nq-g.png" /></figure><ul><li>Go back to the Crawler creation, choose the custom classifier and click on <strong><em>“Next”</em></strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QMw1uQLwnvvutdoP6rYcdQ.png" /></figure><ul><li>Choose the IAM role and click on <strong><em>“Next”</em></strong><em>.</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yV8srzrpZ-Jx1PtzAmPMGA.png" /></figure><ul><li>Now, fill in the target database as the Glue Catalog Database which we created. You can choose a table name prefix for better readability purposes. AWS provides the option to schedule the crawler frequency as per demand, CloudWatch event or time-based scheduling.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Cx498e5SncLvsFgBCNQaA.png" /></figure><ul><li>Finally, review the configuration settings and click on <strong><em>“Create Crawler”</em></strong><em>.</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xJI99pF5oR7jE0Bl6NuxRg.png" /></figure><ul><li>Click on <strong><em>“Run Crawler”</em></strong><em> </em>and wait till the crawler status turns from <strong><em>“Running”</em></strong> to <strong><em>“Completed”</em></strong> with some details added to <strong><em>“Table Changes”</em></strong><em> </em>column.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Ase_w4-dzn9914Jnes-2g.png" /></figure><h4><strong>Step — 3 Check the AWS Glue Catalog tables</strong></h4><h4><strong>AWS Glue Tables –</strong></h4><p>These Data Catalog tables serve as the sources and targets for extract, transform, and load (ETL) jobs that you specify in AWS Glue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TWvjb5k2RzV3DjU4GLvGbw.png" /></figure><ul><li>Click on the table name created by the Glue Crawler and it’ll show the table details, metadata and schema of the data table identified by the crawler.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D8fIop3a6NI0poETUtVrKg.png" /></figure><ul><li>You can watch all the metadata about the data, like delimiter, record count, compression type and more in the <strong><em>“Advanced Properties”.</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ES0ZxUhxLjlkvVjikMnBxg.png" /></figure><ul><li>The schema detected by the crawler shows some different data types for few column names sometimes. To modify any details of the schema, you can click on the <strong><em>“Edit Schema”</em></strong><em> and make the changes.</em></li></ul><blockquote><strong>Note -<br></strong>Crawler identifies all the column names and automatically converts it into lowercases. You can modify it, if needed, with the glue script by mapping the table column names and the desired name.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6gFXmVN90kfvwr4W5IkvNw.png" /></figure><ul><li>Let’s edit the column type of <strong><em>“year founded”</em></strong> into string. Select the column and click on <strong><em>“Edit”</em></strong><em>.</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YcRdWpvuayBotLI-YS0aEQ.png" /></figure><ul><li>Select <strong><em>“string”</em></strong> from the drop-down menu and finally click on <strong><em>“Save”.</em></strong> Make any further changes if required, otherwise just click on <strong><em>“Save as new table version”</em></strong><em>.</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S2y1HBC10aRUvnPP6XpW0A.png" /></figure><h4><strong>Step-4 Create the Glue job for ETL</strong></h4><p>Here comes the last step where you’ll create and configure the Glue job for loading the data from S3 bucket to a DynamoDB.<br>Let’s click to <strong><em>“ETL jobs”</em></strong> from AWS glue console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3ATXonvCnj5Uw4TjVg6TUw.png" /></figure><ul><li>Here you’ll create a Spark job by selecting the option <strong><em>“Spark script editor”</em></strong>, and then click on <strong><em>“Create”</em></strong><em>.</em></li><li>Go to job details and add <strong><em>“Name”</em></strong><em> </em>and<em> </em><strong><em>“IAM Role”</em></strong><em>. </em>Keep the type as Spark, glue version and Language as default<em>.</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K9vsxdlVPLTZu0-bkSJgtw.png" /></figure><ul><li>You can change the worker type up to G 8x which provides 32vCPU and 128 GB RAM configuration. The requested number of workers that can be used is 40, which you can use as per requirement, otherwise you can keep it default as 10.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JntVeTTK-z4rEctrpIa9Vw.png" /></figure><p><strong>Job Bookmarks — </strong>Job bookmarks are used for not processing the previously processed data and save the runtime and execution costs. By default, it’s put in <strong><em>“Disable”</em></strong> state, but we can keep it in <strong><em>“Pause”</em></strong><em> or </em><strong><em>“Enable”</em></strong><em> </em>state as well.</p><ul><li>Keep the rest of the options as default and click on <strong><em>“Save”</em></strong><em>.</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i3yQGQjg5j2gZCklhBVrSA.png" /></figure><h4><strong>Step-5 Development of the script for ETL</strong></h4><p>Now, here comes the fun part where we’ll get the opportunity to write some script at last.<br>You can use the sample script provided below for reading the data from s3 as a dynamic frame and loading it into DynamoDB. Before loading, mapping has been applied to the column names.</p><pre>import sys<br>from awsglue.transforms import *<br>from awsglue.utils import getResolvedOptions<br>from pyspark.context import SparkContext<br>from awsglue.context import GlueContext<br>from awsglue.job import Job<br>from awsglue.dynamicframe import DynamicFrameCollection<br>from awsglue.dynamicframe import DynamicFrame<br><br>## @params: [JOB_NAME]<br>args = getResolvedOptions(sys.argv, [&#39;JOB_NAME&#39;])<br><br>sc = SparkContext()<br>glueContext = GlueContext(sc)<br>spark = glueContext.spark_session<br>job = Job(glueContext)<br><br>### Initialize job<br>job.init(args[&#39;JOB_NAME&#39;], args)<br><br>### Script for AWS Glue data catalog<br>AWSGlueDataCatalog_node1 = glueContext.create_dynamic_frame.from_catalog(<br>        database=&quot;unicorn-companies&quot;,<br>        table_name=&quot;table_unicorn_companies&quot;,<br>        transformation_ctx=&quot;AWSGlueDataCatalog_node1&quot;<br>    )<br>AWSGlueDataCatalog_node1.show()<br><br>### Appy Mapping node <br>ApplyMapping_node2 = ApplyMapping.apply(<br>        frame=AWSGlueDataCatalog_node1,<br>        mappings=[<br>            (&quot;company&quot;,&quot;string&quot;,&quot;Company&quot;,&quot;string&quot;),<br>            (&quot;valuation&quot;,&quot;string&quot;,&quot;Valuation&quot;,&quot;string&quot;),<br>            (&quot;date joined&quot;,&quot;string&quot;,&quot;Date Joined&quot;,&quot;string&quot;),<br>            (&quot;industry&quot;,&quot;string&quot;,&quot;Industry&quot;,&quot;string&quot;),<br>            (&quot;city&quot;,&quot;string&quot;,&quot;City&quot;,&quot;string&quot;),<br>            (&quot;country&quot;,&quot;string&quot;,&quot;Country&quot;,&quot;string&quot;),<br>            (&quot;continent&quot;,&quot;string&quot;,&quot;Continent&quot;,&quot;string&quot;),<br>            (&quot;year founded&quot;,&quot;string&quot;,&quot;Year Founded&quot;,&quot;string&quot;),<br>            (&quot;funding&quot;,&quot;string&quot;,&quot;Funding&quot;,&quot;string&quot;),<br>            (&quot;select investors&quot;,&quot;string&quot;,&quot;Select Investors&quot;,&quot;string&quot;)<br>        ],<br>        transformation_ctx=&quot;ApplyMapping_node2&quot;<br>    )<br>ApplyMapping_node2.show()<br><br>### Script for writing dynamic frame to dynamo DB <br>final_dynamicFrame = glueContext.write_dynamic_frame_from_options(<br>        frame=ApplyMapping_node2,<br>        connection_type=&quot;dynamodb&quot;,<br>        connection_options={<br>            &quot;dynamodb.region&quot;: &quot;us-east-1&quot;,<br>            &quot;dynamodb.output.tableName&quot;: &quot;unicorn_companies&quot;,<br>            &quot;dynamodb.throughput.write.percent&quot;: &quot;1.0&quot;<br>        }<br>    )<br>final_dynamicFrame.show()<br>### End job<br>job.commit()</pre><p>For example, <strong><em>(“company”,“string”,“Company”,“string”)</em></strong> means <strong><em>“company”</em></strong> is the column name present in the Glue catalog table and <strong><em>“Company”</em></strong> is the intended name to display in the DynamoDB table.</p><h4><strong>DynamicFrame vs DataFrame -</strong></h4><p>A DynamicFrame has characteristics similar to a DataFrame, with the exception that each record is self-descriptive, hence no initial schema is needed. Instead, AWS Glue explicitly encodes schema inconsistencies using a choice (or union) type and computes a schema on-the-fly as necessary. To make your datasets compatible with data stores that demand a fixed schema, you can rectify these inconsistencies.</p><p>A DynamicRecord functions similarly to a DynamicFrame’s logical record. Similar to a row in a Spark DataFrame, but self-describing and able to hold data that does not follow a predetermined schema. For more information, check out <a href="https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-crawler-pyspark-extensions-dynamic-frame.html"><strong>DynamicFrame class</strong></a><strong> [5]</strong>.</p><p>Ultimately, save the job and click on <strong><em>“Run”</em></strong>. For checking the logs of your run, you can click on <strong><em>“Output Logs”</em></strong><em> on your execution tab.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g1lVvoDT_VFV5yPE90-lnw.png" /></figure><p>Now, once the logs show some data, then<em> </em>you can check the records being loaded to DynamoDB table. Here, for loading 1174 records in DynamoDB with read/write capacity of 1 unit, the job completed in 20 minutes. As per the investigation, the transformation and load of data increases exponentially after modifying the read/load capacity of the DynamoDB table to <strong><em>“On-Demand” </em></strong>and the requested number of Glue job workers to 40. The job successfully completed around 20 minutes for 2M records csv file with 5 columns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0xahtZec7NruModuMh84mA.png" /><figcaption>Records loaded in DynamoDB table</figcaption></figure><h3>Conclusion —</h3><p>AWS Glue supports millions of data loads with huge transfer rates. The proposed solution provides ETL with existing architectures support without duplication and redundancy of the data sources. The pricing can also be estimated by AWS services earlier, which gives the upper hand in decision-making. In addition, you can transform the data and trigger the jobs as per the requirements with logging capabilities. Hence, this architectural pattern continues to revolutionize the difficult computational difficulties in fields ranging from science to big data processing and beyond.</p><h4>References -</h4><ol><li><a href="https://docs.aws.amazon.com/glue/latest/dg/what-is-glue.html">What is AWS Glue? — AWS Glue (amazon.com)</a></li><li><a href="https://medium.com/@vikalprusia/master-worker-architecture-unleashing-the-power-of-parallel-processing-eed241da30a">Master Worker Architecture: Unleashing the Power of Parallel Processing | by Vikalp Rusia | Medium</a></li><li><a href="https://aws.amazon.com/glue/pricing/">Serverless Data Integration — AWS Glue Pricing — AWS (amazon.com)</a></li><li><a href="https://docs.aws.amazon.com/glue/latest/ug/what-is-glue-studio.html">What is AWS Glue Studio? — AWS Glue Studio (amazon.com)</a></li><li><a href="https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-crawler-pyspark-extensions-dynamic-frame.html">DynamicFrame class — AWS Glue (amazon.com)</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88f7dc741773" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>