CloudRuntime¶
- class lightning.app.runners.cloud.CloudRuntime(app=None, entrypoint=None, start_server=True, host='http://127.0.0.1', port=7501, processes=<factory>, threads=<factory>, work_runners=<factory>, done=False, backend='cloud', env_vars=<factory>, secrets=<factory>, run_app_comment_commands=False, enable_basic_auth='')[source]¶
Bases:
Runtime- _api_create_cloudspace_if_not_exists(project_id, name, existing_cloudspace)[source]¶
Create the cloudspace if it doesn’t exist.
Return the cloudspace ID.
- Return type
- _api_create_run(project_id, cloudspace_id, run_body)[source]¶
Create and return the run.
- Return type
V1LightningRun
- _api_create_run_instance(cluster_id, project_id, run_name, cloudspace_id, run_id, desired_state, queue_server_type=None, env_vars=None, auth=None, source_app=None)[source]¶
Create a new instance of the given run with the given specification.
- Return type
Externalv1LightningappInstance
- static _api_package_and_upload_repo(repo, run)[source]¶
Package and upload the provided local source code directory to the provided run.
- Return type
- _api_stop_existing_run_instance(project_id, existing_run_instance)[source]¶
If an existing instance is provided and it isn’t stopped, stop it.
- Return type
- _api_transfer_run_instance(project_id, run_id, instance_id, desired_state, queue_server_type=None, env_vars=None, auth=None)[source]¶
Transfer an existing instance to the given run ID and update its specification.
Return the instance.
- Return type
Externalv1LightningappInstance
- static _get_auth(credentials)[source]¶
If credentials are provided, parse them and return the auth spec.
- Return type
Optional[V1LightningAuth]
- static _get_drives(work)[source]¶
Get the list of drive specifications for the provided work.
- Return type
List[V1LightningworkDrives]
- static _get_env_vars(env_vars, secrets, run_app_comment_commands)[source]¶
Generate the list of environment variable specs for the app, including variables set by the framework.
- Return type
List[V1EnvVar]
- _get_flow_servers()[source]¶
Collect a spec for each flow that contains a frontend so that the backend knows for which flows it needs to start servers.
- Return type
List[V1Flowserver]
- static _get_mounts(work)[source]¶
Get the list of mount specifications for the provided work.
- Return type
List[V1LightningworkDrives]
- static _get_network_configs(flow_servers)[source]¶
Get the list of network configs for the run if multiple works in default container is enabled.
- _get_run_body(cluster_id, flow_servers, network_configs, works, no_cache, root, start_server, should_mount_cloudspace_content=False, absolute_entrypoint=False)[source]¶
Get the specification of the run creation request.
- Return type
CloudspaceIdRunsBody
- _get_works(cloudspace=None)[source]¶
Get the list of work specs from the app.
- Return type
List[V1Work]
- static _print_specs(run_body, print_format)[source]¶
Print the given run body in either web or gallery format.
- Return type
- _resolve_cloudspace(project_id, cloudspace_id)[source]¶
Returns a cloudspace by project_id and cloudspace_id, if exists.
- Return type
Optional[V1CloudSpace]
- _resolve_cloudspace_name(cloudspace_name, existing_cloudspace, existing_cloudspaces)[source]¶
If there are existing cloudspaces but not on the cluster - choose a randomised name.
- Return type
- _resolve_cluster_id(cluster_id, project_id, existing_cloudspaces)[source]¶
If cloudspaces exist and cluster is None, mimic cluster selection logic to choose a default.
- _resolve_config(name, load=True)[source]¶
Find and load the config file if it exists (otherwise create an empty config).
Override the name if provided.
- Return type
AppConfig
- _resolve_existing_cloudspaces(project_id, cloudspace_name)[source]¶
Lists all the cloudspaces with a name matching the provided cloudspace name.
- Return type
List[V1CloudSpace]
- _resolve_existing_run_instance(cluster_id, project_id, existing_cloudspaces)[source]¶
Look for an existing run and instance from one of the provided cloudspaces on the provided cluster.
- static _resolve_needs_credits(project)[source]¶
Check if the user likely needs credits to run the app with its hardware.
Returns False if user has 1 or more credits.
- _resolve_open_ignore_functions()[source]¶
Used by the
openmethod.If the entrypoint is a file, return an ignore function that will ignore everything except that file so only the file gets uploaded.
- _resolve_project(project_id=None)[source]¶
Determine the project to run on, choosing a default if multiple projects are found.
- Return type
V1Membership
- _resolve_queue_server_type()[source]¶
Resolve the cloud queue type from the environment.
- Return type
V1QueueServerType
- _resolve_repo(root, ignore_functions=None, default_ignore=True, package_source=True, sys_customizations_root=None)[source]¶
Gather and merge all lightningignores from the app children and create the
LocalSourceCodeDirobject.- Return type
LocalSourceCodeDir
- _resolve_run_instances_by_name(project_id, name)[source]¶
Get all existing instances in the given project with the given name.
- Return type
List[Externalv1LightningappInstance]
- _resolve_run_name(name, existing_instances)[source]¶
If there are existing instances with the same name - choose a randomised name.
- Return type
- _validate_cluster_id(cluster_id, project_id)[source]¶
Check that the provided cluster exists and ensure that it is bound to the given project.
- static _validate_repo(root, repo)[source]¶
This method is used to inform the users if their folder files are large and how to filter them.
- Return type
- _validate_work_build_specs_and_compute()[source]¶
Check that the cloud compute and build configs are valid for all works in the app.
- Return type
- cloudspace_dispatch(project_id, cloudspace_id, name, cluster_id, source_app=None)[source]¶
Slim dispatch for creating runs from a cloudspace. This dispatch avoids resolution of some properties such as the project and cluster IDs that are instead passed directly.
- Parameters
- Raises
ApiException – If there was an issue in the backend.
RuntimeError – If there are validation errors.
ValueError – If there are validation errors.
- Return type
Externalv1LightningappInstance- Returns
The spec the created app instance.
- dispatch(name='', cluster_id=None, open_ui=True, no_cache=False, **kwargs)[source]¶
Method to dispatch and run the
LightningAppin the cloud.- Return type