MCPcopy Index your code
hub / github.com/plotly/dash / import_app

Function import_app

dash/testing/application_runners.py:31–56  ·  view source on GitHub ↗

Import a dash application from a module. The import path is in dot notation to the module. The variable named app will be returned. :Example: >>> app = import_app("my_app.app") Will import the application in module `app` of the package `my_app`. :param app_file: Path to t

(app_file, application_name="app")

Source from the content-addressed store, hash-verified

29
30
31def import_app(app_file, application_name="app"):
32 """Import a dash application from a module. The import path is in dot
33 notation to the module. The variable named app will be returned.
34
35 :Example:
36
37 >>> app = import_app("my_app.app")
38
39 Will import the application in module `app` of the package `my_app`.
40
41 :param app_file: Path to the app (dot-separated).
42 :type app_file: str
43 :param application_name: The name of the dash application instance.
44 :raise: dash_tests.errors.NoAppFoundError
45 :return: App from module.
46 :rtype: dash.Dash
47 """
48 try:
49 app_module = runpy.run_module(app_file)
50 app = app_module[application_name]
51 except KeyError as app_name_missing:
52 logger.exception("the app name cannot be found")
53 raise NoAppFoundError(
54 f"No dash `app` instance was found in {app_file}"
55 ) from app_name_missing
56 return app
57
58
59class BaseDashRunner:

Callers 2

Calls 1

NoAppFoundErrorClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…