Skip to content

hopsworks.app #

App #

Represents a Hopsworks Python App.

agent_chat_app property #

agent_chat_app: bool

Whether the app is an agent's own chat app (Agent.create_chat_app()), as opposed to an app of your own that reaches an agent.

agent_deployment_id property #

agent_deployment_id: int | None

The id of the agent deployment the app reaches, if it was created with agent= or is an agent's chat app; None otherwise.

app_base_path property #

app_base_path: str | None

Configured app base path.

app_kind property #

app_kind: str | None

Configured app kind.

app_path property #

app_path: str | None

Path to the app file in HopsFS.

app_port property #

app_port: int | None

Configured app port.

app_url property #

app_url: str | None

URL to the app, or None while it is not serving.

An app that scales to zero when idle keeps its URL in the IDLE state: a request to it is what wakes it.

Example
apps = project.get_app_api()
app = apps.get_app("my_dashboard")
if app.serving:
    print(app.app_url)

cold_start_timeout_seconds property #

cold_start_timeout_seconds: int | None

Seconds the first request waits for the app to wake, when idle_scale_to_zero is set.

cpu_requested property #

cpu_requested: str | None

Requested CPU cores.

db_access property #

db_access: bool

Whether the app gets access to the project's online feature store database.

When True, the database is created on demand when the app starts and the MYSQL_* connection environment variables are injected into the app container. Trino access to the offline tables (TRINO_*) does not depend on this flag.

description property #

description: str | None

App description.

entrypoint_command property #

entrypoint_command: str | None

Configured startup command.

entrypoint_script property #

entrypoint_script: str | None

Configured Git-backed Streamlit entrypoint script.

environment_name property #

environment_name: str | None

Python environment name.

execution_id property #

execution_id: int | None

ID of the current/latest execution.

git_auto_redeploy property #

git_auto_redeploy: bool

Whether the app is rolled to the branch HEAD when a new commit is pushed.

git_branch property #

git_branch: str | None

Configured Git branch.

git_provider property #

git_provider: str | None

Configured Git provider.

git_url property #

git_url: str | None

Configured Git repository URL.

idle_cooldown_seconds property #

idle_cooldown_seconds: int | None

Seconds without a request before the app scales to zero, when idle_scale_to_zero is set.

idle_scale_to_zero property #

idle_scale_to_zero: bool

Whether the app scales to zero when idle.

The pod goes away once no request has been in flight for idle_cooldown_seconds, the app shows the IDLE state, and the next request brings the pod back, held for up to cold_start_timeout_seconds.

latest_branch property #

latest_branch: str | None

Branch the running clone resolved to.

Only set when no branch was configured, in which case this is the repository's default branch that the app actually checked out.

latest_commit property #

latest_commit: str | None

Latest deployed Git commit.

managed_db property #

managed_db: bool

Whether the app owns a registered set of tables in the project's online database.

Such an app connects as its own database user, which can read the project database but can only create and write tables registered with register_table. Apps created before table registration existed connect as the user who started them and have no registered tables.

memory_requested property #

memory_requested: str | None

Requested memory.

name property #

name: str

Name of the app.

proxy_path_mode property #

proxy_path_mode: str | None

ROOT when the proxy strips the browser mount before the app sees a request, PREFIX when it forwards it.

public_access property #

public_access: bool

Whether the app is publicly accessible without a Hopsworks login.

public_url property #

public_url: str | None

Public share URL.

None when the app is not public, or when the caller is not a data owner (only data owners receive the share token from the backend).

readiness_probe_path property #

readiness_probe_path: str | None

Configured readiness probe path.

serving property #

serving: bool

Whether the app is serving (Streamlit health check passed).

state property #

state: str

Current state of the app (RUNNING, IDLE, KILLED, FAILED, STOPPED, etc.).

IDLE is an app that scales to zero when idle and has no pod right now; opening it wakes it.

table_count property #

table_count: int

How many tables the app has registered.

table_prefix property #

table_prefix: str | None

The prefix every table of the app must start with, for example app_reviews__; None when managed_db is False.

alter_table #

alter_table(name: str, alteration: str) -> None

Change a table of the app, for example to add a column; the table stays on disk.

app.alter_table("notes", "ADD COLUMN score DOUBLE")
PARAMETER DESCRIPTION
name

The table name, with or without the app's table_prefix.

TYPE: str

alteration

What follows ALTER TABLE <name>.

TYPE: str

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the app does not own the table, if the alteration sets an engine, tablespace or storage, or if the database refuses it.

create_table #

create_table(name: str, definition: str) -> str

Create a table of the app in the project's online database, stored on disk in RonDB.

The app's database user cannot create or alter tables, so Hopsworks runs the CREATE TABLE, registering the table first. Hopsworks sets the engine, tablespace and STORAGE DISK; RonDB keeps primary-key and other indexed columns in memory. Creating a table that exists does nothing, so it is safe on every start.

notes = app.create_table("notes", "id BIGINT AUTO_INCREMENT PRIMARY KEY, note TEXT")
PARAMETER DESCRIPTION
name

The table name, with or without the app's table_prefix; the prefix is added when missing.

TYPE: str

definition

The columns and indexes, as written inside the parentheses of CREATE TABLE.

TYPE: str

RETURNS DESCRIPTION
str

The full table name to use in SQL.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the name is refused as by register_table, if the definition sets an engine, tablespace or storage, or if the database refuses the definition.

delete #

delete()

Delete the app entirely.

This stops the app if running and removes the job configuration.

get_logs #

get_logs() -> dict[str, str]

Get stdout and stderr logs for the latest app execution.

RETURNS DESCRIPTION
dict[str, str]

Dictionary with stdout and stderr log content.

RAISES DESCRIPTION
hopsworks.client.exceptions.JobExecutionException

If the app has no execution.

hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when retrieving logs.

get_table #

get_table(name: str) -> dict

Get a registered table with its columns.

PARAMETER DESCRIPTION
name

The full table name.

TYPE: str

RETURNS DESCRIPTION
dict

The table dict of get_tables plus columns, each with name, type, nullable, primary and default_value.

get_tables #

get_tables() -> list[dict]

List the tables the app registered.

RETURNS DESCRIPTION
list[dict]

One dict per table with name, registered, created (False until the app runs its CREATE TABLE) and rows (an estimate).

get_url #

get_url() -> str

Get URL to view the app in Hopsworks UI.

RETURNS DESCRIPTION
str

The URL to the app page in the Hopsworks UI.

make_private #

make_private() -> None

Revoke public access.

Every outstanding public link stops working immediately.

make_public #

make_public() -> str | None

Make this app reachable without a Hopsworks login.

RETURNS DESCRIPTION
str | None

str. The share URL to give out.

Danger

Anyone with the link can use the app with the app's own credentials, data access, and secrets. This is not read-only access. Only data owners can enable it, and only when the administrator allows public apps.

preview_table #

preview_table(name: str, limit: int = 20) -> dict

Read the first rows of a registered table.

PARAMETER DESCRIPTION
name

The full table name.

TYPE: str

limit

How many rows, at most 100.

TYPE: int DEFAULT: 20

RETURNS DESCRIPTION
dict

A dict with columns, the column names, and rows, a list of rows whose values are strings or None.

redeploy #

redeploy(await_serving: bool = True) -> App

Redeploy the app by rolling its Kubernetes deployment.

This stops the current running execution and starts a new one using the same app configuration and runtime parameters.

PARAMETER DESCRIPTION
await_serving

If True, wait until the app is serving before returning.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
App

Self, with updated state.

register_table #

register_table(name: str) -> str

Reserve a table name for the app in the project's online database, without creating the table.

The app's database user is granted the registered table only, and the table is dropped when the app is deleted. create_table registers the table too, so most apps only call that. Registering a table the app already owns does nothing, so it is safe on every start.

PARAMETER DESCRIPTION
name

The table name, with or without the app's table_prefix; the prefix is added when missing.

TYPE: str

RETURNS DESCRIPTION
str

The full table name to use in SQL.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the name is not lowercase a-z, 0-9 and _, is longer than 64 characters with the prefix, already exists as another table, or belongs to another app, or if the app does not register tables (managed_db is False).

run #

run(await_serving: bool = True) -> App

Start the app.

Example
apps = project.get_app_api()
app = apps.get_app("my_dashboard")
app.run()
print(app.app_url)
PARAMETER DESCRIPTION
await_serving

If True, wait until the app is serving before returning.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
App

Self, with updated state.

RAISES DESCRIPTION
hopsworks.client.exceptions.JobExecutionException

If the app fails to start or the serving timeout is exceeded.

stop #

stop() -> App

Stop the app.

RETURNS DESCRIPTION
App

Self, with updated state.