IEEE.org     |     IEEE Xplore Digital Library     |     IEEE Standards     |     IEEE Spectrum     |     More Sites

Verified Commit 298ae92d authored by Emi Simpson's avatar Emi Simpson
Browse files

Don't error when dashboards aren't yet loaded

parent c1ab22e9
......@@ -13,10 +13,12 @@ This module also includes methods like `get_user` and `get_project`, which can b
determine the active user/project.
"""
import asyncio
from logging import warn
from mystic.coordination import JobDict
from mystic.analytics.queries import QueryMachine
from mystic.analytics.dashboards import DASHBOARDS, Dashboard
from elasticsearch.client import Elasticsearch
from elasticsearch.exceptions import NotFoundError
from flask.helpers import flash
from pymysql.cursors import Cursor
......@@ -25,7 +27,7 @@ from mystic.sources import SOURCE_PROCESSORS
from flask import request, session, g
from mystic.database import MalformedId, Project, User
from mystic.config import connect_coordinator, get_auth_module, save_projects_json
from typing import Any, Callable, Coroutine, Dict, List, Optional, Set, Tuple, cast
from typing import Callable, Dict, Generator, List, Optional, Set, cast
class ErrorTuple(Exception):
"""
......@@ -372,8 +374,8 @@ def try_action(c: Cursor) -> None:
e.category = f'error-{e.category}'
raise e
def get_analytics(c: Cursor, es: Elasticsearch, project: Project) -> List[Dashboard]:
dashboards = [
def get_analytics(c: Cursor, es: Elasticsearch, project: Project) -> Generator[Dashboard, None, bool]:
dashboards = (
d
for d in (
d.produce_for(c, project)
......@@ -381,11 +383,15 @@ def get_analytics(c: Cursor, es: Elasticsearch, project: Project) -> List[Dashbo
in DASHBOARDS
)
if d is not None
]
)
for d in dashboards:
qm = QueryMachine()
d.load(es, qm)
return cast(List[Dashboard], dashboards)
try:
d.load(es, qm)
yield d
except NotFoundError:
warn("Not found error indicates that some dashboard isn't set up")
def get_pending_jobs(p: Project) -> List[JobDict]:
async def get_jobs() -> List[JobDict]:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment