get_tapis_app_schema()#
get_tapis_app_schema(t, appId, version=’latest’, quiet=False)
Fetch a Tapis App schema by ID and version, or grab the latest version when you don’t specify one.
What it does#
Calls t.apps.getAppLatestVersion(appId=…) when version is empty or “latest”.
Calls t.apps.getApp(appId=…, appVersion=…) when you provide a specific version string.
Returns the schema object (usually a TapisResult) or None if not found / error.
Parameters#
t (tapipy.tapis.Tapis) – Authenticated Tapis client.
appId (str) – App ID (e.g., “opensees-mp-s3”).
version (str, default “latest”) – Version string (e.g., “2.1.0”) or “latest”.
quiet (bool, default False) – Suppress error prints if True.
Returns#
App schema (TapisResult | dict | None) – The app schema on success, else None.
Examples#
# Latest version
schema = get_tapis_app_schema(t, "opensees-mp-s3")
# Specific version
schema_v = get_tapis_app_schema(t, "opensees-mp-s3", version="2.1.0")
# Quietly attempt
maybe_schema = get_tapis_app_schema(t, "nonexistent-app", quiet=True)
if maybe_schema is None:
print("Not found.")
Notes#
Uses Tapis Apps service convenience methods for clarity.
Returns
Nonewhen an app/version isn’t found or other errors occur (printout controlled byquiet).
Files#
You can find these files in Community Data.
get_tapis_app_schema.py
def get_tapis_app_schema(t, appId: str, version: str = "latest", quiet: bool = False):
"""
Fetch a Tapis App schema by ID and version (or the latest version).
Behavior
--------
- If `version` is empty or equals "latest" (case-insensitive), retrieves the app's
latest available version via `t.apps.getAppLatestVersion`.
- Otherwise, retrieves the specified version via `t.apps.getApp(appVersion=...)`.
- Returns the schema object (typically a TapisResult) on success, `None` on failure.
Parameters
----------
t : tapipy.tapis.Tapis
An authenticated Tapis client.
appId : str
The Tapis app ID (e.g., "opensees-mp-s3").
version : str, default "latest"
App version string (e.g., "1.0.3") or "latest" (case-insensitive).
quiet : bool, default False
If True, suppresses error prints and simply returns `None` on failure.
Returns
-------
tapipy.tapis.TapisResult | dict | None
The app schema object on success (commonly a TapisResult). Returns `None` when
not found or if an error occurs.
Example
-------
# Get latest
schema = get_tapis_app_schema(t, "opensees-mp-s3")
# Get a specific version
schema_v = get_tapis_app_schema(t, "opensees-mp-s3", version="2.1.0")
Author
------
Silvia Mazzoni, DesignSafe (silviamazzoni@yahoo.com)
Date
----
2025-08-14
Version
-------
1.0
"""
from tapipy.errors import BaseTapyException
# Normalize version
ver = (version or "").strip().lower()
try:
if ver == "" or ver == "latest":
return t.apps.getAppLatestVersion(appId=appId)
else:
return t.apps.getApp(appId=appId, appVersion=version)
except BaseTapyException as e:
if not quiet:
print(f"I was unable to find Tapis app: '{appId}', version='{version}'. Error: {e}")
return None
except Exception as e:
if not quiet:
print(f"Unexpected error retrieving app '{appId}' (version='{version}'): {e}")
return None