Skip to content

hopsworks.core.app_api #

AppApi #

create_app #

create_app(
    name: str,
    app_path: str | None = None,
    environment: str = "python-app-pipeline",
    memory: int = 2048,
    cores: float = 1.0,
    env_vars: dict[str, str] | None = None,
    app_kind: str = "STREAMLIT",
    entrypoint_command: str | None = None,
    app_port: int | None = None,
    description: str | None = None,
    git_url: str | None = None,
    git_provider: str | None = None,
    git_branch: str | None = None,
    git_auto_redeploy: bool = False,
    entrypoint_script: str | None = None,
    app_base_path: str | None = None,
    readiness_probe_path: str | None = None,
    db_access: bool = True,
    idle_scale_to_zero: bool | None = None,
    idle_cooldown_seconds: int | None = None,
    cold_start_timeout_seconds: int | None = None,
) -> app.App

Create a new app.

Example
import hopsworks

project = hopsworks.login()
apps = project.get_app_api()

app = apps.create_app(
    "my_dashboard",
    app_path="Resources/app.py",
)

app.run()
print(app.app_url)
PARAMETER DESCRIPTION
name

Name of the app.

TYPE: str

app_path

Path to the app file in HopsFS.

TYPE: str | None DEFAULT: None

environment

Python environment name (default: "python-app-pipeline").

TYPE: str DEFAULT: 'python-app-pipeline'

memory

Memory in MB (default: 2048).

TYPE: int DEFAULT: 2048

cores

CPU cores (default: 1.0).

TYPE: float DEFAULT: 1.0

env_vars

Per-runtime env vars applied when the app is started. These override account-level env vars for this app's executions.

TYPE: dict[str, str] | None DEFAULT: None

app_kind

What the app is, which decides how it is started. STREAMLIT, FLASK and GRADIO run the given Python file with their framework. NODEJS runs a JavaScript or TypeScript file with Node.js, and the app reads its port from process.env.PORT. CUSTOM runs entrypoint_command.

TYPE: str DEFAULT: 'STREAMLIT'

entrypoint_command

Startup command for CUSTOM apps. The other kinds generate theirs from the app file.

TYPE: str | None DEFAULT: None

app_port

Port the app listens on, for every kind but STREAMLIT. Flask is started on it; Gradio and Node.js are told it through GRADIO_SERVER_PORT and PORT. Unset leaves the backend's default.

TYPE: int | None DEFAULT: None

description

Optional app description.

TYPE: str | None DEFAULT: None

git_url

Optional Git repository URL. When set, the app is cloned on every start.

TYPE: str | None DEFAULT: None

git_provider

Git provider for git-backed apps (GitHub, GitLab or BitBucket).

TYPE: str | None DEFAULT: None

git_branch

Optional branch to clone for git-backed apps.

TYPE: str | None DEFAULT: None

git_auto_redeploy

Roll the app to the branch HEAD whenever a new commit is pushed. Only valid for git-backed apps. The running app keeps serving until the new version is ready.

TYPE: bool DEFAULT: False

entrypoint_script

The app file relative to the repository root, for git repository apps of every kind but CUSTOM.

TYPE: str | None DEFAULT: None

app_base_path

Public mount path for the app, for example / or /myapp.

TYPE: str | None DEFAULT: None

readiness_probe_path

Optional readiness probe path to use instead of the platform default.

TYPE: str | None DEFAULT: None

db_access

Give the app access to the project's online feature store database. Defaults to True: starting the app creates the database if the project does not have one yet and injects the MYSQL_USER, MYSQL_PASSWORD_SECRET_NAME, MYSQL_DB, MYSQL_HOST and MYSQL_PORT environment variables into the app container, the same way agent deployments get them. Set to False for apps that do not need the database. Independently of this flag, when Trino is enabled on the cluster every app gets TRINO_HOST, TRINO_PORT, TRINO_USER, TRINO_PASSWORD_SECRET_NAME and TRINO_SCHEMA to read the offline feature group tables with SQL (the catalog is the feature group's format, delta or hudi, chosen by the app).

TYPE: bool DEFAULT: True

idle_scale_to_zero

Scale the app to zero when idle. The app's pod goes away once no request has been in flight for idle_cooldown_seconds and comes back on the next request, which is held for up to cold_start_timeout_seconds. The app shows the IDLE state meanwhile, and opening it is what wakes it. On by default wherever the cluster has KEDA (None leaves the choice to the cluster); pass False for an app that must stay up, and True to insist, which fails on a cluster without KEDA. An open WebSocket, such as a Streamlit session in an open tab, counts as in flight, so the app stays up while someone has it open.

TYPE: bool | None DEFAULT: None

idle_cooldown_seconds

Seconds without a request before the app scales to zero. Turns the option on when given; the default is the cluster's pythonapp_idle_cooldown_seconds (21600, six hours).

TYPE: int | None DEFAULT: None

cold_start_timeout_seconds

Seconds the first request waits for the app to wake. Turns the option on when given; the default and ceiling is the cluster's pythonapp_cold_start_timeout_max_seconds (300). The ingress read timeout (60 unless raised) may fail the waking request earlier; the pod keeps starting and the next request finds it ready.

TYPE: int | None DEFAULT: None

RETURNS DESCRIPTION
app.App

The created App object.

get_app #

get_app(name: str) -> app.App | None

Get an app by name.

PARAMETER DESCRIPTION
name

Name of the app.

TYPE: str

RETURNS DESCRIPTION
app.App | None

App object, or None if no app with that name exists, so a

app.App | None

reuse-if-exists guard does not have to catch a 404.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error other than a 404.

get_apps #

get_apps() -> list[app.App]

Get all apps in the project.

RETURNS DESCRIPTION
list[app.App]

List of App objects.