spc-group / haven

Bluesky tools for beamlines managed by the spectroscopy group
https://haven-spc.readthedocs.io/en/latest/
Other
2 stars 6 forks source link

Make a Haven window for the ``bluesky.plans.count`` plan #143

Closed canismarko closed 4 months ago

Cathyhjj commented 10 months ago

I just pushed intial ui draft for plans.count and 1d scan plans. Let me know if you have improvement ideas. Also before starting its corresponding python file, I wanted to run test_main_window.py in haven/tests. But it returned the following error and no window pops up:

(haven) [juanjuan.huang@goldendale]~/src/haven/tests% python test_main_window.py

/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/epicscorelibs/path/pyepics.py:18: UserWarning: epicscorelibs.path.pyepics must be imported before epics.ca to have effect warnings.warn("epicscorelibs.path.pyepics must be imported before epics.ca to have effect") /home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/apstools/devices/aps_data_management.py

canismarko commented 10 months ago

@Cathyhjj Is there a summary afterwards that says how many tests passed? If there were no failures or errors then we can ignore that warning.

Cathyhjj commented 10 months ago

I tried pytest in haven directory. But I don't think any test has passed? See error messages below.

(haven) [juanjuan.huang@goldendale]~/src/haven/tests% pytest ============================================================================== test session starts =============================================================================== platform linux -- Python 3.9.18, pytest-7.4.3, pluggy-1.3.0 PyQt5 5.15.9 -- Qt runtime 5.15.8 -- Qt compiled 5.15.8 rootdir: /home/beams0/JUANJUAN.HUANG/src/haven configfile: pytest.ini plugins: anyio-4.0.0, asyncio-0.22.0, cov-4.1.0, mock-3.12.0, qt-4.2.0, xvfb-3.0.0, time-machine-2.13.0, timeout-2.2.0, mongodb-2.4.0 asyncio: mode=strict collected 153 items
INTERNALERROR> Traceback (most recent call last): INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/_pytest/main.py", line 271, in wrap_session INTERNALERROR> session.exitstatus = doit(config, session) or 0 INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/_pytest/main.py", line 324, in _main INTERNALERROR> config.hook.pytest_collection(session=session) INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/pluggy/_hooks.py", line 493, in call INTERNALERROR> return self._hookexec(self.name, self._hookimpls, kwargs, firstresult) INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/pluggy/_manager.py", line 115, in _hookexec INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult) INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/pluggy/_callers.py", line 152, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/pluggy/_result.py", line 114, in get_result INTERNALERROR> raise exc.with_traceback(exc.traceback) INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/pluggy/_callers.py", line 77, in _multicall INTERNALERROR> res = hook_impl.function(args) INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/_pytest/main.py", line 335, in pytest_collection INTERNALERROR> session.perform_collect() INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/_pytest/main.py", line 675, in perform_collect INTERNALERROR> self.items.extend(self.genitems(node)) INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/_pytest/main.py", line 842, in genitems INTERNALERROR> rep = collect_one_node(node) INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/_pytest/runner.py", line 546, in collect_one_node INTERNALERROR> ihook.pytest_collectstart(collector=collector) INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/pluggy/_hooks.py", line 493, in call INTERNALERROR> return self._hookexec(self.name, self._hookimpls, kwargs, firstresult) INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/pluggy/_manager.py", line 115, in _hookexec INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult) INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/pluggy/_callers.py", line 113, in _multicall INTERNALERROR> raise exception.with_traceback(exception.traceback) INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/pluggy/_callers.py", line 77, in _multicall INTERNALERROR> res = hook_impl.function(args) INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/pytest_asyncio/plugin.py", line 552, in pytest_collectstart INTERNALERROR> marks = get_unpacked_marks(collector.obj, consider_mro=True) INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/_pytest/python.py", line 310, in obj INTERNALERROR> self._obj = obj = self._getobj() INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/_pytest/python.py", line 528, in _getobj INTERNALERROR> return self._importtestmodule() INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/_pytest/python.py", line 617, in _importtestmodule INTERNALERROR> mod = import_path(self.path, mode=importmode, root=self.config.rootpath) INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/_pytest/pathlib.py", line 567, in import_path INTERNALERROR> importlib.import_module(module_name) INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/importlib/init.py", line 127, in import_module INTERNALERROR> return _bootstrap._gcd_import(name[level:], package, level) INTERNALERROR> File "", line 1030, in _gcd_import INTERNALERROR> File "", line 1007, in _find_and_load INTERNALERROR> File "", line 986, in _find_and_load_unlocked INTERNALERROR> File "", line 680, in _load_unlocked INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/_pytest/assertion/rewrite.py", line 186, in exec_module INTERNALERROR> exec(co, module.dict) INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/src/haven/tests/test_run_browser.py", line 25, in INTERNALERROR> pytest.skip(reason=httpx_reason, allow_module_level=True) INTERNALERROR> File "/home/beams0/JUANJUAN.HUANG/mambaforge/envs/haven/lib/python3.9/site-packages/_pytest/outcomes.py", line 179, in skip INTERNALERROR> raise Skipped(msg=reason, allow_module_level=allow_module_level) INTERNALERROR> Skipped: v0.1.0a106 of tiled client broke the run_browsergiving an httpx.PoolTimeout exception. Happens when calling ``run['primary']['data'] on in run_browser.py ln 294 =============================================================================== 1 warning in 0.33s ===============================================================================

Yesterday when I tried to run an individual test in the haven/tests folder, e.g., python test_main_window.py, one error said that pcdsdevices was not installed, though it was in your environment.yml. So I did mamba install -c conda-forge pcdsdevices. I believe this is the only thing I changed in my haven environment.

canismarko commented 10 months ago

Hmmm...okay. I think there are several problems with the test, but I have too many branches going right now to know. I'll merge all of them together and then get the tests working again. Hopefully that can get us back to a place where things work.

canismarko commented 10 months ago

@Cathyhjj I think I fixed the tests. The CI still fails, so I'll work on that, but try running the tests yourself now. I moved them from ./tests to ./src/firefly/tests and ./src/haven/tests.

canismarko commented 9 months ago

@Cathyhjj Follow up to our talk yesterday about opening displays in Firefly. I added a method to the FireflyApplication that make it easy to add new plan displays. Just add a line to the list in that function, and the menu will be created automatically.

NB: it assume the .ui and .py files are in src/firefly/plans/. There's already a count.py file in that folder, but you can overwrite it.

Hopefully that makes your development easier. Let me know if it's unclear.