Basics
Phidata makes it easy to build applications using open source tools. The general workflow is:
- Import the tool you need:
FastApi
,Django
,Jupyter
,Streamlit
- Add it to a runtime:
DockerConfig
,AWSConfig
orK8sConfig
- Run the tools:
phi start resources.py
(orphi ws up
)
Example
To build an ML App using Jupyter for model development and FastApi for model serving, we'll import the Jupyter
and FastApiServer
classes and add them to a DockerConfig
to run locally.
dev_resources.py
from phidata.app.jupyter import Jupyter
from phidata.app.fastapi import FastApiServer
from phidata.docker.config import DockerConfig
# -*- Jupyter running on port 8888
dev_jupyter = Jupyter()
# -*- FastApiServer running on port 9090
dev_fastapi = FastApiServer()
dev_docker_config = DockerConfig(apps=[dev_jupyter, dev_fastapi])
- Run the tools using
phi start dev_resources.py
- Stop them using
phi stop dev_resources.py
In production, we'll run these tools on AWS ECS (Fargate) or EKS (Kubernetes).
Your application will eventually need a database, adding it is as simple as:
dev_resources.py
from phidata.app.postgres import PostgresDb
# -*- PostgresDb running on port 5432
dev_db = PostgresDb(db_user="phi", db_password="phi", db_schema="phi")
dev_docker_config = DockerConfig(apps=[dev_jupyter, dev_fastapi, dev_db])
In production, we'll use the cloud-hosted version (RDS) instead of running postgres ourself.
Templates
Instead of wiring tools one by one, phidata
provides pre-built templates for common applications. Templates are tested in production by large teams, are fully customizable and come with:
- Development Environment for running the application locally.
- Production Environment for running the application on AWS.
- Best practices like Testing, Formatting, Linting, CI/CD, Security and Secret management.
Templates are available for LLM Apps, Web Apps (Django), RestAPIs (FastApi) and Data Platforms.