AppsManager
Class to manage the different apps.
Each app runs in its own dedicated process.
app_dir: str | Nonerunning_processes: dictConsume an authorize grant and return the user id it names.
Confirms the grant was minted for this app before trusting it, so a grant for app A cannot be replayed on app B.
strstrstrAppInstanceAppInstanceUrlCreate app asynchronously and return the app ID. The app will be started in background.
AppInstanceCreateAppAsyncResultDTOConsume a one-time app code and return a JWT + the resolved user id.
Called from the app (via POST /apps/exchange-code) to turn the gws_code it received
in its URL into a JWT it carries on data lab API calls. The code is single-use
(consumed here) and must match the app it was minted for.
strstrExchangeAppCodeResponseDTOFind the streamlit app that was generated from the given resource model id
strgws_core.apps.app_process.AppProcess | NoneFind the process that contains the app with the given token
strgws_core.apps.app_process.AppProcess | NoneMint a short-lived, single-use code that authenticates a user to a specific app.
The code is put in the app URL as gws_code. The app relays it back to
exchange_app_code (it cannot consume the code itself, being gws_core-free), which
swaps it for a JWT. The code is bound to app_id so it cannot be replayed against
another app.
strstrint - 60strMint the single-use authorize grant returned by the gateway authorize step.
Names the resolved user and is bound to app_id. The front replays it to handoff,
which consumes it (consume_authorize_grant) to re-resolve the user without a lab
session and mint the fresh app grant post-RUNNING.
strstrstrstrRead the server log filtered by the app id
strdatetime.datetime | NoneLogsBetweenDatesAppsStatusDTOSet (or clear) the custom subdomain on an app resource.
The value is validated and checked for DB-wide uniqueness by the resource setter. Passing a falsy value clears the custom subdomain and restores the default id-based host.
The custom subdomain is a front-only alias on the app host: the canonical id-based host is kept, and the custom host is added as an extra nginx server_name. If the app is currently running, the change is applied immediately (the front nginx service is re-registered and nginx reloaded); otherwise it takes effect on the next start.
strstr | NoneSet the stop policy on an app resource and update the running process if any.
strAppStopPolicy(Cold-)start the app in background and return its process.
Unlike create_or_get_app_async, this builds no app URL, so it works in contexts where there is no current user (lab boot) and for callers that only need the process itself.
AppInstanceAppProcessStop every running app process, concurrently.
Each stop_process() SIGTERMs the app's process group and then waits up to 5s for it to die before SIGKILLing survivors. Stopping apps sequentially would sum those waits and, with several apps, exceed uvicorn's shutdown-timeout — cutting shutdown short and leaving some apps as orphans (issue #97). Stopping them in parallel bounds the total wait to a single ~5s window regardless of app count.
strReturn the user id from the user access token if the user has access to the app
strstrstr | NoneValidate an app-scoped token (from the app's gws_app_jwt cookie) and return the user id.
Used on a fresh page load (F5 / new tab) to re-authenticate without a one-time code: the app stored the app token in a cookie on first load and relays it here. Validated as an app-scoped token bound to this app (typ:app + matching app_id), so a token minted for another app is rejected.
strstrValidateAppJwtResponseDTO