pcdshub / pmps-ui

User interfaces and diagnostics for PMPS
Other
0 stars 8 forks source link

REF: move internal imports to a reasonable place #103

Open tangkong opened 7 months ago

tangkong commented 7 months ago

Expected Behavior

There are places where we import modules/functions inside functions, rather than in the module preamble. For example:

Current Behavior

We should structure the package more sensibly

Possible Solution

Copy paste, see if it breaks?

Context

100

Your Environment

pcds-5.8.1

ZLLentz commented 7 months ago

Just to add a bit, typically there are two reasons you might delay an import or put it inside some internal function:

  1. something terrible has happened to make the import order matter
  2. the imports are slow and the code path that needs the import isn't always hit when running the software

I don't think either of these are true here.

tangkong commented 7 months ago

I overlooked the actual reason these are imported in the method: PyDM's initialization routines don't work well if more than one Display subclass is present in the file's namespace

https://github.com/pcdshub/pmps-ui/blob/f14fbb380d0a9744ba3e9f122caf103dff6834d0/pmpsui/pmps.py#L218-L220

This makes me want to reconsider initializing this through PyDMApplication at all. Refactoring this to just use a standard QApplication would be my suggestion if it didn't result in loads of teardown errors... 🤔

I'll have to look into exactly which parts of PyDMApplication are necessary for this work

ZLLentz commented 7 months ago