docstr: Used to create frontend's if the app couldn't be loaded locally.
docstr_tok: ["Used","to","create","frontend","'s","if","the","app","could","n't","be","loaded","locally","."]
code: def update_lightning_app_frontend(
      self, app: "lightning.LightningApp"
  ):  # noqa: F821
      """Used to create frontend's if the app couldn't be loaded locally."""
      if not len(app.frontends.keys()):
          return
  
      external_app_spec: "Externalv1LightningappInstance" = self.client.lightningapp_instance_service_get_lightningapp_instance(
          project_id=CloudBackend._get_project_id(),
          id=CloudBackend._get_app_id(),
      )
  
      frontend_specs = external_app_spec.spec.flow_servers
      spec = external_app_spec.spec
      if len(frontend_specs) != len(app.frontends.keys()):
          frontend_specs: List[V1Flowserver] = []
          for flow_name in sorted(app.frontends.keys()):
              frontend_spec = V1Flowserver(name=flow_name)
              frontend_specs.append(frontend_spec)
  
          spec.flow_servers = frontend_specs
          spec.enable_app_server = True
  
          logger.info("Found new frontends. Updating the app spec.")
  
          self.client.lightningapp_instance_service_update_lightningapp_instance(
              project_id=CloudBackend._get_project_id(),
              id=CloudBackend._get_app_id(),
              body=AppinstancesIdBody(spec=spec),
          )
  
imports: import inspect
  import json
  import logging
  import os
  import random
  import string
  import urllib
  from time import monotonic, sleep, time
  from typing import List, Optional
  from lightning_cloud.openapi import AppinstancesIdBody, Externalv1LightningappInstance, Externalv1Lightningwork, V1BuildSpec, V1Drive, V1DriveSpec, V1DriveStatus, V1DriveType, V1Flowserver, V1LightningappInstanceState, V1LightningappRestartPolicy, V1LightningworkClusterDriver, V1LightningworkDrives, V1LightningworkSpec, V1LightningworkState, V1ListLightningworkResponse, V1Metadata, V1NetworkConfig, V1PackageManager, V1PythonDependencyInfo, V1SourceType, V1UserRequestedComputeConfig
  from lightning_cloud.openapi.rest import ApiException
  from lightning.app.core import LightningApp, LightningWork
  from lightning.app.core.queues import QueuingSystem
  from lightning.app.runners.backends.backend import Backend
  from lightning.app.storage import Drive, Mount
  from lightning.app.utilities.enum import WorkStageStatus, WorkStopReasons, make_status
  from lightning.app.utilities.exceptions import LightningPlatformException
  from lightning.app.utilities.network import LightningClient, _check_service_url_is_ready
  from lightning_cloud.openapi import SpecLightningappInstanceIdWorksBody, WorksIdBody
label_desc: Use image node_id 17 for calling the CloudBackend obj's underlying member method code with example usage: obj.update_lightning_app_frontend(app) without return types