def create_app_from_workspace(workspace: Workspace, instance: DagsterInstance, path_prefix: str = ""): check.inst_param(workspace, "workspace", Workspace) check.inst_param(instance, "instance", DagsterInstance) check.str_param(path_prefix, "path_prefix") if path_prefix: if not path_prefix.startswith("/"): raise Exception( f'The path prefix should begin with a leading "/": got {path_prefix}' ) if path_prefix.endswith("/"): raise Exception( f'The path prefix should not include a trailing "/": got {path_prefix}' ) warn_if_compute_logs_disabled() print("Loading repository...") # pylint: disable=print-call context = WorkspaceProcessContext(instance=instance, workspace=workspace, version=__version__) log_workspace_stats(instance, context) schema = create_schema() return instantiate_app_with_views(context, schema, path_prefix)
def create_app_from_workspace_process_context( workspace_process_context: WorkspaceProcessContext, path_prefix: str = "", ) -> Starlette: check.inst_param(workspace_process_context, "workspace_process_context", WorkspaceProcessContext) check.str_param(path_prefix, "path_prefix") instance = workspace_process_context.instance if path_prefix: if not path_prefix.startswith("/"): raise Exception( f'The path prefix should begin with a leading "/": got {path_prefix}' ) if path_prefix.endswith("/"): raise Exception( f'The path prefix should not include a trailing "/": got {path_prefix}' ) warn_if_compute_logs_disabled() log_workspace_stats(instance, workspace_process_context) return DagitWebserver( workspace_process_context, path_prefix, ).create_asgi_app()
def create_app_from_workspace_process_context( workspace_process_context: WorkspaceProcessContext, path_prefix: str = "", ) -> Flask: check.inst_param(workspace_process_context, "workspace_process_context", WorkspaceProcessContext) check.str_param(path_prefix, "path_prefix") instance = workspace_process_context.instance if path_prefix: if not path_prefix.startswith("/"): raise Exception( f'The path prefix should begin with a leading "/": got {path_prefix}' ) if path_prefix.endswith("/"): raise Exception( f'The path prefix should not include a trailing "/": got {path_prefix}' ) warn_if_compute_logs_disabled() log_workspace_stats(instance, workspace_process_context) schema = create_schema() return instantiate_app_with_views(workspace_process_context, schema, path_prefix, include_notebook_route=True)
def test_log_workspace_stats(caplog): with instance_for_test(overrides={"telemetry": {"enabled": True}}) as instance: with load_workspace_process_context_from_yaml_paths( instance, [file_relative_path(__file__, "./multi_env_telemetry_workspace.yaml")] ) as context: log_workspace_stats(instance, context) for record in caplog.records: message = json.loads(record.getMessage()) assert message.get("action") == UPDATE_REPO_STATS assert set(message.keys()) == EXPECTED_KEYS assert len(caplog.records) == 2
def host_dagit_ui_with_workspace(instance, workspace, host, port, path_prefix, port_lookup=True): check.inst_param(instance, "instance", DagsterInstance) check.inst_param(workspace, "workspace", Workspace) log_workspace_stats(instance, workspace) app = create_app_from_workspace(workspace, instance, path_prefix) start_server(instance, host, port, path_prefix, app, port_lookup)
def test_log_workspace_stats(caplog): with instance_for_test() as instance: with load_workspace_from_yaml_paths([ file_relative_path(__file__, "./multi_env_telemetry_workspace.yaml") ]) as workspace: log_workspace_stats(instance, workspace) for record in caplog.records: message = json.loads(record.getMessage()) assert message.get("action") == UPDATE_REPO_STATS assert set(message.keys()) == EXPECTED_KEYS assert len(caplog.records) == 2