Optimize Streamlit app workflows with GitLab

Catch the latest livestream with @tonykip and William Arias, to see how GitLab’s powerful features can help streamline collaboration, enhance efficiency, and bring your app ideas to life faster.

Some main topics covered:

:fox_face: What is GitLab and why you should use it
:balloon: A demo of a Streamlit app that follows the standard DevOps & DevSecOps best practices
:robot: Duo Chat: GitLab’s AI that aims to simplify software development for developers

See past livestreams here, click the :bell: to be notified of future livestreams here: livestream

Overview (generated with Gemini 2.5 Flash), for anyone that doesn’t want to skim the whole video:

The video is a recording of the first episode of the “Streamlit Show” for the year 2024, featuring a discussion and demonstration by Tony Kipkemboi (Developer Advocate for Streamlit at Snowflake) and William Arias (Senior Developer Evangelist at GitLab).

The main focus of the episode is optimizing Streamlit app workflows using the GitLab DevSecOps Platform, with a particular emphasis on automation and the integration of AI features.

1. Introduction and Guest Background

  • Hosts & Guest: The episode is hosted by Tony Kipkemboi and features William Arias from GitLab.
  • William Arias’s Background:
    • He has a diverse career path starting with a Bachelor’s degree in Electrical Engineering, which led him to programming (assembly, C++, and now Python).
    • He worked at Intel as a Field Applications Engineer, focusing on understanding new hardware and finding application use cases.
    • He was a co-founder of a startup called Octosoft.
    • He worked as a consultant for companies like Oracle.
    • He is currently a Senior Developer Evangelist at GitLab.
    • He is also a Guest Lecturer at Prague University, teaching Applied ML.
    • His journey to GitLab was driven by his interest in DevOps as a way to automate and improve future workflows.
  • Streamlit Experience: William mentioned he started using Streamlit around 2018 when he needed to quickly create UIs for data applications to pitch ideas to project managers, finding it a fast and effective prototyping tool for Python coders.

2. GitLab and the DevSecOps Platform

  • What is GitLab? GitLab is a DevSecOps Platform that guides users through the entire software delivery lifecycle, from an initial idea to deployment and monitoring. It offers a single UI and data model to handle all stages.
  • Software Delivery Lifecycle Stages (GitLab’s View): Plan & Create, Integrate & Verify, Deploy & Operate, Secure & Govern, Monitor & Improve.
  • AI Integration: GitLab has embedded AI “touchpoints” throughout the software delivery lifecycle to simplify and assist development.

3. Streamlit Workflow Optimization with GitLab (Demonstration)

William demonstrates how to evolve a basic Streamlit developer workflow into an automated, secure, and collaborative process using GitLab.

Initial Developer Workflow (Workflow I):

  1. Create a Virtual Environment.
  2. Code the Streamlit App.
  3. Run the app on localhost.

Optimized Developer Workflow (Workflow II - GitLab):

This workflow leverages GitLab’s CI/CD (Continuous Integration/Continuous Delivery) and DevSecOps features, triggered by pushing code to a remote repository.

A. Planning & Tracking (Plan & Create Stage):

  • Epics & Issues: The project work is structured using Epics (high-level goals) and Issues (individual tasks).
  • Milestones: Progress can be tracked against milestones, showing the status of open/closed issues and providing burndown charts for project managers.

B. Code Contribution & Automation (Integrate & Verify Stage):

  • Merge Request (MR) / Pull Request: A developer creates an MR to introduce code changes (e.g., enabling Streamlit’s new @st.cache_resource decorator for a sentiment analysis model).
  • Web IDE: Changes can be made directly within the GitLab UI using the Web IDE, eliminating the need to switch to a local environment.
  • Automated CI/CD Pipeline: Committing the change triggers an automated pipeline that performs several actions:
    • Containerize: Builds a Docker container image of the Streamlit application (automating docker build).
    • Test & Scan (DevSecOps): Runs various security and quality checks:
      • Dependency Scanning: Checks for known vulnerabilities in third-party packages used by the app.
      • Secret Detection: Scans the code for accidentally committed secrets (like API tokens).
      • SAST (Static Application Security Testing): Detects potential vulnerabilities in the code itself (e.g., SQL injection risks).
    • AI-Powered Review:
      • AI-Generated Summary: Provides a natural language summary of the code changes in the MR.
      • Suggested Reviewers: Uses an ML model trained on project contribution history to recommend the most suitable person to review the code change.

C. Review and Deployment (Deploy & Operate Stage):

  • Review App (Ephemeral Environments): After the initial build and scan, the pipeline can automatically deploy a temporary, isolated version of the Streamlit app to a Kubernetes cluster. This allows stakeholders (including non-developers) to interact with and test the new feature before it’s merged into the main codebase.
  • Merge: Once the MR is approved and merged, a final production pipeline is triggered.

D. Continuous Delivery Features:

  • Feature Flags: Allows developers to deploy a new feature (e.g., a new text input component) to production but keep it hidden from most users. The feature can be rolled out gradually (e.g., only 50% of visitors see it) to test its stability and impact before a full release, mitigating the risk of deploying on a Friday afternoon.
  • Multi-Cloud Deployment: GitLab’s pipeline architecture allows a single code change to trigger deployment to multiple targets simultaneously (e.g., Google Cloud Platform, AWS, and a self-managed Kubernetes cluster), simplifying scaling and infrastructure management.
  • Separate Logic (Segregate Duties): Demonstrates a pattern where the Streamlit application code lives in one project, and the infrastructure/deployment manifests (for Kubernetes) live in a separate project. A successful build in the app project automatically triggers an update in the deployment project, allowing developers to focus on the app and DevOps engineers to focus on the infrastructure, without needing expertise in both.

4. Advanced Use Case: GPU-Enabled Training

  • ML App Architecture: A Streamlit UI consumes predictions from a separate model project.
  • GPU Abstraction: For training the ML model, the GitLab CI/CD setup allows developers to request a GPU-enabled runner simply by adding a specific tag (e.g., gpu-standard) to the job definition in the YAML file. This abstracts away the complexity of installing and managing GPU drivers and hardware, allowing the developer to focus on the ML logic.

5. AI-Powered Developer Assistance (GitLab Duo)

  • GitLab Duo Chat: An integrated large language model that can be accessed directly within the GitLab UI (e.g., in the Web IDE).
    • Code Generation: Can generate boilerplate code (e.g., a Streamlit application template) based on natural language prompts.
    • Documentation/Support: Can answer questions about GitLab features and documentation without requiring the user to leave the platform.
  • Root Cause Analysis: A feature that uses AI to analyze the output logs of a failed CI/CD job, identifying the error and suggesting a possible fix (e.g., “missing the dot in the Docker build command”).

6. Key Takeaways and Benefits

  • Automation: Automates containerization, testing, scanning, and deployment, saving significant developer time.
  • Security: Integrates security scanning early in the development process (Shift Left Security), preventing vulnerabilities from reaching production.
  • Collaboration: Facilitates code review and testing with ephemeral Review Apps and AI-powered reviewer suggestions.
  • Modularity: Encourages the development of modular code, which is essential for scaling and maintaining complex applications.
  • Performance: Features like @st.cache_resource and Review Apps help developers identify and address performance bottlenecks in resource-constrained cloud environments.

This first episode of the “Streamlit Show” is an excellent deep dive into how Streamlit apps can be scaled and optimized with proper DevSecOps practices. What stood out to me is how GitLab’s CI/CD pipelines not only automate repetitive tasks like containerization and deployment but also integrate security checks and AI-powered code reviews right into the workflow.

The use of ephemeral Review Apps is especially clever—it lets stakeholders interact with new features before they hit production, which is a game-changer for collaboration. I also liked seeing how GPU-enabled training is abstracted within the CI/CD setup, letting developers focus purely on ML logic without worrying about infrastructure.