Limit Your App To One Instance

url http://www.devx.com/tips/Tip/13745

How can we make sure that only one instance of our Java application is running on a machine? Java does not provide the means of finding out if another instance of our app is running. And, sometimes, we may really want to limit the user of our app to only one running instance. So, what do we do?

One way of dealing with this problem is to have our app create a file under a certain file name when it runs for the first time. Subsequent launches of our app will check for that file. If it already exists, the app knows another instance is already running and will inform the user, then quit. The first instance of the app, however has to delete the file before it exits.

The drawback of this approach is that out first instance of the app may crash, or may be killed by the user, or for whatever reason, it may cease to exist without having a chance to remove the little file that indicates a running instance.

Another way of dealing with this problem is via the use of java.net.ServerSocket class. The idea is to have an instance of ServerSocket listening over some port for as long as the first running instance of our app runs. Consequent launches of our app will try to set up their own ServerSocket over the same port, and will get a java.net.BindException (because we cannot start two versions of a server on the same port), and we'll know that another instance of the app is already running.

Now, if, for any unintentional reason, our app dies, the resources used by the app die away with it, and another instance can start and set the ServerSocket to prevent more instances from running. The following illustrates our approach:

java 代码
  1. private static final int RUN_PORT = 9666;    
  2. //use an obscure port    
  3.   
  4. void main(String[] av)    
  5. {    
  6.         try    
  7.         {    
  8.                 java.net.ServerSocket ss = new java.net.ServerSocket(PORT);    
  9.         }    
  10.       catch (java.net.BindException ex)    
  11.         {    
  12.                 System.out.println("Program already running");    
  13.                 System.exit(1);    
  14.         }    
  15.       catch (java.io.IOException ex)    
  16.         {    
  17.                 ex.printStackTrace();    
  18.                 System.exit(1);    
  19.         }    
  20.         //the rest of your code for the main(...) method    
  21. }   
# Configuration file for notebook. c = get_config() #noqa #------------------------------------------------------------------------------ # Application(SingletonConfigurable) configuration #------------------------------------------------------------------------------ ## This is an application. ## The date format used by logging formatters for %(asctime)s # Default: '%Y-%m-%d %H:%M:%S' # c.Application.log_datefmt = '%Y-%m-%d %H:%M:%S' ## The Logging format template # Default: '[%(name)s]%(highlevel)s %(message)s' # c.Application.log_format = '[%(name)s]%(highlevel)s %(message)s' ## Set the log level by value or name. # Choices: any of [0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL'] # Default: 30 # c.Application.log_level = 30 ## Configure additional log handlers. # # The default stderr logs handler is configured by the log_level, log_datefmt # and log_format settings. # # This configuration can be used to configure additional handlers (e.g. to # output the log to a file) or for finer control over the default handlers. # # If provided this should be a logging configuration dictionary, for more # information see: # https://docs.python.org/3/library/logging.config.html#logging-config- # dictschema # # This dictionary is merged with the base logging configuration which defines # the following: # # * A logging formatter intended for interactive use called # ``console``. # * A logging handler that writes to stderr called # ``console`` which uses the formatter ``console``. # * A logger with the name of this application set to ``DEBUG`` # level. # # This example adds a new handler that writes to a file: # # .. code-block:: python # # c.Application.logging_config = { # 'handlers': { # 'file': { # 'class': 'logging.FileHandler', # 'level': 'DEBUG', # 'filename': '<path/to/file>', # } # }, # 'loggers': { # '<application-name>': { # 'level': 'DEBUG', # # NOTE: if you don't list the default "console" # # handler here then it will be disabled # 'handlers': ['console', 'file'], # }, # } # } # Default: {} # c.Application.logging_config = {} ## Instead of starting the Application, dump configuration to stdout # Default: False # c.Application.show_config = False ## Instead of starting the Application, dump configuration to stdout (as JSON) # Default: False # c.Application.show_config_json = False #------------------------------------------------------------------------------ # JupyterApp(Application) configuration #------------------------------------------------------------------------------ ## Base class for Jupyter applications ## Answer yes to any prompts. # Default: False # c.JupyterApp.answer_yes = False ## Full path of a config file. # Default: '' # c.JupyterApp.config_file = '' ## Specify a config file to load. # Default: '' # c.JupyterApp.config_file_name = '' ## Generate default config file. # Default: False # c.JupyterApp.generate_config = False ## The date format used by logging formatters for %(asctime)s # See also: Application.log_datefmt # c.JupyterApp.log_datefmt = '%Y-%m-%d %H:%M:%S' ## The Logging format template # See also: Application.log_format # c.JupyterApp.log_format = '[%(name)s]%(highlevel)s %(message)s' ## Set the log level by value or name. # See also: Application.log_level # c.JupyterApp.log_level = 30 ## # See also: Application.logging_config # c.JupyterApp.logging_config = {} ## Instead of starting the Application, dump configuration to stdout # See also: Application.show_config # c.JupyterApp.show_config = False ## Instead of starting the Application, dump configuration to stdout (as JSON) # See also: Application.show_config_json # c.JupyterApp.show_config_json = False #------------------------------------------------------------------------------ # ExtensionApp(JupyterApp) configuration #------------------------------------------------------------------------------ ## Base class for configurable Jupyter Server Extension Applications. # # ExtensionApp subclasses can be initialized two ways: # # - Extension is listed as a jpserver_extension, and ServerApp calls # its load_jupyter_server_extension classmethod. This is the # classic way of loading a server extension. # # - Extension is launched directly by calling its `launch_instance` # class method. This method can be set as a entry_point in # the extensions setup.py. ## Answer yes to any prompts. # See also: JupyterApp.answer_yes # c.ExtensionApp.answer_yes = False ## Full path of a config file. # See also: JupyterApp.config_file # c.ExtensionApp.config_file = '' ## Specify a config file to load. # See also: JupyterApp.config_file_name # c.ExtensionApp.config_file_name = '' # Default: '' # c.ExtensionApp.default_url = '' ## Generate default config file. # See also: JupyterApp.generate_config # c.ExtensionApp.generate_config = False ## Handlers appended to the server. # Default: [] # c.ExtensionApp.handlers = [] ## The date format used by logging formatters for %(asctime)s # See also: Application.log_datefmt # c.ExtensionApp.log_datefmt = '%Y-%m-%d %H:%M:%S' ## The Logging format template # See also: Application.log_format # c.ExtensionApp.log_format = '[%(name)s]%(highlevel)s %(message)s' ## Set the log level by value or name. # See also: Application.log_level # c.ExtensionApp.log_level = 30 ## # See also: Application.logging_config # c.ExtensionApp.logging_config = {} ## Whether to open in a browser after starting. # The specific browser used is platform dependent and # determined by the python standard library `webbrowser` # module, unless it is overridden using the --browser # (ServerApp.browser) configuration option. # Default: False # c.ExtensionApp.open_browser = False ## Settings that will passed to the server. # Default: {} # c.ExtensionApp.settings = {} ## Instead of starting the Application, dump configuration to stdout # See also: Application.show_config # c.ExtensionApp.show_config = False ## Instead of starting the Application, dump configuration to stdout (as JSON) # See also: Application.show_config_json # c.ExtensionApp.show_config_json = False ## paths to search for serving static files. # # This allows adding javascript/css to be available from the notebook server machine, # or overriding individual files in the IPython # Default: [] # c.ExtensionApp.static_paths = [] ## Url where the static assets for the extension are served. # Default: '' # c.ExtensionApp.static_url_prefix = '' ## Paths to search for serving jinja templates. # # Can be used to override templates from notebook.templates. # Default: [] # c.ExtensionApp.template_paths = [] #------------------------------------------------------------------------------ # LabServerApp(ExtensionApp) configuration #------------------------------------------------------------------------------ ## A Lab Server Application that runs out-of-the-box ## "A list of comma-separated URIs to get the allowed extensions list # # .. versionchanged:: 2.0.0 # `LabServerApp.whitetlist_uris` renamed to `allowed_extensions_uris` # Default: '' # c.LabServerApp.allowed_extensions_uris = '' ## Answer yes to any prompts. # See also: JupyterApp.answer_yes # c.LabServerApp.answer_yes = False ## The application settings directory. # Default: '' # c.LabServerApp.app_settings_dir = '' ## The url path for the application. # Default: '/lab' # c.LabServerApp.app_url = '/lab' ## Deprecated, use `LabServerApp.blocked_extensions_uris` # Default: '' # c.LabServerApp.blacklist_uris = '' ## A list of comma-separated URIs to get the blocked extensions list # # .. versionchanged:: 2.0.0 # `LabServerApp.blacklist_uris` renamed to `blocked_extensions_uris` # Default: '' # c.LabServerApp.blocked_extensions_uris = '' ## Whether to cache files on the server. This should be `True` except in dev # mode. # Default: True # c.LabServerApp.cache_files = True ## Full path of a config file. # See also: JupyterApp.config_file # c.LabServerApp.config_file = '' ## Specify a config file to load. # See also: JupyterApp.config_file_name # c.LabServerApp.config_file_name = '' ## Whether getting a relative (False) or absolute (True) path when copying a # path. # Default: False # c.LabServerApp.copy_absolute_path = False ## Extra paths to look for federated JupyterLab extensions # Default: [] # c.LabServerApp.extra_labextensions_path = [] ## Generate default config file. # See also: JupyterApp.generate_config # c.LabServerApp.generate_config = False ## Handlers appended to the server. # See also: ExtensionApp.handlers # c.LabServerApp.handlers = [] ## Options to pass to the jinja2 environment for this # Default: {} # c.LabServerApp.jinja2_options = {} ## The standard paths to look in for federated JupyterLab extensions # Default: [] # c.LabServerApp.labextensions_path = [] ## The url for federated JupyterLab extensions # Default: '' # c.LabServerApp.labextensions_url = '' ## The interval delay in seconds to refresh the lists # Default: 3600 # c.LabServerApp.listings_refresh_seconds = 3600 ## The optional kwargs to use for the listings HTTP requests as # described on https://2.python-requests.org/en/v2.7.0/api/#requests.request # Default: {} # c.LabServerApp.listings_request_options = {} ## The listings url. # Default: '' # c.LabServerApp.listings_url = '' ## The date format used by logging formatters for %(asctime)s # See also: Application.log_datefmt # c.LabServerApp.log_datefmt = '%Y-%m-%d %H:%M:%S' ## The Logging format template # See also: Application.log_format # c.LabServerApp.log_format = '[%(name)s]%(highlevel)s %(message)s' ## Set the log level by value or name. # See also: Application.log_level # c.LabServerApp.log_level = 30 ## # See also: Application.logging_config # c.LabServerApp.logging_config = {} ## Whether a notebook should start a kernel automatically. # Default: True # c.LabServerApp.notebook_starts_kernel = True ## Whether to open in a browser after starting. # See also: ExtensionApp.open_browser # c.LabServerApp.open_browser = False ## The optional location of the settings schemas directory. If given, a handler # will be added for settings. # Default: '' # c.LabServerApp.schemas_dir = '' ## Settings that will passed to the server. # See also: ExtensionApp.settings # c.LabServerApp.settings = {} ## The url path of the settings handler. # Default: '' # c.LabServerApp.settings_url = '' ## Instead of starting the Application, dump configuration to stdout # See also: Application.show_config # c.LabServerApp.show_config = False ## Instead of starting the Application, dump configuration to stdout (as JSON) # See also: Application.show_config_json # c.LabServerApp.show_config_json = False ## The optional location of local static files. If given, a static file handler # will be added. # Default: '' # c.LabServerApp.static_dir = '' ## paths to search for serving static files. # See also: ExtensionApp.static_paths # c.LabServerApp.static_paths = [] ## Url where the static assets for the extension are served. # See also: ExtensionApp.static_url_prefix # c.LabServerApp.static_url_prefix = '' ## Paths to search for serving jinja templates. # See also: ExtensionApp.template_paths # c.LabServerApp.template_paths = [] ## The application templates directory. # Default: '' # c.LabServerApp.templates_dir = '' ## The optional location of the themes directory. If given, a handler will be # added for themes. # Default: '' # c.LabServerApp.themes_dir = '' ## The theme url. # Default: '' # c.LabServerApp.themes_url = '' ## The url path of the translations handler. # Default: '' # c.LabServerApp.translations_api_url = '' ## The url path of the tree handler. # Default: '' # c.LabServerApp.tree_url = '' ## The optional location of the user settings directory. # Default: '' # c.LabServerApp.user_settings_dir = '' ## Deprecated, use `LabServerApp.allowed_extensions_uris` # Default: '' # c.LabServerApp.whitelist_uris = '' ## The url path of the workspaces API. # Default: '' # c.LabServerApp.workspaces_api_url = '' ## The optional location of the saved workspaces directory. If given, a handler # will be added for workspaces. # Default: '' # c.LabServerApp.workspaces_dir = '' #------------------------------------------------------------------------------ # JupyterNotebookApp(LabServerApp) configuration #------------------------------------------------------------------------------ ## The notebook server extension app. ## # See also: LabServerApp.allowed_extensions_uris # c.JupyterNotebookApp.allowed_extensions_uris = '' ## Answer yes to any prompts. # See also: JupyterApp.answer_yes # c.JupyterNotebookApp.answer_yes = False ## The application settings directory. # Default: '' # c.JupyterNotebookApp.app_settings_dir = '' ## The url path for the application. # Default: '/lab' # c.JupyterNotebookApp.app_url = '/lab' ## Deprecated, use `LabServerApp.blocked_extensions_uris` # See also: LabServerApp.blacklist_uris # c.JupyterNotebookApp.blacklist_uris = '' ## # See also: LabServerApp.blocked_extensions_uris # c.JupyterNotebookApp.blocked_extensions_uris = '' ## Whether to cache files on the server. This should be `True` except in dev # mode. # Default: True # c.JupyterNotebookApp.cache_files = True ## Full path of a config file. # See also: JupyterApp.config_file # c.JupyterNotebookApp.config_file = '' ## Specify a config file to load. # See also: JupyterApp.config_file_name # c.JupyterNotebookApp.config_file_name = '' ## Whether getting a relative (False) or absolute (True) path when copying a # path. # Default: False # c.JupyterNotebookApp.copy_absolute_path = False ## Whether custom CSS is loaded on the page. # Defaults to True and custom CSS is loaded. # Default: True # c.JupyterNotebookApp.custom_css = True ## The default URL to redirect to from `/` # Default: '/tree' # c.JupyterNotebookApp.default_url = '/tree' ## Whether to expose the global app instance to browser via window.jupyterapp # Default: False # c.JupyterNotebookApp.expose_app_in_browser = False ## Extra paths to look for federated JupyterLab extensions # Default: [] # c.JupyterNotebookApp.extra_labextensions_path = [] ## Generate default config file. # See also: JupyterApp.generate_config # c.JupyterNotebookApp.generate_config = False ## Handlers appended to the server. # See also: ExtensionApp.handlers # c.JupyterNotebookApp.handlers = [] ## Options to pass to the jinja2 environment for this # Default: {} # c.JupyterNotebookApp.jinja2_options = {} ## The standard paths to look in for federated JupyterLab extensions # Default: [] # c.JupyterNotebookApp.labextensions_path = [] ## The url for federated JupyterLab extensions # Default: '' # c.JupyterNotebookApp.labextensions_url = '' ## The interval delay in seconds to refresh the lists # See also: LabServerApp.listings_refresh_seconds # c.JupyterNotebookApp.listings_refresh_seconds = 3600 ## The optional kwargs to use for the listings HTTP requests as # described on https://2.python-requests.org/en/v2.7.0/api/#requests.request # See also: LabServerApp.listings_request_options # c.JupyterNotebookApp.listings_request_options = {} ## The listings url. # Default: '' # c.JupyterNotebookApp.listings_url = '' ## The date format used by logging formatters for %(asctime)s # See also: Application.log_datefmt # c.JupyterNotebookApp.log_datefmt = '%Y-%m-%d %H:%M:%S' ## The Logging format template # See also: Application.log_format # c.JupyterNotebookApp.log_format = '[%(name)s]%(highlevel)s %(message)s' ## Set the log level by value or name. # See also: Application.log_level # c.JupyterNotebookApp.log_level = 30 ## # See also: Application.logging_config # c.JupyterNotebookApp.logging_config = {} ## Whether a notebook should start a kernel automatically. # Default: True # c.JupyterNotebookApp.notebook_starts_kernel = True ## Whether to open in a browser after starting. # See also: ExtensionApp.open_browser # c.JupyterNotebookApp.open_browser = False ## The optional location of the settings schemas directory. If given, a handler # will be added for settings. # Default: '' # c.JupyterNotebookApp.schemas_dir = '' ## Settings that will passed to the server. # See also: ExtensionApp.settings # c.JupyterNotebookApp.settings = {} ## The url path of the settings handler. # Default: '' # c.JupyterNotebookApp.settings_url = '' ## Instead of starting the Application, dump configuration to stdout # See also: Application.show_config # c.JupyterNotebookApp.show_config = False ## Instead of starting the Application, dump configuration to stdout (as JSON) # See also: Application.show_config_json # c.JupyterNotebookApp.show_config_json = False ## The optional location of local static files. If given, a static file handler # will be added. # Default: '' # c.JupyterNotebookApp.static_dir = '' ## paths to search for serving static files. # See also: ExtensionApp.static_paths # c.JupyterNotebookApp.static_paths = [] ## Url where the static assets for the extension are served. # See also: ExtensionApp.static_url_prefix # c.JupyterNotebookApp.static_url_prefix = '' ## Paths to search for serving jinja templates. # See also: ExtensionApp.template_paths # c.JupyterNotebookApp.template_paths = [] ## The application templates directory. # Default: '' # c.JupyterNotebookApp.templates_dir = '' ## The optional location of the themes directory. If given, a handler will be # added for themes. # Default: '' # c.JupyterNotebookApp.themes_dir = '' ## The theme url. # Default: '' # c.JupyterNotebookApp.themes_url = '' ## The url path of the translations handler. # Default: '' # c.JupyterNotebookApp.translations_api_url = '' ## The url path of the tree handler. # Default: '' # c.JupyterNotebookApp.tree_url = '' ## The optional location of the user settings directory. # Default: '' # c.JupyterNotebookApp.user_settings_dir = '' ## Deprecated, use `LabServerApp.allowed_extensions_uris` # See also: LabServerApp.whitelist_uris # c.JupyterNotebookApp.whitelist_uris = '' ## The url path of the workspaces API. # Default: '' # c.JupyterNotebookApp.workspaces_api_url = '' ## The optional location of the saved workspaces directory. If given, a handler # will be added for workspaces. # Default: '' # c.JupyterNotebookApp.workspaces_dir = '' #------------------------------------------------------------------------------ # ServerApp(JupyterApp) configuration #------------------------------------------------------------------------------ ## The Jupyter Server application class. ## Set the Access-Control-Allow-Credentials: true header # Default: False # c.ServerApp.allow_credentials = False ## Set the Access-Control-Allow-Origin header # # Use '*' to allow any origin to access your server. # # Takes precedence over allow_origin_pat. # Default: '' # c.ServerApp.allow_origin = '' ## Use a regular expression for the Access-Control-Allow-Origin header # # Requests from an origin matching the expression will get replies with: # # Access-Control-Allow-Origin: origin # # where `origin` is the origin of the request. # # Ignored if allow_origin is set. # Default: '' # c.ServerApp.allow_origin_pat = '' ## DEPRECATED in 2.0. Use PasswordIdentityProvider.allow_password_change # Default: True # c.ServerApp.allow_password_change = True ## Allow requests where the Host header doesn't point to a local server # # By default, requests get a 403 forbidden response if the 'Host' header # shows that the browser thinks it's on a non-local domain. # Setting this option to True disables this check. # # This protects against 'DNS rebinding' attacks, where a remote web server # serves you a page and then changes its DNS to send later requests to a # local IP, bypassing same-origin checks. # # Local IP addresses (such as 127.0.0.1 and ::1) are allowed as local, # along with hostnames configured in local_hostnames. # Default: False # c.ServerApp.allow_remote_access = False ## Whether to allow the user to run the server as root. # Default: False # c.ServerApp.allow_root = False ## Answer yes to any prompts. # See also: JupyterApp.answer_yes # c.ServerApp.answer_yes = False ## " # Require authentication to access prometheus metrics. # Default: True # c.ServerApp.authenticate_prometheus = True ## The authorizer class to use. # Default: 'jupyter_server.auth.authorizer.AllowAllAuthorizer' # c.ServerApp.authorizer_class = 'jupyter_server.auth.authorizer.AllowAllAuthorizer' ## Reload the webapp when changes are made to any Python src files. # Default: False # c.ServerApp.autoreload = False ## The base URL for the Jupyter server. # # Leading and trailing slashes can be omitted, # and will automatically be added. # Default: '/' # c.ServerApp.base_url = '/' ## Specify what command to use to invoke a web # browser when starting the server. If not specified, the # default browser will be determined by the `webbrowser` # standard library module, which allows setting of the # BROWSER environment variable to override it. # Default: '' # c.ServerApp.browser = '' ## The full path to an SSL/TLS certificate file. # Default: '' # c.ServerApp.certfile = '' ## The full path to a certificate authority certificate for SSL/TLS client # authentication. # Default: '' # c.ServerApp.client_ca = '' ## Full path of a config file. # See also: JupyterApp.config_file # c.ServerApp.config_file = '' ## Specify a config file to load. # See also: JupyterApp.config_file_name # c.ServerApp.config_file_name = '' ## The config manager class to use # Default: 'jupyter_server.services.config.manager.ConfigManager' # c.ServerApp.config_manager_class = 'jupyter_server.services.config.manager.ConfigManager' ## The content manager class to use. # Default: 'jupyter_server.services.contents.largefilemanager.AsyncLargeFileManager' # c.ServerApp.contents_manager_class = 'jupyter_server.services.contents.largefilemanager.AsyncLargeFileManager' ## DEPRECATED. Use IdentityProvider.cookie_options # Default: {} # c.ServerApp.cookie_options = {} ## The random bytes used to secure cookies. # By default this is a new random number every time you start the server. # Set it to a value in a config file to enable logins to persist across server sessions. # # Note: Cookie secrets should be kept private, do not share config files with # cookie_secret stored in plaintext (you can read the value from a file). # Default: b'' # c.ServerApp.cookie_secret = b'' ## The file where the cookie secret is stored. # Default: '' # c.ServerApp.cookie_secret_file = '' ## Override URL shown to users. # # Replace actual URL, including protocol, address, port and base URL, # with the given value when displaying URL to the users. Do not change # the actual connection URL. If authentication token is enabled, the # token is added to the custom URL automatically. # # This option is intended to be used when the URL to display to the user # cannot be determined reliably by the Jupyter server (proxified # or containerized setups for example). # Default: '' # c.ServerApp.custom_display_url = '' ## The default URL to redirect to from `/` # Default: '/' # c.ServerApp.default_url = '/' ## Disable cross-site-request-forgery protection # # Jupyter server includes protection from cross-site request forgeries, # requiring API requests to either: # # - originate from pages served by this server (validated with XSRF cookie and token), or # - authenticate with a token # # Some anonymous compute resources still desire the ability to run code, # completely without authentication. # These services can disable all authentication and security checks, # with the full knowledge of what that implies. # Default: False # c.ServerApp.disable_check_xsrf = False ## handlers that should be loaded at higher priority than the default services # Default: [] # c.ServerApp.extra_services = [] ## Extra paths to search for serving static files. # # This allows adding javascript/css to be available from the Jupyter server machine, # or overriding individual files in the IPython # Default: [] # c.ServerApp.extra_static_paths = [] ## Extra paths to search for serving jinja templates. # # Can be used to override templates from jupyter_server.templates. # Default: [] # c.ServerApp.extra_template_paths = [] ## Open the named file when the application is launched. # Default: '' # c.ServerApp.file_to_run = '' ## The URL prefix where files are opened directly. # Default: 'notebooks' # c.ServerApp.file_url_prefix = 'notebooks' ## Generate default config file. # See also: JupyterApp.generate_config # c.ServerApp.generate_config = False ## DEPRECATED. Use IdentityProvider.get_secure_cookie_kwargs # Default: {} # c.ServerApp.get_secure_cookie_kwargs = {} ## The identity provider class to use. # Default: 'jupyter_server.auth.identity.PasswordIdentityProvider' # c.ServerApp.identity_provider_class = 'jupyter_server.auth.identity.PasswordIdentityProvider' ## DEPRECATED. Use ZMQChannelsWebsocketConnection.iopub_data_rate_limit # Default: 0.0 # c.ServerApp.iopub_data_rate_limit = 0.0 ## DEPRECATED. Use ZMQChannelsWebsocketConnection.iopub_msg_rate_limit # Default: 0.0 # c.ServerApp.iopub_msg_rate_limit = 0.0 ## The IP address the Jupyter server will listen on. # Default: 'localhost' # c.ServerApp.ip = 'localhost' ## Supply extra arguments that will be passed to Jinja environment. # Default: {} # c.ServerApp.jinja_environment_options = {} ## Extra variables to supply to jinja templates when rendering. # Default: {} # c.ServerApp.jinja_template_vars = {} ## Dict of Python modules to load as Jupyter server extensions.Entry values can # be used to enable and disable the loading ofthe extensions. The extensions # will be loaded in alphabetical order. # Default: {} # c.ServerApp.jpserver_extensions = {} ## The kernel manager class to use. # Default: 'jupyter_server.services.kernels.kernelmanager.MappingKernelManager' # c.ServerApp.kernel_manager_class = 'jupyter_server.services.kernels.kernelmanager.MappingKernelManager' ## The kernel spec manager class to use. Should be a subclass of # `jupyter_client.kernelspec.KernelSpecManager`. # # The Api of KernelSpecManager is provisional and might change without warning # between this version of Jupyter and the next stable one. # Default: 'builtins.object' # c.ServerApp.kernel_spec_manager_class = 'builtins.object' ## The kernel websocket connection class to use. # Default: 'jupyter_server.services.kernels.connection.base.BaseKernelWebsocketConnection' # c.ServerApp.kernel_websocket_connection_class = 'jupyter_server.services.kernels.connection.base.BaseKernelWebsocketConnection' ## DEPRECATED. Use ZMQChannelsWebsocketConnection.kernel_ws_protocol # Default: '' # c.ServerApp.kernel_ws_protocol = '' ## The full path to a private key file for usage with SSL/TLS. # Default: '' # c.ServerApp.keyfile = '' ## DEPRECATED. Use ZMQChannelsWebsocketConnection.limit_rate # Default: False # c.ServerApp.limit_rate = False ## Hostnames to allow as local when allow_remote_access is False. # # Local IP addresses (such as 127.0.0.1 and ::1) are automatically accepted # as local as well. # Default: ['localhost'] # c.ServerApp.local_hostnames = ['localhost'] ## The date format used by logging formatters for %(asctime)s # See also: Application.log_datefmt # c.ServerApp.log_datefmt = '%Y-%m-%d %H:%M:%S' ## The Logging format template # See also: Application.log_format # c.ServerApp.log_format = '[%(name)s]%(highlevel)s %(message)s' ## Set the log level by value or name. # See also: Application.log_level # c.ServerApp.log_level = 30 ## # See also: Application.logging_config # c.ServerApp.logging_config = {} ## The login handler class to use. # Default: 'jupyter_server.auth.login.LegacyLoginHandler' # c.ServerApp.login_handler_class = 'jupyter_server.auth.login.LegacyLoginHandler' ## The logout handler class to use. # Default: 'jupyter_server.auth.logout.LogoutHandler' # c.ServerApp.logout_handler_class = 'jupyter_server.auth.logout.LogoutHandler' ## Sets the maximum allowed size of the client request body, specified in the # Content-Length request header field. If the size in a request exceeds the # configured value, a malformed HTTP message is returned to the client. # # Note: max_body_size is applied even in streaming mode. # Default: 536870912 # c.ServerApp.max_body_size = 536870912 ## Gets or sets the maximum amount of memory, in bytes, that is allocated for use # by the buffer manager. # Default: 536870912 # c.ServerApp.max_buffer_size = 536870912 ## Gets or sets a lower bound on the open file handles process resource limit. # This may need to be increased if you run into an OSError: [Errno 24] Too many # open files. This is not applicable when running on Windows. # Default: 0 # c.ServerApp.min_open_files_limit = 0 ## DEPRECATED, use root_dir. # Default: '' # c.ServerApp.notebook_dir = '' ## Whether to open in a browser after starting. # The specific browser used is platform dependent and # determined by the python standard library `webbrowser` # module, unless it is overridden using the --browser # (ServerApp.browser) configuration option. # Default: False # c.ServerApp.open_browser = False ## DEPRECATED in 2.0. Use PasswordIdentityProvider.hashed_password # Default: '' # c.ServerApp.password = '' ## DEPRECATED in 2.0. Use PasswordIdentityProvider.password_required # Default: False # c.ServerApp.password_required = False ## The port the server will listen on (env: JUPYTER_PORT). # Default: 0 # c.ServerApp.port = 0 ## The number of additional ports to try if the specified port is not available # (env: JUPYTER_PORT_RETRIES). # Default: 50 # c.ServerApp.port_retries = 50 ## Preferred starting directory to use for notebooks and kernels. # Default: '' # c.ServerApp.preferred_dir = '' ## DISABLED: use %pylab or %matplotlib in the notebook to enable matplotlib. # Default: 'disabled' # c.ServerApp.pylab = 'disabled' ## If True, display controls to shut down the Jupyter server, such as menu items # or buttons. # Default: True # c.ServerApp.quit_button = True ## DEPRECATED. Use ZMQChannelsWebsocketConnection.rate_limit_window # Default: 0.0 # c.ServerApp.rate_limit_window = 0.0 ## Reraise exceptions encountered loading server extensions? # Default: False # c.ServerApp.reraise_server_extension_failures = False ## The directory to use for notebooks and kernels. # Default: '' # c.ServerApp.root_dir = '' ## The session manager class to use. # Default: 'builtins.object' # c.ServerApp.session_manager_class = 'builtins.object' ## Instead of starting the Application, dump configuration to stdout # See also: Application.show_config # c.ServerApp.show_config = False ## Instead of starting the Application, dump configuration to stdout (as JSON) # See also: Application.show_config_json # c.ServerApp.show_config_json = False ## Shut down the server after N seconds with no kernelsrunning and no activity. # This can be used together with culling idle kernels # (MappingKernelManager.cull_idle_timeout) to shutdown the Jupyter server when # it's not in use. This is not precisely timed: it may shut down up to a minute # later. 0 (the default) disables this automatic shutdown. # Default: 0 # c.ServerApp.shutdown_no_activity_timeout = 0 ## The UNIX socket the Jupyter server will listen on. # Default: '' # c.ServerApp.sock = '' ## The permissions mode for UNIX socket creation (default: 0600). # Default: '0600' # c.ServerApp.sock_mode = '0600' ## Supply SSL options for the tornado HTTPServer. # See the tornado docs for details. # Default: {} # c.ServerApp.ssl_options = {} ## Paths to set up static files as immutable. # # This allow setting up the cache control of static files as immutable. It # should be used for static file named with a hash for instance. # Default: [] # c.ServerApp.static_immutable_cache = [] ## Supply overrides for terminado. Currently only supports "shell_command". # Default: {} # c.ServerApp.terminado_settings = {} ## Set to False to disable terminals. # # This does *not* make the server more secure by itself. # Anything the user can in a terminal, they can also do in a notebook. # # Terminals may also be automatically disabled if the terminado package # is not available. # Default: False # c.ServerApp.terminals_enabled = False ## DEPRECATED. Use IdentityProvider.token # Default: '<DEPRECATED>' # c.ServerApp.token = '<DEPRECATED>' ## Supply overrides for the tornado.web.Application that the Jupyter server uses. # Default: {} # c.ServerApp.tornado_settings = {} ## Whether to trust or not X-Scheme/X-Forwarded-Proto and X-Real-Ip/X-Forwarded- # For headerssent by the upstream reverse proxy. Necessary if the proxy handles # SSL # Default: False # c.ServerApp.trust_xheaders = False ## Disable launching browser by redirect file # For versions of notebook > 5.7.2, a security feature measure was added that # prevented the authentication token used to launch the browser from being visible. # This feature makes it difficult for other users on a multi-user system from # running code in your Jupyter session as you. # However, some environments (like Windows Subsystem for Linux (WSL) and Chromebooks), # launching a browser using a redirect file can lead the browser failing to load. # This is because of the difference in file structures/paths between the runtime and # the browser. # # Disabling this setting to False will disable this behavior, allowing the browser # to launch by using a URL and visible token (as before). # Default: True # c.ServerApp.use_redirect_file = True ## Specify where to open the server on startup. This is the # `new` argument passed to the standard library method `webbrowser.open`. # The behaviour is not guaranteed, but depends on browser support. Valid # values are: # # - 2 opens a new tab, # - 1 opens a new window, # - 0 opens in an existing window. # # See the `webbrowser.open` documentation for details. # Default: 2 # c.ServerApp.webbrowser_open_new = 2 ## Set the tornado compression options for websocket connections. # # This value will be returned from # :meth:`WebSocketHandler.get_compression_options`. None (default) will disable # compression. A dict (even an empty one) will enable compression. # # See the tornado docs for WebSocketHandler.get_compression_options for details. # Default: None # c.ServerApp.websocket_compression_options = None ## The base URL for websockets, # if it differs from the HTTP server (hint: it almost certainly doesn't). # # Should be in the form of an HTTP origin: ws[s]://hostname[:port] # Default: '' # c.ServerApp.websocket_url = ''
07-19
[01:26:52] 系统启动完成!优先使用「设备状态数据分析」功能,AI功能为辅 [01:26:54] 选择文件:D:/秘密基地/工作/工匠杯20250821/测试过程文件/变化开关量表(测试用例).xlsx [01:26:54] 进度[10%]: 正在读取文件... [01:26:54] 进度[10%]: 成功读取文件:变化开关量表(测试用例).xlsx(481行数据) [01:26:54] 进度[20%]: 数据预处理完成,可开始分析或AI训练 [01:26:54] 数据概览:481条记录,25台设备,2种类型 [01:26:57] 进度[85%]: 开始异常检测:规则+AI辅助... [01:26:57] 进度[85%]: 异常检测:共25台设备,按3条规则判断... [01:26:57] 设备XESBJ-临顿路站:规则③触发异常(变化次数=1次) [01:26:57] 进度[85%]: 异常检测:处理设备 XESBJ-临顿路站(1/25) [01:26:57] 进度[85%]: 异常检测:处理设备 SGMJ-临顿路站(2/25) [01:26:57] 进度[85%]: 异常检测:处理设备 SGMJ-悬桥巷站(3/25) [01:26:57] 进度[86%]: 异常检测:处理设备 SGMJ-拙政园苏博站(4/25) [01:26:57] 进度[86%]: 异常检测:处理设备 SGMJ-梅巷站(5/25) [01:26:57] 进度[87%]: 异常检测:处理设备 SKMJ-临顿路站(6/25) [01:26:57] 进度[87%]: 异常检测:处理设备 SKMJ-悬桥巷站(7/25) [01:26:57] 进度[87%]: 异常检测:处理设备 SKMJ-拙政园苏博站(8/25) [01:26:57] 进度[88%]: 异常检测:处理设备 SKMJ-梅巷站(9/25) [01:26:57] 进度[88%]: 异常检测:处理设备 SMGJ-临顿路站(10/25) [01:26:57] 进度[89%]: 异常检测:处理设备 SMGJ-悬桥巷站(11/25) [01:26:57] 进度[89%]: 异常检测:处理设备 SMGJ-拙政园苏博站(12/25) [01:26:57] 进度[89%]: 异常检测:处理设备 SMGJ-梅巷站(13/25) [01:26:57] 进度[90%]: 异常检测:处理设备 XGMJ-临顿路站(14/25) [01:26:57] 进度[90%]: 异常检测:处理设备 XGMJ-悬桥巷站(15/25) [01:26:57] 进度[91%]: 异常检测:处理设备 XGMJ-拙政园苏博站(16/25) [01:26:57] 进度[91%]: 异常检测:处理设备 XGMJ-梅巷站(17/25) [01:26:57] 进度[91%]: 异常检测:处理设备 XKMJ-临顿路站(18/25) [01:26:57] 进度[92%]: 异常检测:处理设备 XKMJ-悬桥巷站(19/25) [01:26:57] 进度[92%]: 异常检测:处理设备 XKMJ-拙政园苏博站(20/25) [01:26:57] 进度[93%]: 异常检测:处理设备 XKMJ-梅巷站(21/25) [01:26:57] 进度[93%]: 异常检测:处理设备 XMGJ-临顿路站(22/25) [01:26:57] 进度[93%]: 异常检测:处理设备 XMGJ-悬桥巷站(23/25) [01:26:57] 进度[94%]: 异常检测:处理设备 XMGJ-拙政园苏博站(24/25) [01:26:57] 进度[94%]: 异常检测:处理设备 XMGJ-梅巷站(25/25) [01:26:57] 异常检测失败:Invalid property specified for object of type plotly.graph_objs.Layout: 'paper' Did you mean "map"? Valid properties: activeselection :class:`plotly.graph_objects.layout.Activeselection` instance or dict with compatible properties activeshape :class:`plotly.graph_objects.layout.Activeshape` instance or dict with compatible properties annotations A tuple of :class:`plotly.graph_objects.layout.Annotation` instances or dicts with compatible properties annotationdefaults When used in a template (as layout.template.layout.annotationdefaults), sets the default property values to use for elements of layout.annotations autosize Determines whether or not a layout width or height that has been left undefined by the user is initialized on each relayout. Note that, regardless of this attribute, an undefined layout width or height is always initialized on the first call to plot. autotypenumbers Using "strict" a numeric string in trace data is not converted to a number. Using *convert types* a numeric string in trace data may be treated as a number during automatic axis `type` detection. This is the default value; however it could be overridden for individual axes. barcornerradius Sets the rounding of bar corners. May be an integer number of pixels, or a percentage of bar width (as a string ending in %). bargap Sets the gap (in plot fraction) between bars of adjacent location coordinates. bargroupgap Sets the gap (in plot fraction) between bars of the same location coordinate. barmode Determines how bars at the same location coordinate are displayed on the graph. With "stack", the bars are stacked on top of one another With "relative", the bars are stacked on top of one another, with negative values below the axis, positive values above With "group", the bars are plotted next to one another centered around the shared location. With "overlay", the bars are plotted over one another, you might need to reduce "opacity" to see multiple bars. barnorm Sets the normalization for bar traces on the graph. With "fraction", the value of each bar is divided by the sum of all values at that location coordinate. "percent" is the same but multiplied by 100 to show percentages. boxgap Sets the gap (in plot fraction) between boxes of adjacent location coordinates. Has no effect on traces that have "width" set. boxgroupgap Sets the gap (in plot fraction) between boxes of the same location coordinate. Has no effect on traces that have "width" set. boxmode Determines how boxes at the same location coordinate are displayed on the graph. If "group", the boxes are plotted next to one another centered around the shared location. If "overlay", the boxes are plotted over one another, you might need to set "opacity" to see them multiple boxes. Has no effect on traces that have "width" set. calendar Sets the default calendar system to use for interpreting and displaying dates throughout the plot. clickmode Determines the mode of single click interactions. "event" is the default value and emits the `plotly_click` event. In addition this mode emits the `plotly_selected` event in drag modes "lasso" and "select", but with no event data attached (kept for compatibility reasons). The "select" flag enables selecting single data points via click. This mode also supports persistent selections, meaning that pressing Shift while clicking, adds to / subtracts from an existing selection. "select" with `hovermode`: "x" can be confusing, consider explicitly setting `hovermode`: "closest" when using this feature. Selection events are sent accordingly as long as "event" flag is set as well. When the "event" flag is missing, `plotly_click` and `plotly_selected` events are not fired. coloraxis :class:`plotly.graph_objects.layout.Coloraxis` instance or dict with compatible properties colorscale :class:`plotly.graph_objects.layout.Colorscale` instance or dict with compatible properties colorway Sets the default trace colors. computed Placeholder for exporting automargin-impacting values namely `margin.t`, `margin.b`, `margin.l` and `margin.r` in "full-json" mode. datarevision If provided, a changed value tells `Plotly.react` that one or more data arrays has changed. This way you can modify arrays in-place rather than making a complete new copy for an incremental change. If NOT provided, `Plotly.react` assumes that data arrays are being treated as immutable, thus any data array with a different identity from its predecessor contains new data. dragmode Determines the mode of drag interactions. "select" and "lasso" apply only to scatter traces with markers or text. "orbit" and "turntable" apply only to 3D scenes. editrevision Controls persistence of user-driven changes in `editable: true` configuration, other than trace names and axis titles. Defaults to `layout.uirevision`. extendfunnelareacolors If `true`, the funnelarea slice colors (whether given by `funnelareacolorway` or inherited from `colorway`) will be extended to three times its original length by first repeating every color 20% lighter then each color 20% darker. This is intended to reduce the likelihood of reusing the same color when you have many slices, but you can set `false` to disable. Colors provided in the trace, using `marker.colors`, are never extended. extendiciclecolors If `true`, the icicle slice colors (whether given by `iciclecolorway` or inherited from `colorway`) will be extended to three times its original length by first repeating every color 20% lighter then each color 20% darker. This is intended to reduce the likelihood of reusing the same color when you have many slices, but you can set `false` to disable. Colors provided in the trace, using `marker.colors`, are never extended. extendpiecolors If `true`, the pie slice colors (whether given by `piecolorway` or inherited from `colorway`) will be extended to three times its original length by first repeating every color 20% lighter then each color 20% darker. This is intended to reduce the likelihood of reusing the same color when you have many slices, but you can set `false` to disable. Colors provided in the trace, using `marker.colors`, are never extended. extendsunburstcolors If `true`, the sunburst slice colors (whether given by `sunburstcolorway` or inherited from `colorway`) will be extended to three times its original length by first repeating every color 20% lighter then each color 20% darker. This is intended to reduce the likelihood of reusing the same color when you have many slices, but you can set `false` to disable. Colors provided in the trace, using `marker.colors`, are never extended. extendtreemapcolors If `true`, the treemap slice colors (whether given by `treemapcolorway` or inherited from `colorway`) will be extended to three times its original length by first repeating every color 20% lighter then each color 20% darker. This is intended to reduce the likelihood of reusing the same color when you have many slices, but you can set `false` to disable. Colors provided in the trace, using `marker.colors`, are never extended. font Sets the global font. Note that fonts used in traces and other layout components inherit from the global font. funnelareacolorway Sets the default funnelarea slice colors. Defaults to the main `colorway` used for trace colors. If you specify a new list here it can still be extended with lighter and darker colors, see `extendfunnelareacolors`. funnelgap Sets the gap (in plot fraction) between bars of adjacent location coordinates. funnelgroupgap Sets the gap (in plot fraction) between bars of the same location coordinate. funnelmode Determines how bars at the same location coordinate are displayed on the graph. With "stack", the bars are stacked on top of one another With "group", the bars are plotted next to one another centered around the shared location. With "overlay", the bars are plotted over one another, you might need to reduce "opacity" to see multiple bars. geo :class:`plotly.graph_objects.layout.Geo` instance or dict with compatible properties grid :class:`plotly.graph_objects.layout.Grid` instance or dict with compatible properties height Sets the plot's height (in px). hiddenlabels hiddenlabels is the funnelarea & pie chart analog of visible:'legendonly' but it can contain many labels, and can simultaneously hide slices from several pies/funnelarea charts hiddenlabelssrc Sets the source reference on Chart Studio Cloud for `hiddenlabels`. hidesources Determines whether or not a text link citing the data source is placed at the bottom-right cored of the figure. Has only an effect only on graphs that have been generated via forked graphs from the Chart Studio Cloud (at https://chart-studio.plotly.com or on- premise). hoverdistance Sets the default distance (in pixels) to look for data to add hover labels (-1 means no cutoff, 0 means no looking for data). This is only a real distance for hovering on point-like objects, like scatter points. For area-like objects (bars, scatter fills, etc) hovering is on inside the area and off outside, but these objects will not supersede hover on point-like objects in case of conflict. hoverlabel :class:`plotly.graph_objects.layout.Hoverlabel` instance or dict with compatible properties hovermode Determines the mode of hover interactions. If "closest", a single hoverlabel will appear for the "closest" point within the `hoverdistance`. If "x" (or "y"), multiple hoverlabels will appear for multiple points at the "closest" x- (or y-) coordinate within the `hoverdistance`, with the caveat that no more than one hoverlabel will appear per trace. If *x unified* (or *y unified*), a single hoverlabel will appear multiple points at the closest x- (or y-) coordinate within the `hoverdistance` with the caveat that no more than one hoverlabel will appear per trace. In this mode, spikelines are enabled by default perpendicular to the specified axis. If false, hover interactions are disabled. hoversubplots Determines expansion of hover effects to other subplots If "single" just the axis pair of the primary point is included without overlaying subplots. If "overlaying" all subplots using the main axis and occupying the same space are included. If "axis", also include stacked subplots using the same axis when `hovermode` is set to "x", *x unified*, "y" or *y unified*. iciclecolorway Sets the default icicle slice colors. Defaults to the main `colorway` used for trace colors. If you specify a new list here it can still be extended with lighter and darker colors, see `extendiciclecolors`. images A tuple of :class:`plotly.graph_objects.layout.Image` instances or dicts with compatible properties imagedefaults When used in a template (as layout.template.layout.imagedefaults), sets the default property values to use for elements of layout.images legend :class:`plotly.graph_objects.layout.Legend` instance or dict with compatible properties map :class:`plotly.graph_objects.layout.Map` instance or dict with compatible properties mapbox :class:`plotly.graph_objects.layout.Mapbox` instance or dict with compatible properties margin :class:`plotly.graph_objects.layout.Margin` instance or dict with compatible properties meta Assigns extra meta information that can be used in various `text` attributes. Attributes such as the graph, axis and colorbar `title.text`, annotation `text` `trace.name` in legend items, `rangeselector`, `updatemenus` and `sliders` `label` text all support `meta`. One can access `meta` fields using template strings: `%{meta[i]}` where `i` is the index of the `meta` item in question. `meta` can also be an object for example `{key: value}` which can be accessed %{meta[key]}. metasrc Sets the source reference on Chart Studio Cloud for `meta`. minreducedheight Minimum height of the plot with margin.automargin applied (in px) minreducedwidth Minimum width of the plot with margin.automargin applied (in px) modebar :class:`plotly.graph_objects.layout.Modebar` instance or dict with compatible properties newselection :class:`plotly.graph_objects.layout.Newselection` instance or dict with compatible properties newshape :class:`plotly.graph_objects.layout.Newshape` instance or dict with compatible properties paper_bgcolor Sets the background color of the paper where the graph is drawn. piecolorway Sets the default pie slice colors. Defaults to the main `colorway` used for trace colors. If you specify a new list here it can still be extended with lighter and darker colors, see `extendpiecolors`. plot_bgcolor Sets the background color of the plotting area in- between x and y axes. polar :class:`plotly.graph_objects.layout.Polar` instance or dict with compatible properties scattergap Sets the gap (in plot fraction) between scatter points of adjacent location coordinates. Defaults to `bargap`. scattermode Determines how scatter points at the same location coordinate are displayed on the graph. With "group", the scatter points are plotted next to one another centered around the shared location. With "overlay", the scatter points are plotted over one another, you might need to reduce "opacity" to see multiple scatter points. scene :class:`plotly.graph_objects.layout.Scene` instance or dict with compatible properties selectdirection When `dragmode` is set to "select", this limits the selection of the drag to horizontal, vertical or diagonal. "h" only allows horizontal selection, "v" only vertical, "d" only diagonal and "any" sets no limit. selectionrevision Controls persistence of user-driven changes in selected points from all traces. selections A tuple of :class:`plotly.graph_objects.layout.Selection` instances or dicts with compatible properties selectiondefaults When used in a template (as layout.template.layout.selectiondefaults), sets the default property values to use for elements of layout.selections separators Sets the decimal and thousand separators. For example, *. * puts a '.' before decimals and a space between thousands. In English locales, dflt is ".," but other locales may alter this default. shapes A tuple of :class:`plotly.graph_objects.layout.Shape` instances or dicts with compatible properties shapedefaults When used in a template (as layout.template.layout.shapedefaults), sets the default property values to use for elements of layout.shapes showlegend Determines whether or not a legend is drawn. Default is `true` if there is a trace to show and any of these: a) Two or more traces would by default be shown in the legend. b) One pie trace is shown in the legend. c) One trace is explicitly given with `showlegend: true`. sliders A tuple of :class:`plotly.graph_objects.layout.Slider` instances or dicts with compatible properties sliderdefaults When used in a template (as layout.template.layout.sliderdefaults), sets the default property values to use for elements of layout.sliders smith :class:`plotly.graph_objects.layout.Smith` instance or dict with compatible properties spikedistance Sets the default distance (in pixels) to look for data to draw spikelines to (-1 means no cutoff, 0 means no looking for data). As with hoverdistance, distance does not apply to area-like objects. In addition, some objects can be hovered on but will not generate spikelines, such as scatter fills. sunburstcolorway Sets the default sunburst slice colors. Defaults to the main `colorway` used for trace colors. If you specify a new list here it can still be extended with lighter and darker colors, see `extendsunburstcolors`. template Default attributes to be applied to the plot. This should be a dict with format: `{'layout': layoutTemplate, 'data': {trace_type: [traceTemplate, ...], ...}}` where `layoutTemplate` is a dict matching the structure of `figure.layout` and `traceTemplate` is a dict matching the structure of the trace with type `trace_type` (e.g. 'scatter'). Alternatively, this may be specified as an instance of plotly.graph_objs.layout.Template. Trace templates are applied cyclically to traces of each type. Container arrays (eg `annotations`) have special handling: An object ending in `defaults` (eg `annotationdefaults`) is applied to each array item. But if an item has a `templateitemname` key we look in the template array for an item with matching `name` and apply that instead. If no matching `name` is found we mark the item invisible. Any named template item not referenced is appended to the end of the array, so this can be used to add a watermark annotation or a logo image, for example. To omit one of these items on the plot, make an item with matching `templateitemname` and `visible: false`. ternary :class:`plotly.graph_objects.layout.Ternary` instance or dict with compatible properties title :class:`plotly.graph_objects.layout.Title` instance or dict with compatible properties transition Sets transition options used during Plotly.react updates. treemapcolorway Sets the default treemap slice colors. Defaults to the main `colorway` used for trace colors. If you specify a new list here it can still be extended with lighter and darker colors, see `extendtreemapcolors`. uirevision Used to allow user interactions with the plot to persist after `Plotly.react` calls that are unaware of these interactions. If `uirevision` is omitted, or if it is given and it changed from the previous `Plotly.react` call, the exact new figure is used. If `uirevision` is truthy and did NOT change, any attribute that has been affected by user interactions and did not receive a different value in the new figure will keep the interaction value. `layout.uirevision` attribute serves as the default for `uirevision` attributes in various sub-containers. For finer control you can set these sub-attributes directly. For example, if your app separately controls the data on the x and y axes you might set `xaxis.uirevision=*time*` and `yaxis.uirevision=*cost*`. Then if only the y data is changed, you can update `yaxis.uirevision=*quantity*` and the y axis range will reset but the x axis range will retain any user-driven zoom. uniformtext :class:`plotly.graph_objects.layout.Uniformtext` instance or dict with compatible properties updatemenus A tuple of :class:`plotly.graph_objects.layout.Updatemenu` instances or dicts with compatible properties updatemenudefaults When used in a template (as layout.template.layout.updatemenudefaults), sets the default property values to use for elements of layout.updatemenus violingap Sets the gap (in plot fraction) between violins of adjacent location coordinates. Has no effect on traces that have "width" set. violingroupgap Sets the gap (in plot fraction) between violins of the same location coordinate. Has no effect on traces that have "width" set. violinmode Determines how violins at the same location coordinate are displayed on the graph. If "group", the violins are plotted next to one another centered around the shared location. If "overlay", the violins are plotted over one another, you might need to set "opacity" to see them multiple violins. Has no effect on traces that have "width" set. waterfallgap Sets the gap (in plot fraction) between bars of adjacent location coordinates. waterfallgroupgap Sets the gap (in plot fraction) between bars of the same location coordinate. waterfallmode Determines how bars at the same location coordinate are displayed on the graph. With "group", the bars are plotted next to one another centered around the shared location. With "overlay", the bars are plotted over one another, you might need to reduce "opacity" to see multiple bars. width Sets the plot's width (in px). xaxis :class:`plotly.graph_objects.layout.XAxis` instance or dict with compatible properties yaxis :class:`plotly.graph_objects.layout.YAxis` instance or dict with compatible properties Did you mean "map"? Bad property path: paper_b极值点color ^^^^^ [01:26:57] Traceback (most recent call last): File "D:\秘密基地\工作\工匠杯20250821\AI.py", line 1925, in _detect_abnormal_core html_path = self._generate_abnormal_html_report(device_summary_df) File "D:\秘密基地\工作\工匠杯20250821\AI.py", line 1613, in _generate_abnormal_html_report fig2.update_layout( ~~~~~~~~~~~~~~~~~~^ font=dict(family=PLOTLY_FONT, size=12), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...<2 lines>... paper_b极值点color='rgba(248,249,250,1)' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "D:\Python\Lib\site-packages\plotly\graph_objs\_figure.py", line 787, in update_layout return super(Figure, self).update_layout(dict1, overwrite, **kwargs) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Python\Lib\site-packages\plotly\basedatatypes.py", line 1392, in update_layout self.layout.update(dict1, overwrite=overwrite, **kwargs) ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Python\Lib\site-packages\plotly\basedatatypes.py", line 5123, in update BaseFigure._perform_update(self, kwargs, overwrite=overwrite) ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Python\Lib\site-packages\plotly\basedatatypes.py", line 3882, in _perform_update raise err ValueError: Invalid property specified for object of type plotly.graph_objs.Layout: 'paper' Did you mean "map"? Valid properties: activeselection :class:`plotly.graph_objects.layout.Activeselection` instance or dict with compatible properties activeshape :class:`plotly.graph_objects.layout.Activeshape` instance or dict with compatible properties annotations A tuple of :class:`plotly.graph_objects.layout.Annotation` instances or dicts with compatible properties annotationdefaults When used in a template (as layout.template.layout.annotationdefaults), sets the default property values to use for elements of layout.annotations autosize Determines whether or not a layout width or height that has been left undefined by the user is initialized on each relayout. Note that, regardless of this attribute, an undefined layout width or height is always initialized on the first call to plot. autotypenumbers Using "strict" a numeric string in trace data is not converted to a number. Using *convert types* a numeric string in trace data may be treated as a number during automatic axis `type` detection. This is the default value; however it could be overridden for individual axes. barcornerradius Sets the rounding of bar corners. May be an integer number of pixels, or a percentage of bar width (as a string ending in %). bargap Sets the gap (in plot fraction) between bars of adjacent location coordinates. bargroupgap Sets the gap (in plot fraction) between bars of the same location coordinate. barmode Determines how bars at the same location coordinate are displayed on the graph. With "stack", the bars are stacked on top of one another With "relative", the bars are stacked on top of one another, with negative values below the axis, positive values above With "group", the bars are plotted next to one another centered around the shared location. With "overlay", the bars are plotted over one another, you might need to reduce "opacity" to see multiple bars. barnorm Sets the normalization for bar traces on the graph. With "fraction", the value of each bar is divided by the sum of all values at that location coordinate. "percent" is the same but multiplied by 100 to show percentages. boxgap Sets the gap (in plot fraction) between boxes of adjacent location coordinates. Has no effect on traces that have "width" set. boxgroupgap Sets the gap (in plot fraction) between boxes of the same location coordinate. Has no effect on traces that have "width" set. boxmode Determines how boxes at the same location coordinate are displayed on the graph. If "group", the boxes are plotted next to one another centered around the shared location. If "overlay", the boxes are plotted over one another, you might need to set "opacity" to see them multiple boxes. Has no effect on traces that have "width" set. calendar Sets the default calendar system to use for interpreting and displaying dates throughout the plot. clickmode Determines the mode of single click interactions. "event" is the default value and emits the `plotly_click` event. In addition this mode emits the `plotly_selected` event in drag modes "lasso" and "select", but with no event data attached (kept for compatibility reasons). The "select" flag enables selecting single data points via click. This mode also supports persistent selections, meaning that pressing Shift while clicking, adds to / subtracts from an existing selection. "select" with `hovermode`: "x" can be confusing, consider explicitly setting `hovermode`: "closest" when using this feature. Selection events are sent accordingly as long as "event" flag is set as well. When the "event" flag is missing, `plotly_click` and `plotly_selected` events are not fired. coloraxis :class:`plotly.graph_objects.layout.Coloraxis` instance or dict with compatible properties colorscale :class:`plotly.graph_objects.layout.Colorscale` instance or dict with compatible properties colorway Sets the default trace colors. computed Placeholder for exporting automargin-impacting values namely `margin.t`, `margin.b`, `margin.l` and `margin.r` in "full-json" mode. datarevision If provided, a changed value tells `Plotly.react` that one or more data arrays has changed. This way you can modify arrays in-place rather than making a complete new copy for an incremental change. If NOT provided, `Plotly.react` assumes that data arrays are being treated as immutable, thus any data array with a different identity from its predecessor contains new data. dragmode Determines the mode of drag interactions. "select" and "lasso" apply only to scatter traces with markers or text. "orbit" and "turntable" apply only to 3D scenes. editrevision Controls persistence of user-driven changes in `editable: true` configuration, other than trace names and axis titles. Defaults to `layout.uirevision`. extendfunnelareacolors If `true`, the funnelarea slice colors (whether given by `funnelareacolorway` or inherited from `colorway`) will be extended to three times its original length by first repeating every color 20% lighter then each color 20% darker. This is intended to reduce the likelihood of reusing the same color when you have many slices, but you can set `false` to disable. Colors provided in the trace, using `marker.colors`, are never extended. extendiciclecolors If `true`, the icicle slice colors (whether given by `iciclecolorway` or inherited from `colorway`) will be extended to three times its original length by first repeating every color 20% lighter then each color 20% darker. This is intended to reduce the likelihood of reusing the same color when you have many slices, but you can set `false` to disable. Colors provided in the trace, using `marker.colors`, are never extended. extendpiecolors If `true`, the pie slice colors (whether given by `piecolorway` or inherited from `colorway`) will be extended to three times its original length by first repeating every color 20% lighter then each color 20% darker. This is intended to reduce the likelihood of reusing the same color when you have many slices, but you can set `false` to disable. Colors provided in the trace, using `marker.colors`, are never extended. extendsunburstcolors If `true`, the sunburst slice colors (whether given by `sunburstcolorway` or inherited from `colorway`) will be extended to three times its original length by first repeating every color 20% lighter then each color 20% darker. This is intended to reduce the likelihood of reusing the same color when you have many slices, but you can set `false` to disable. Colors provided in the trace, using `marker.colors`, are never extended. extendtreemapcolors If `true`, the treemap slice colors (whether given by `treemapcolorway` or inherited from `colorway`) will be extended to three times its original length by first repeating every color 20% lighter then each color 20% darker. This is intended to reduce the likelihood of reusing the same color when you have many slices, but you can set `false` to disable. Colors provided in the trace, using `marker.colors`, are never extended. font Sets the global font. Note that fonts used in traces and other layout components inherit from the global font. funnelareacolorway Sets the default funnelarea slice colors. Defaults to the main `colorway` used for trace colors. If you specify a new list here it can still be extended with lighter and darker colors, see `extendfunnelareacolors`. funnelgap Sets the gap (in plot fraction) between bars of adjacent location coordinates. funnelgroupgap Sets the gap (in plot fraction) between bars of the same location coordinate. funnelmode Determines how bars at the same location coordinate are displayed on the graph. With "stack", the bars are stacked on top of one another With "group", the bars are plotted next to one another centered around the shared location. With "overlay", the bars are plotted over one another, you might need to reduce "opacity" to see multiple bars. geo :class:`plotly.graph_objects.layout.Geo` instance or dict with compatible properties grid :class:`plotly.graph_objects.layout.Grid` instance or dict with compatible properties height Sets the plot's height (in px). hiddenlabels hiddenlabels is the funnelarea & pie chart analog of visible:'legendonly' but it can contain many labels, and can simultaneously hide slices from several pies/funnelarea charts hiddenlabelssrc Sets the source reference on Chart Studio Cloud for `hiddenlabels`. hidesources Determines whether or not a text link citing the data source is placed at the bottom-right cored of the figure. Has only an effect only on graphs that have been generated via forked graphs from the Chart Studio Cloud (at https://chart-studio.plotly.com or on- premise). hoverdistance Sets the default distance (in pixels) to look for data to add hover labels (-1 means no cutoff, 0 means no looking for data). This is only a real distance for hovering on point-like objects, like scatter points. For area-like objects (bars, scatter fills, etc) hovering is on inside the area and off outside, but these objects will not supersede hover on point-like objects in case of conflict. hoverlabel :class:`plotly.graph_objects.layout.Hoverlabel` instance or dict with compatible properties hovermode Determines the mode of hover interactions. If "closest", a single hoverlabel will appear for the "closest" point within the `hoverdistance`. If "x" (or "y"), multiple hoverlabels will appear for multiple points at the "closest" x- (or y-) coordinate within the `hoverdistance`, with the caveat that no more than one hoverlabel will appear per trace. If *x unified* (or *y unified*), a single hoverlabel will appear multiple points at the closest x- (or y-) coordinate within the `hoverdistance` with the caveat that no more than one hoverlabel will appear per trace. In this mode, spikelines are enabled by default perpendicular to the specified axis. If false, hover interactions are disabled. hoversubplots Determines expansion of hover effects to other subplots If "single" just the axis pair of the primary point is included without overlaying subplots. If "overlaying" all subplots using the main axis and occupying the same space are included. If "axis", also include stacked subplots using the same axis when `hovermode` is set to "x", *x unified*, "y" or *y unified*. iciclecolorway Sets the default icicle slice colors. Defaults to the main `colorway` used for trace colors. If you specify a new list here it can still be extended with lighter and darker colors, see `extendiciclecolors`. images A tuple of :class:`plotly.graph_objects.layout.Image` instances or dicts with compatible properties imagedefaults When used in a template (as layout.template.layout.imagedefaults), sets the default property values to use for elements of layout.images legend :class:`plotly.graph_objects.layout.Legend` instance or dict with compatible properties map :class:`plotly.graph_objects.layout.Map` instance or dict with compatible properties mapbox :class:`plotly.graph_objects.layout.Mapbox` instance or dict with compatible properties margin :class:`plotly.graph_objects.layout.Margin` instance or dict with compatible properties meta Assigns extra meta information that can be used in various `text` attributes. Attributes such as the graph, axis and colorbar `title.text`, annotation `text` `trace.name` in legend items, `rangeselector`, `updatemenus` and `sliders` `label` text all support `meta`. One can access `meta` fields using template strings: `%{meta[i]}` where `i` is the index of the `meta` item in question. `meta` can also be an object for example `{key: value}` which can be accessed %{meta[key]}. metasrc Sets the source reference on Chart Studio Cloud for `meta`. minreducedheight Minimum height of the plot with margin.automargin applied (in px) minreducedwidth Minimum width of the plot with margin.automargin applied (in px) modebar :class:`plotly.graph_objects.layout.Modebar` instance or dict with compatible properties newselection :class:`plotly.graph_objects.layout.Newselection` instance or dict with compatible properties newshape :class:`plotly.graph_objects.layout.Newshape` instance or dict with compatible properties paper_bgcolor Sets the background color of the paper where the graph is drawn. piecolorway Sets the default pie slice colors. Defaults to the main `colorway` used for trace colors. If you specify a new list here it can still be extended with lighter and darker colors, see `extendpiecolors`. plot_bgcolor Sets the background color of the plotting area in- between x and y axes. polar :class:`plotly.graph_objects.layout.Polar` instance or dict with compatible properties scattergap Sets the gap (in plot fraction) between scatter points of adjacent location coordinates. Defaults to `bargap`. scattermode Determines how scatter points at the same location coordinate are displayed on the graph. With "group", the scatter points are plotted next to one another centered around the shared location. With "overlay", the scatter points are plotted over one another, you might need to reduce "opacity" to see multiple scatter points. scene :class:`plotly.graph_objects.layout.Scene` instance or dict with compatible properties selectdirection When `dragmode` is set to "select", this limits the selection of the drag to horizontal, vertical or diagonal. "h" only allows horizontal selection, "v" only vertical, "d" only diagonal and "any" sets no limit. selectionrevision Controls persistence of user-driven changes in selected points from all traces. selections A tuple of :class:`plotly.graph_objects.layout.Selection` instances or dicts with compatible properties selectiondefaults When used in a template (as layout.template.layout.selectiondefaults), sets the default property values to use for elements of layout.selections separators Sets the decimal and thousand separators. For example, *. * puts a '.' before decimals and a space between thousands. In English locales, dflt is ".," but other locales may alter this default. shapes A tuple of :class:`plotly.graph_objects.layout.Shape` instances or dicts with compatible properties shapedefaults When used in a template (as layout.template.layout.shapedefaults), sets the default property values to use for elements of layout.shapes showlegend Determines whether or not a legend is drawn. Default is `true` if there is a trace to show and any of these: a) Two or more traces would by default be shown in the legend. b) One pie trace is shown in the legend. c) One trace is explicitly given with `showlegend: true`. sliders A tuple of :class:`plotly.graph_objects.layout.Slider` instances or dicts with compatible properties sliderdefaults When used in a template (as layout.template.layout.sliderdefaults), sets the default property values to use for elements of layout.sliders smith :class:`plotly.graph_objects.layout.Smith` instance or dict with compatible properties spikedistance Sets the default distance (in pixels) to look for data to draw spikelines to (-1 means no cutoff, 0 means no looking for data). As with hoverdistance, distance does not apply to area-like objects. In addition, some objects can be hovered on but will not generate spikelines, such as scatter fills. sunburstcolorway Sets the default sunburst slice colors. Defaults to the main `colorway` used for trace colors. If you specify a new list here it can still be extended with lighter and darker colors, see `extendsunburstcolors`. template Default attributes to be applied to the plot. This should be a dict with format: `{'layout': layoutTemplate, 'data': {trace_type: [traceTemplate, ...], ...}}` where `layoutTemplate` is a dict matching the structure of `figure.layout` and `traceTemplate` is a dict matching the structure of the trace with type `trace_type` (e.g. 'scatter'). Alternatively, this may be specified as an instance of plotly.graph_objs.layout.Template. Trace templates are applied cyclically to traces of each type. Container arrays (eg `annotations`) have special handling: An object ending in `defaults` (eg `annotationdefaults`) is applied to each array item. But if an item has a `templateitemname` key we look in the template array for an item with matching `name` and apply that instead. If no matching `name` is found we mark the item invisible. Any named template item not referenced is appended to the end of the array, so this can be used to add a watermark annotation or a logo image, for example. To omit one of these items on the plot, make an item with matching `templateitemname` and `visible: false`. ternary :class:`plotly.graph_objects.layout.Ternary` instance or dict with compatible properties title :class:`plotly.graph_objects.layout.Title` instance or dict with compatible properties transition Sets transition options used during Plotly.react updates. treemapcolorway Sets the default treemap slice colors. Defaults to the main `colorway` used for trace colors. If you specify a new list here it can still be extended with lighter and darker colors, see `extendtreemapcolors`. uirevision Used to allow user interactions with the plot to persist after `Plotly.react` calls that are unaware of these interactions. If `uirevision` is omitted, or if it is given and it changed from the previous `Plotly.react` call, the exact new figure is used. If `uirevision` is truthy and did NOT change, any attribute that has been affected by user interactions and did not receive a different value in the new figure will keep the interaction value. `layout.uirevision` attribute serves as the default for `uirevision` attributes in various sub-containers. For finer control you can set these sub-attributes directly. For example, if your app separately controls the data on the x and y axes you might set `xaxis.uirevision=*time*` and `yaxis.uirevision=*cost*`. Then if only the y data is changed, you can update `yaxis.uirevision=*quantity*` and the y axis range will reset but the x axis range will retain any user-driven zoom. uniformtext :class:`plotly.graph_objects.layout.Uniformtext` instance or dict with compatible properties updatemenus A tuple of :class:`plotly.graph_objects.layout.Updatemenu` instances or dicts with compatible properties updatemenudefaults When used in a template (as layout.template.layout.updatemenudefaults), sets the default property values to use for elements of layout.updatemenus violingap Sets the gap (in plot fraction) between violins of adjacent location coordinates. Has no effect on traces that have "width" set. violingroupgap Sets the gap (in plot fraction) between violins of the same location coordinate. Has no effect on traces that have "width" set. violinmode Determines how violins at the same location coordinate are displayed on the graph. If "group", the violins are plotted next to one another centered around the shared location. If "overlay", the violins are plotted over one another, you might need to set "opacity" to see them multiple violins. Has no effect on traces that have "width" set. waterfallgap Sets the gap (in plot fraction) between bars of adjacent location coordinates. waterfallgroupgap Sets the gap (in plot fraction) between bars of the same location coordinate. waterfallmode Determines how bars at the same location coordinate are displayed on the graph. With "group", the bars are plotted next to one another centered around the shared location. With "overlay", the bars are plotted over one another, you might need to reduce "opacity" to see multiple bars. width Sets the plot's width (in px). xaxis :class:`plotly.graph_objects.layout.XAxis` instance or dict with compatible properties yaxis :class:`plotly.graph_objects.layout.YAxis` instance or dict with compatible properties Did you mean "map"? Bad property path: paper_b极值点color ^^^^^
08-27
### 关于 'Cursor You have reached your trial request limit' 的解释 当收到此错误消息时,表明当前机器上创建的免费试用账户数量已超过官方设定的最大限额。这是为了防止服务被滥用而设置的安全措施[^1]。 #### 解决方案概述 对于希望继续使用 Cursor 工具而不受上述限制影响的情况,建议考虑升级至专业版订阅计划。这不仅能够解除现有功能上的诸多约束,还能享受更多高级特性和服务支持[^3]。 另外一种临时性的处理手段涉及手动调整本地配置文件: - **定位存储文件** 根据操作系统不同,`storage.json` 文件的位置有所差异: - Windows: `%APPDATA%\Cursor\User\globalStorage\storage.json` - macOS: `~/Library/Application Support/Cursor/User/globalStorage/storage.json` - Linux: `~/.config/Cursor/User/globalStorage/storage.json` - **更改访问权限** 确认目标 JSON 文件具备写入权限以便后续编辑操作顺利进行。针对各平台的具体做法如下所示: - 对于 Windows 用户而言,可以通过图形界面完成这项工作——只需右击相应路径下的 `storage.json` 并选取“属性”,再将其中的“只读”状态移除即可。 - 而在 Unix 类似环境中,则推荐利用命令行工具执行相同任务;例如,在终端内键入 `chmod 666 storage.json` 即可赋予所有者及其他用户对该文档完整的控制权[^4]。 ```bash # MacOS 或 Linux 下修改文件权限示例 chmod 666 ~/Library/Application\ Support/Cursor/User/globalStorage/storage.json ``` 最后一步则是实际对 `storage.json` 内容作出适当改动来绕过试用次数上限的问题。不过需要注意的是,此类非正式途径可能违反软件许可协议条款,并且存在潜在风险,因此务必谨慎行事。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值