Skip to content

Commit

Permalink
MNT #588 no more circular imports reported
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Nov 27, 2021
1 parent f2b0d1b commit 7ff3280
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions apstools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,12 @@
# The full license is in the file LICENSE.txt, distributed with this software.
# -----------------------------------------------------------------------------

from bluesky import plan_stubs as bps
from bluesky.callbacks.best_effort import BestEffortCallback
from collections import defaultdict
from collections import OrderedDict
from databroker._drivers.mongo_normalized import BlueskyMongoCatalog
from dataclasses import dataclass
from email.mime.text import MIMEText
from event_model import NumpyEncoder

import databroker
import databroker.queries
import databroker._drivers.mongo_normalized
import databroker._drivers.msgpack
import datetime
import intake
import json
import logging
import math
Expand All @@ -158,6 +152,14 @@
import warnings
import zipfile

from bluesky import plan_stubs as bps
from bluesky.callbacks.best_effort import BestEffortCallback
from collections import defaultdict
from collections import OrderedDict
from dataclasses import dataclass
from email.mime.text import MIMEText
from event_model import NumpyEncoder

from .filewriters import _rebuild_scan_command
from ._utils import *
from ._utils import getDefaultNamespace
Expand All @@ -166,10 +168,20 @@

logger = logging.getLogger(__name__)

MAX_EPICS_STRINGOUT_LENGTH = 40

CATALOG_CLASSES = (
databroker.Broker,
databroker._drivers.mongo_normalized.BlueskyMongoCatalog,
databroker._drivers.msgpack.BlueskyMsgpackCatalog,
intake.Catalog,
)
MONGO_CATALOG_CLASSES = (
databroker.Broker,
databroker._drivers.mongo_normalized.BlueskyMongoCatalog,
# intake.Catalog,
)
FIRST_DATA = "1995-01-01"
LAST_DATA = "2100-12-31"
MAX_EPICS_STRINGOUT_LENGTH = 40


class ExcelReadError(openpyxl.utils.exceptions.InvalidFileException):
Expand Down Expand Up @@ -356,11 +368,9 @@ def getDefaultDatabase():

# note all database instances in memory
db_list = []
for k, v in g.items():
if hasattr(v, "__class__") and not k.startswith("_"):
end = v.__class__.__name__.split(".")[-1]
if end in ("Broker", "BlueskyMongoCatalog"):
db_list.append(v)
for v in g.values():
if isinstance(v, CATALOG_CLASSES):
db_list.append(v)

# easy decisions first
if len(db_list) == 0:
Expand Down Expand Up @@ -943,7 +953,7 @@ def _sort(uid):
exc,
)
else:
if isinstance(cat, BlueskyMongoCatalog) and self.sortby == "time":
if isinstance(cat, MONGO_CATALOG_CLASSES) and self.sortby == "time":
if self.reverse:
# the default rendering: from MongoDB in reverse time order
sequence = iter(cat)
Expand Down

0 comments on commit 7ff3280

Please sign in to comment.