What Programming Languages Does OpenMed Use? A Technical Breakdown of the Hybrid ML Stack

OpenMed uses Python for machine learning pipelines, Swift for iOS/macOS frontends, and Bash for automation scripts.

OpenMed (maziyarpanahi/openmed) is a multi-language repository that combines Python-based data processing with native Swift mobile interfaces. Understanding what programming languages OpenMed uses helps developers navigate its architecture, which spans from backend model training to on-device inference.

Python: Machine Learning and Backend Logic

The core data-processing, model-training, and validation utilities in OpenMed are implemented in Python. This language choice leverages Python's extensive machine learning ecosystem for handling complex inference tasks and quality assurance.

Model Validation and Smoke Testing

The repository includes Python-based smoke tests for model validation. In scripts/smoke_gliner.py, the project implements inference testing logic for the GLiNER model, demonstrating how Python handles model loading and validation workflows. These scripts serve as the first line of defense for ensuring model integrity before deployment.

Unit Testing Infrastructure

Python also powers the comprehensive test suite located under tests/unit/. The file tests/unit/test_utils.py contains utility tests that validate backend logic and data processing functions. This extensive unit-test coverage confirms Python's role as the primary language for backend quality-gate checks.


# Representative pattern based on OpenMed's smoke testing

def validate_gliner_model(model_path):
    model = load_model(model_path)
    test_results = model.run_inference(test_samples)
    return verify_outputs(test_results)

Swift: Native iOS and macOS Frontend

OpenMed implements its mobile frontend and on-device inference capabilities in Swift, utilizing modern SwiftUI frameworks for cross-platform Apple ecosystem deployment.

SwiftUI Application Layer

The demo application entry point resides in swift/OpenMedDemo/OpenMedDemo/OpenMedDemoApp.swift. This file establishes the SwiftUI application lifecycle and serves as the primary interface for on-device inference demonstrations. The implementation leverages Swift protocols and modern concurrency features to manage ML model interactions.

OpenMedKit Library Architecture

The core reusable library is defined in swift/OpenMedKit/Sources/OpenMedKit/OpenMedKit.swift. This module encapsulates the on-device inference logic, providing a clean Swift API that abstracts the underlying ML operations. The library uses Swift's type safety and performance characteristics to deliver efficient native execution on iOS and macOS devices.

// Representative pattern based on OpenMed's Swift structure
import SwiftUI

@main
struct OpenMedDemoApp: App {
    var body: some Scene {
        WindowGroup {
            InferenceView()
        }
    }
}

Shell Scripts: Automation and CI/CD

While not a primary development language, Bash plays a critical role in OpenMed's build automation and continuous integration workflows.

Environment Management and Testing

The script scripts/reset_uv_env_and_run_tests.sh orchestrates Python environment setup using the uv package manager, dependency installation, and test execution. This automation ensures consistent development environments across different machines.

GitHub Actions Integration

The CI pipeline defined in .github/workflows/swift-test.yml utilizes Bash commands to coordinate Swift testing workflows. These scripts handle the compilation of Swift components and execution of the iOS/macOS test suites, bridging the gap between the Python backend and Swift frontend in automated builds.

#!/bin/bash

# Representative automation pattern from OpenMed

uv sync
source .venv/bin/activate
python -m pytest tests/unit/

Summary

Frequently Asked Questions

Is OpenMed primarily a Python or Swift project?

OpenMed is a hybrid project that uses both Python and Swift as primary languages. Python dominates the backend ML processing and model training, while Swift handles the iOS/macOS frontend and on-device inference. Neither is secondary; they serve different architectural layers.

What is the purpose of the smoke tests in OpenMed?

The smoke tests, located in scripts/smoke_gliner.py, serve as sanity checks to verify that ML models load correctly and produce expected outputs. These Python scripts run validation inference before deployment to catch model corruption or environment issues early in the pipeline.

How does OpenMed handle cross-platform ML deployment?

OpenMed uses a dual-layer approach: Python handles server-side or development-side model training and heavy processing, while Swift enables on-device inference for iOS/macOS clients. This architecture allows the project to leverage Python's ML ecosystem while delivering native mobile performance through Swift.

Which directory contains the iOS source code in OpenMed?

The iOS and macOS source code resides in the swift/ directory. Specifically, swift/OpenMedDemo/ contains the demo application using SwiftUI, and swift/OpenMedKit/ contains the reusable library components for integrating OpenMed functionality into other Apple platform applications.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →