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 caproto Zebra IOC #2

Merged
merged 59 commits into from
May 17, 2024
Merged

Add caproto Zebra IOC #2

merged 59 commits into from
May 17, 2024

Conversation

mrakitin
Copy link
Member

@mrakitin mrakitin commented Feb 14, 2024

WIP with @hyperrealist

…tuptools to an older version; more verbose test output
act -W .github/workflows/ci.yml -j checks --matrix python-version:3.11

NOTE: Python 3.12 build fails on a datetime/TZ issue.

| OpenBLAS WARNING - could not determine the L2 cache size on this system, assuming 256k
| ImportError while loading conftest '/Users/mrakitin/src/NSLS-II/SRX/srx-caproto-iocs/tests/conftest.py'.
| tests/conftest.py:13: in <module>
|     from srx_caproto_iocs.base import OphydDeviceWithCaprotoIOC
| /opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/site-packages/srx_caproto_iocs/base.py:11: in <module>
|     from caproto import ChannelType
| /opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/site-packages/caproto/__init__.py:2: in <module>
|     from ._utils import *
| /opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/site-packages/caproto/_utils.py:29: in <module>
|     from ._dbr import SubscriptionType
| /opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/site-packages/caproto/_dbr.py:17: in <module>
|     from ._constants import (EPICS2UNIX_EPOCH, EPICS_EPOCH, MAX_ENUM_STATES,
| /opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/site-packages/caproto/_constants.py:11: in <module>
|     EPICS_EPOCH = datetime.datetime.utcfromtimestamp(EPICS2UNIX_EPOCH)
| E   DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
@mrakitin
Copy link
Member Author

I've opened caproto/caproto#838 to report the issue we are observing with Python 3.12.

Copy link
Contributor

@hyperrealist hyperrealist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good.
I have some general suggestions in the comments.

Also, it seems we have from __future__ import annotations at the beginning of every file, but we are not using type hints much, if not at all.

@@ -57,13 +63,34 @@ jobs:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Set env vars
run: |

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a set -x here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would not hurt. I copied this piece from other workflows where we don't use set for the step, but it's OK to add.


data_dir="/tmp/test/$(date +%Y/%m/%d)"

if [ ! -d "${data_dir}" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if block is probably not needed since you are using mkdir -p

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it can be eliminated.

frame_num = dataset.shape[0]

# https://docs.h5py.org/en/stable/swmr.html
h5file_desc.swmr_mode = True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty cool feature, didn't know it existed! If it may help someone I'd add a comment here to mention that older HDF5 libraries do not support reading those files

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, please add the comment.

import shutil
import time as ttime
import uuid
from pathlib import Path
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import is not being used for testing anything

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used in the test_base_ophyd_templates test a number of times.

date = now(as_object=True)
write_dir_root = Path(tmpdirname)
dir_template = f"{write_dir_root}/{date_template}"
write_dir = Path(date.strftime(dir_template))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if we need to "manually" strftime here. Shouldn't that happen when we stage base_ophyd_device?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's to make the directory structure on the next line. What we pass to the ophyd object and then to the caproto IOC is dir_template.

@mrakitin
Copy link
Member Author

Also, it seems we have from __future__ import annotations at the beginning of every file, but we are not using type hints much, if not at all.

That import is automatically added by pre-commit. I didn't want to fight with it, so just left it as is.

@mrakitin mrakitin requested a review from hyperrealist May 3, 2024 15:03
@mrakitin
Copy link
Member Author

We are going to merge it to test at SRX.

@mrakitin mrakitin marked this pull request as ready for review May 17, 2024 19:19
@mrakitin mrakitin merged commit d5ed90d into main May 17, 2024
1 of 3 checks passed
@mrakitin mrakitin deleted the add-zebra-ioc branch May 17, 2024 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants