NoBS Python

Guides

Network Application

This document explains how to configure and deploy a Network Application in a NoBS project. Network applications are services that expose network ports — such as custom APIs, dashboards, or MLFlow servers — managed and deployed within a Project.

Overview

A NetworkApp represents a user-defined network-accessible service. It allows you to specify a startup command, exposed ports, compute requirements, scaling configuration, and other deployment metadata.

You can define a NetworkApp inside a Project configuration:

python
from nobs.models import Project, FastAPIApp, Worker
from nobs.secrets import SlackWebhook

project = Project(
    name="my-custom-server",

    custom_network_app=NetworkApp(
        command=["/bin/bash", "-c", "uv run main.py"],
        port=8000,
    ),
)

Available Fields

Below is the full schema of the NetworkApp class and its parameters.

python
@dataclass
class NetworkApp:
    command: list[str]
    port: int

    description: str | None = None
    environments: dict[str, str] | None = None
    secrets: list[type[BaseSettings]] | None = None
    contacts: list[Contact] | Contact | None = None

    health_check: str | None = None

    compute: Compute = field(default_factory=Compute)
    min_scale: int = 0
    max_scale: int = 1

    https_only: bool = True
    domain_names: list[str] | str | None = None
    tags: list[str] | None = None

    docker_image: str | None = None

Example Configurations

Below are examples of using built-in NoBS network app types.

FastAPI Server

You can define a FastAPIApp server directly in your project. NoBS will deploy and expose it securely.

python
from nobs.models import Project, FastAPIApp, Worker
from nobs.secrets import SlackWebhook

project = Project(
    name="fastapi-project",

    server=FastAPIApp(
        app,
        secrets=[SlackWebhook],
        domain_names=[
            "cloud.aligned.codes",
            "www.cloud.aligned.codes",
        ]
    ),
)

Key Notes:

  • The FastAPIApp automatically detects the FastAPI app object.
  • Supports HTTPS and domain-based routing.
  • You can attach secrets for environment configuration.

Streamlit Server

Deploy a Streamlit application as part of your project.

python
from nobs.models import Project, MlflowServer, Job, StreamlitApp, Worker
from nobs.secrets import MlflowConfig, S3StorageConfig

from src.pokemon_app import main
from src.pokemon import LoadData, TrainConfig, load_all_data, train_model

project = Project(
    name="streamlit-apps",

    is_legendary_app=StreamlitApp(
        main,
        secrets=[MlflowConfig],
    )
)

Features:

  • Runs Streamlit-based dashboards and visualizations.
  • Automatically configures environment secrets (e.g., MlflowConfig).
  • Integrates with background workers and ML pipelines.

MLFlow Server

NoBS Python can automatically spin up a managed MLFlow tracking server. If the MLFlow version is not explicitly set, it will match the version used in your Python project.

python
from nobs.models import Project, MlflowServer, Job, StreamlitApp, Worker
from nobs.secrets import MlflowConfig

from src.pokemon_app import main
from src.pokemon import LoadData, TrainConfig, load_all_data, train_model

project = Project(
    name="mlops-example",

    mlflow_server=MlflowServer(
        domain_names=[
            "example.aligned.codes"
        ]
    ),

    is_legendary_app=StreamlitApp(
        main,
        secrets=[MlflowConfig],
    )
)

Highlights:

  • Fully managed MLFlow deployment with HTTPS and custom domains.
  • Compatible with StreamlitApp for experiment visualization.
  • Scalable and version-aware.
Previous
Local Development