Application Manager Client

App Manager Client

Provides API for managing application containers: - Install, start, stop, uninstall applications - Get application info and stats - Stream application logs

class neoruntime_ipc_sdk.app.AppInfo(id, name, version, state, container_id, pid, installed_at, started_at, stopped_at, restart_count, manifest_path, instance_path)[source]

Bases: object

Application information

id: str
name: str
version: str
state: str
container_id: str
pid: int
installed_at: int
started_at: int
stopped_at: int
restart_count: int
manifest_path: str
instance_path: str
__init__(id, name, version, state, container_id, pid, installed_at, started_at, stopped_at, restart_count, manifest_path, instance_path)
class neoruntime_ipc_sdk.app.AppStats(app_id, cpu_usage_percent, memory_usage_bytes, memory_limit_bytes, thread_count, uptime_seconds)[source]

Bases: object

Application runtime statistics

app_id: str
cpu_usage_percent: float
memory_usage_bytes: int
memory_limit_bytes: int
thread_count: int
uptime_seconds: int
__init__(app_id, cpu_usage_percent, memory_usage_bytes, memory_limit_bytes, thread_count, uptime_seconds)
class neoruntime_ipc_sdk.app.LogLine(timestamp, level, message)[source]

Bases: object

Single log line

timestamp: int
level: str
message: str
property datetime: datetime

Convert timestamp to datetime

__init__(timestamp, level, message)
class neoruntime_ipc_sdk.app.AppClient(endpoint=None)[source]

Bases: GrpcClient

Application Container Management Client

Usage:

app_client = AppClient()

# List all apps
apps = app_client.list_apps()
for app in apps:
    print(f"{app.name}: {app.state}")

# Get logs (last 100 lines)
for line in app_client.get_logs("my_app", max_lines=100):
    print(line)

# Follow logs in real-time
for line in app_client.get_logs("my_app", follow=True):
    print(line)
register_web_url(path='/')[source]

Register a web access path for this app.

After calling this method, the web console will show a “Visit App” button linking to http://{device_ip}:{inbound_port}{path}.

Requires the APP_ID environment variable to be set (injected automatically by the platform when the container starts).

Parameters:

path (str) – Web page path, default "/"

install_app(manifest_path, image_path)[source]

Install an application from manifest and image

Parameters:
  • manifest_path (str) – Path to app.yaml

  • image_path (str) – Path to container image tar

Returns:

app_id of installed application

Return type:

str

start_app(app_id)[source]

Start a stopped application

stop_app(app_id, timeout_seconds=30)[source]

Stop a running application

uninstall_app(app_id, keep_logs=True)[source]

Uninstall an application

restart_app(app_id, timeout_seconds=30)[source]

Restart a running application (stop + start).

This is a composite operation since the gRPC service does not expose a dedicated RestartApp RPC. It stops the app and then starts it again.

Parameters:
  • app_id (str) – Application ID

  • timeout_seconds (int) – Seconds to wait for the app to stop (default: 30)

list_apps()[source]

List all installed applications

get_app(app_id)[source]

Get application information

get_app_stats(app_id)[source]

Get application runtime statistics

get_logs(app_id, max_lines=100, follow=False)[source]

Get application logs

Parameters:
  • app_id (str) – Application ID

  • max_lines (int) – Maximum number of lines to return (default: 100)

  • follow (bool) – If True, stream logs continuously (default: False)

Yields:

LogLine objects

Examples

# Get last 100 lines
for line in app_client.get_logs("my_app", max_lines=100):
    print(line)

# Follow logs in real-time
for line in app_client.get_logs("my_app", follow=True):
    print(line)
get_logs_text(app_id, max_lines=100, follow=False)[source]

Get application logs as text lines

Parameters:
  • app_id (str) – Application ID

  • max_lines (int) – Maximum number of lines to return (default: 100)

  • follow (bool) – If True, stream logs continuously (default: False)

Yields:

Formatted log strings

Examples

# Print logs
for line in app_client.get_logs_text("my_app"):
    print(line)

Usage Examples

Application Lifecycle

from neoruntime_ipc_sdk import AppClient

app = AppClient()

# List all applications
apps = app.list_apps()
for a in apps:
    print(f"{a.name}: {a.state}")

# Install application
app_id = app.install_app(
    manifest_path="/data/apps/my_app/app.yaml",
    image_path="/data/apps/my_app/image.tar"
)

# Start application
app.start_app(app_id)

# Restart application (stop + start)
app.restart_app(app_id, timeout_seconds=30)

# Stop application
app.stop_app(app_id)

# Uninstall application
app.uninstall_app(app_id, keep_logs=True)

Getting Application Info

# Get application details
info = app.get_app("my_app")
print(f"Name: {info.name}")
print(f"Version: {info.version}")
print(f"State: {info.state}")

# Get application statistics
stats = app.get_app_stats("my_app")
print(f"CPU: {stats.cpu_usage_percent}%")
print(f"Memory: {stats.memory_usage_bytes / 1024 / 1024:.1f} MB")

Viewing Application Logs

# Get last 100 log lines
for line in app.get_logs("my_app", max_lines=100):
    print(line)

# Follow logs in real-time
for line in app.get_logs("my_app", follow=True):
    print(line)

# Get text-formatted logs
for text in app.get_logs_text("my_app"):
    print(text)

Registering Web URL

# Register web access path (inside app container)
# Requires APP_ID environment variable (injected by platform)
app.register_web_url("/")

# Register custom path
app.register_web_url("/dashboard")

Context Manager

with AppClient() as app:
    apps = app.list_apps()
    for a in apps:
        print(f"{a.name}: {a.state}")