Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for fb epid database in optics #848

Merged
merged 13 commits into from
May 17, 2023
Merged

add support for fb epid database in optics #848

merged 13 commits into from
May 17, 2023

Conversation

prjemian
Copy link
Contributor

@prjemian prjemian added this to the 1.6.16 milestone Apr 17, 2023
@prjemian prjemian self-assigned this Apr 17, 2023
@prjemian
Copy link
Contributor Author

needs tests

@prjemian
Copy link
Contributor Author

CI failed on unrelated test (but recent addition):

=========================== short test summary info ============================
FAILED apstools/synApps/tests/test_2slit.py::test_geometry_property[Optics2Slit2D_HV-gp:Slit1] - AssertionError: assert SlitGeometry(width=0.3, height=0.1, x=0.5, y=-0.399) == SlitGeometry(width=0.3, height=0.1, x=0.5, y=-0.4)
  
  Matching attributes:
  ['width', 'height', 'x']
  Differing attributes:
  ['y']
  
  Drill down into differing attribute y:
    y: -0.399 != -0.4
  Full diff:
  - SlitGeometry(width=0.3, height=0.1, x=0.5, y=-0.4)
  ?                                                 ^
  + SlitGeometry(width=0.3, height=0.1, x=0.5, y=-0.399)
  ?                                                 ^^^
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
======= 1 failed, 348 passed, 3 skipped, 8 warnings in 318.25s (0:05:18) =======
Error: Process completed with exit code 1.

It's a sig figs situation. Uses math.isclose()?

@prjemian
Copy link
Contributor Author

Locally, a different test failure:

(bluesky_2023_2) prjemian@zap:~/.../BCDA-APS/apstools$ pytest -vvv --lf apstools/synApps/tests/test_2slit.py
================================================================ test session starts =================================================================
platform linux -- Python 3.10.4, pytest-7.3.1, pluggy-1.0.0 -- /home/prjemian/.conda/envs/bluesky_2023_2/bin/python3.10
cachedir: .pytest_cache
rootdir: /home/prjemian/Documents/projects/BCDA-APS/apstools
configfile: pytest.ini
plugins: notebook-0.6.1, anyio-3.6.2
collected 17 items                                                                                                                                   
run-last-failure: 13 known failures not in selected tests

apstools/synApps/tests/test_2slit.py::test_attribute_quantities[Optics2Slit1D-gp:Slit1H-False-read_attrs-12] PASSED                            [  5%]
apstools/synApps/tests/test_2slit.py::test_attribute_quantities[Optics2Slit1D-gp:Slit1H-False-configuration_attrs-16] PASSED                   [ 11%]
apstools/synApps/tests/test_2slit.py::test_attribute_quantities[Optics2Slit1D-gp:Slit1H-True-read()-8] PASSED                                  [ 17%]
apstools/synApps/tests/test_2slit.py::test_attribute_quantities[Optics2Slit1D-gp:Slit1H-True-summary()-63] PASSED                              [ 23%]
apstools/synApps/tests/test_2slit.py::test_attribute_quantities[Optics2Slit2D_HV-gp:Slit1-False-read_attrs-26] PASSED                          [ 29%]
apstools/synApps/tests/test_2slit.py::test_attribute_quantities[Optics2Slit2D_HV-gp:Slit1-False-configuration_attrs-34] PASSED                 [ 35%]
apstools/synApps/tests/test_2slit.py::test_attribute_quantities[Optics2Slit2D_HV-gp:Slit1-True-read()-16] PASSED                               [ 41%]
apstools/synApps/tests/test_2slit.py::test_attribute_quantities[Optics2Slit2D_HV-gp:Slit1-True-summary()-114] PASSED                           [ 47%]
apstools/synApps/tests/test_2slit.py::test_attribute_quantities[Optics2Slit2D_InbOutBotTop-gp:Slit1-False-read_attrs-24] PASSED                [ 52%]
apstools/synApps/tests/test_2slit.py::test_attribute_quantities[Optics2Slit2D_InbOutBotTop-gp:Slit1-False-configuration_attrs-32] PASSED       [ 58%]
apstools/synApps/tests/test_2slit.py::test_attribute_quantities[Optics2Slit2D_InbOutBotTop-gp:Slit1-True-read()-16] PASSED                     [ 64%]
apstools/synApps/tests/test_2slit.py::test_attribute_quantities[Optics2Slit2D_InbOutBotTop-gp:Slit1-True-summary()-112] PASSED                 [ 70%]
apstools/synApps/tests/test_2slit.py::test_2slit1D PASSED                                                                                      [ 76%]
apstools/synApps/tests/test_2slit.py::test_2slit2D_HV PASSED                                                                                   [ 82%]
apstools/synApps/tests/test_2slit.py::test_2slit2D_InbOutBotTop PASSED                                                                         [ 88%]
apstools/synApps/tests/test_2slit.py::test_geometry_property[Optics2Slit2D_HV-gp:Slit1] PASSED                                                 [ 94%]
apstools/synApps/tests/test_2slit.py::test_geometry_property[Optics2Slit2D_InbOutBotTop-gp:Slit1] PASSED                                       [100%]

================================================================= 17 passed in 7.56s =================================================================
Subscription value callback exception (EpicsSignal(read_pv='gp:Slit1Hsize', name='obj_size_setpoint', parent='obj_size', value=0.30000000000000004, timestamp=1684260304.479151, tolerance=0.001, auto_monitor=False, string=False, write_pv='gp:Slit1Hsize', limits=False, put_complete=True))
Traceback (most recent call last):
  File "/home/prjemian/.conda/envs/bluesky_2023_2/lib/python3.10/site-packages/ophyd/ophydobj.py", line 492, in inner
    cb(*args, **kwargs)
  File "/home/prjemian/Documents/projects/BCDA-APS/apstools/apstools/devices/positioner_soft_done.py", line 191, in cb_setpoint
    logger.debug("cb_setpoint: done=%s, setpoint=%s", self.done.get(), self.setpoint.get())
  File "/home/prjemian/.conda/envs/bluesky_2023_2/lib/python3.10/site-packages/ophyd/signal.py", line 1379, in get
    info = self._get_with_timeout(
  File "/home/prjemian/.conda/envs/bluesky_2023_2/lib/python3.10/site-packages/ophyd/signal.py", line 1319, in _get_with_timeout
    info = pv.get_with_metadata(
  File "/home/prjemian/.conda/envs/bluesky_2023_2/lib/python3.10/site-packages/epics/pv.py", line 47, in wrapped
    return func(self, *args, **kwargs)
  File "/home/prjemian/.conda/envs/bluesky_2023_2/lib/python3.10/site-packages/epics/pv.py", line 563, in get_with_metadata
    md = ca.get_with_metadata(
  File "/home/prjemian/.conda/envs/bluesky_2023_2/lib/python3.10/site-packages/epics/ca.py", line 635, in wrapper
    return fcn(*args, **kwds)
  File "/home/prjemian/.conda/envs/bluesky_2023_2/lib/python3.10/site-packages/epics/ca.py", line 1390, in get_with_metadata
    return get_complete_with_metadata(chid, count=count, ftype=ftype,
  File "/home/prjemian/.conda/envs/bluesky_2023_2/lib/python3.10/site-packages/epics/ca.py", line 635, in wrapper
    return fcn(*args, **kwds)
  File "/home/prjemian/.conda/envs/bluesky_2023_2/lib/python3.10/site-packages/epics/ca.py", line 1537, in get_complete_with_metadata
    val = _unpack(chid, full_value, count=count,
  File "/home/prjemian/.conda/envs/bluesky_2023_2/lib/python3.10/site-packages/epics/ca.py", line 1273, in _unpack
    elem_count = element_count(chid)
  File "/home/prjemian/.conda/envs/bluesky_2023_2/lib/python3.10/site-packages/epics/ca.py", line 576, in wrapper
    raise ChannelAccessException('Unexpected channel ID')
epics.ca.ChannelAccessException: Unexpected channel ID

@prjemian
Copy link
Contributor Author

Seems this code is not avoiding the problem at exit.

@prjemian
Copy link
Contributor Author

Add atexit handler, similar to ophyd.

@prjemian
Copy link
Contributor Author

With 9769084, the local builds finish without epics.ca.ChannelAccessException.

@prjemian
Copy link
Contributor Author

Different failure just now. Probably a transient. Documenting here just in case:

apstools/callbacks/tests/test_nxwriter.py::test_NXWriter_with_RunEngine FAILED [  5%]

=================================== FAILURES ===================================
_________________________ test_NXWriter_with_RunEngine _________________________

camera = MyDetector(prefix='ad:', name='camera', read_attrs=['cam', 'hdf1'], configuration_attrs=['cam', 'cam.acquire_period', ... 'cam.image_mode', 'cam.manufacturer', 'cam.model', 'cam.num_exposures', 'cam.num_images', 'cam.trigger_mode', 'hdf1'])
motor = EpicsMotor(prefix='gp:m1', name='motor', settle_time=0.0, timeout=None, read_attrs=['user_readback', 'user_setpoint'], configuration_attrs=['user_offset', 'user_offset_dir', 'velocity', 'acceleration', 'motor_egu'])

    def test_NXWriter_with_RunEngine(camera, motor):
        test_file = pathlib.Path(tempfile.mkdtemp()) / "nxwriter.h5"
        catalog = databroker.temp().v2
    
        nxwriter = NXWriter()
        nxwriter.file_name = str(test_file)
        assert isinstance(nxwriter.file_name, pathlib.Path)
        nxwriter.warn_on_missing_content = False
    
        RE = RunEngine()
        RE.subscribe(catalog.v1.insert)
        RE.subscribe(nxwriter.receiver)
    
        npoints = 3
        uids = RE(bp.scan([camera], motor, -0.1, 0, npoints))
        assert isinstance(uids, (list, tuple))
        assert len(uids) == 1
        assert uids[-1] in catalog
    
        nxwriter.wait_writer()
        # time.sleep(1)  # wait just a bit longer
    
        assert test_file.exists()
        with h5py.File(test_file, "r") as root:
            default = root.attrs.get("default", "entry")
            assert default == "entry"
            assert default in root
            nxentry = root[default]
    
            default = nxentry.attrs.get("default", "data")
            assert default == "data"
            assert default in nxentry, f"{test_file=} {list(nxentry)=}"
            nxdata = nxentry[default]
    
            signal = nxdata.attrs.get("signal", "data")
            # assert signal == camera.name
>           assert signal in nxdata
E           assert 'data' in <HDF5 group "/entry/data" (0 members)>

/home/runner/work/apstools/apstools/apstools/callbacks/tests/test_nxwriter.py:1[56](https://github.com/BCDA-APS/apstools/actions/runs/4996050845/jobs/8948746959#step:15:57): AssertionError
------------------------------ Captured log call -------------------------------

@prjemian
Copy link
Contributor Author

Still needs unit tests for epid.py.

@prjemian
Copy link
Contributor Author

start the GUI: caQtDM -macro "P=gp:epid1" fb_epid_sim.ui &

@prjemian prjemian marked this pull request as ready for review May 16, 2023 23:26
@prjemian prjemian merged commit c3d0f94 into main May 17, 2023
@prjemian prjemian deleted the 847-fb_epid branch May 17, 2023 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for optics fb_epid database
1 participant