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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
d4eb5cd
Add dependencies and update pre-commit config
mrakitin Feb 13, 2024
517213c
Create base classes and utility functions
mrakitin Feb 13, 2024
bd46a1a
CI: run ci workflow on all pushes
mrakitin Feb 13, 2024
f393c63
CI: Exclude pypy tests
mrakitin Feb 13, 2024
cc80d49
TST: add ophyd-based test for Zebra Caproto IOC
mrakitin Feb 13, 2024
e320f28
Working ophyd tests
mrakitin Feb 13, 2024
a61223f
More fixes for the tests
mrakitin Feb 13, 2024
ca99a7e
TST: add a caproto IOC fixture to be able to start and test against i…
mrakitin Feb 14, 2024
d2d25e2
CI: disable Win/OSX builds; more python versions to test with; pin se…
mrakitin Feb 14, 2024
e151089
TST: add broadcast address a smarter way
mrakitin Feb 14, 2024
7a9944a
CI: Do not run tests twice on a PR from the same repo's branch
mrakitin Feb 14, 2024
d7ec78c
TST: print caproto stdout and stderr
mrakitin Feb 14, 2024
09a08ca
Use base IOC/ophyd in CI tests
mrakitin Feb 14, 2024
eb36115
Add saving capabilities to the base IOC
mrakitin Feb 14, 2024
d29d442
Fixed saving capabilities
mrakitin Feb 14, 2024
42f073b
Make it work on MacOS
mrakitin Feb 15, 2024
d78df6f
Make it work with `act`
mrakitin Feb 15, 2024
f18d187
Working saving example of multiple frames with ophyd
mrakitin Feb 15, 2024
fbf17aa
Add `scikit-image` to the dependencies
mrakitin Feb 15, 2024
384c001
Add missing skimage dependency to pull the dataset
mrakitin Feb 15, 2024
7dbbaca
PKG: apply setuptools limitation better
mrakitin Feb 15, 2024
8248509
CI: configure PyPI uploading
mrakitin Feb 15, 2024
69d4306
Add convenience script to run `act` locally
mrakitin Feb 15, 2024
15bb697
add `suid` to filename formatter
hyperrealist Feb 16, 2024
a4e70d4
fix bug where `uid` not generated if only `suid` is used in `file_name`
hyperrealist Feb 16, 2024
1d3aae3
fix typo, make more readable
hyperrealist Feb 17, 2024
f63e243
Merge pull request #3 from hyperrealist/add-zebra-ioc
mrakitin Feb 17, 2024
618cbb3
CNL: remove irrelevant comment and add a docstring to the `_get_curre…
mrakitin Feb 18, 2024
1ac8b6f
TST: add input arg for a number of frames to the testing script
mrakitin Feb 18, 2024
34e291c
Make multiple files saving working correctly
mrakitin Feb 18, 2024
a179b09
Update the script for manual testing to report the resulting `:full_f…
mrakitin Feb 18, 2024
66df054
Update caproto startup and testing scripts
mrakitin Feb 18, 2024
08bcbf2
PKG: install dependencies if skimage via extra
mrakitin Feb 18, 2024
1c6d5be
CI: upload testing results as artifacts
mrakitin Feb 18, 2024
5be9909
CI: fix uploading of artifacts
mrakitin Feb 18, 2024
41fca53
CI: update artifact names
mrakitin Feb 18, 2024
e75be6c
add test parameters to test hidden spaces in write dir
hyperrealist Feb 21, 2024
a33c735
fix lint errors from `e75be6c`
hyperrealist Feb 21, 2024
9724d19
WIP: test with string IOC
mrakitin Feb 21, 2024
dc98043
STY: fix linting errors
mrakitin Feb 22, 2024
cfe47e2
Parametrize the script to start different caproto IOCs
mrakitin Feb 22, 2024
9f1f5c6
TST: `cainfo` and `caput` tests for string caproto IOC
mrakitin Feb 22, 2024
2d05e76
TST: fix the blocking issue in the tests
mrakitin Feb 22, 2024
9c9f539
CI: install `epics-base` package from conda-forge (for `caget`, `capu…
mrakitin Feb 22, 2024
590e554
Minor tweaks and addressing review comments from PR#2
mrakitin Feb 22, 2024
ab77f7f
CI: use micromamba for the python env
mrakitin Feb 22, 2024
def5ded
Change `write_dir` and `file_name` PV types to CHAR and fix the relev…
mrakitin Feb 22, 2024
ccca4d3
Minor improvements
mrakitin Feb 22, 2024
7d0e104
sanitize file path better
hyperrealist Feb 23, 2024
571539e
update `test_base_ophyd.py` to use the correct path sanitizer
hyperrealist Feb 23, 2024
9abfa20
Merge pull request #4 from NSLS-II-SRX/more-caproto-ioc-flavors
hyperrealist Feb 23, 2024
af0f986
Dev updates for the Zebra IOC
mrakitin May 14, 2024
0afd370
WIP: can save `enc1` 1-D data
mrakitin May 14, 2024
6524861
Vendor acquire/saver methods from the base IOC in the Zebra one
mrakitin May 16, 2024
adb96a3
Prototyped IOC to accept the a dict of arrays to save - the ophyd/blu…
mrakitin May 17, 2024
d7ea796
Add support for SIS scaler exporting
mrakitin May 17, 2024
afdb488
Fix enum default value for the dev_type
mrakitin May 17, 2024
246d885
Clean up irrelevant code
mrakitin May 17, 2024
9dc73ff
Merge pull request #11 from NSLS-II-SRX/add-zebra-ioc-dev
mrakitin May 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,4 @@ jobs:
- uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name == 'release' && github.event.action == 'published'
with:
# Remember to tell (test-)pypi about this repo before publishing
# Remove this line to publish to PyPI
repository-url: https://test.pypi.org/legacy/
packages-dir: ./dist/
64 changes: 52 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
workflow_dispatch:
pull_request:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -34,36 +32,78 @@ jobs:
pipx run nox -s pylint

checks:
# pull requests are a duplicate of a branch push if within the same repo.
if:
github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name != github.repository

name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
runs-on: ${{ matrix.runs-on }}
needs: [pre-commit]
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.12"]
runs-on: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
# runs-on: [ubuntu-latest, macos-latest, windows-latest]
runs-on: [ubuntu-latest]

# include:
# - python-version: pypy-3.10
# runs-on: ubuntu-latest
env:
TZ: America/New_York

include:
- python-version: pypy-3.10
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
- name: Set env vars
run: |
set -x
export REPOSITORY_NAME=${GITHUB_REPOSITORY#*/} # just the repo, as opposed to org/repo
echo "REPOSITORY_NAME=${REPOSITORY_NAME}" >> $GITHUB_ENV

export PYTHONVER=$(echo ${{ matrix.python-version }} | sed 's/\.//g')
echo "PYTHONVER=${PYTHONVER}" >> $GITHUB_ENV

export DATETIME_STRING=$(date +%Y%m%d%H%M%S)
echo "DATETIME_STRING=${DATETIME_STRING}" >> $GITHUB_ENV

# - uses: actions/setup-python@v5
# with:
# python-version: ${{ matrix.python-version }}
# allow-prereleases: true

- name: Set up Python ${{ matrix.python-version }} with conda
uses: mamba-org/setup-micromamba@v1
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
init-shell: bash
environment-name: ${{env.REPOSITORY_NAME}}-py${{matrix.python-version}}
create-args: >-
python=${{ matrix.python-version }} epics-base setuptools<67

- name: Install package
run: python -m pip install .[test]
run: |
set -vxeuo pipefail
which caput
python -m pip install .[test]

- name: Test package
run: >-
python -m pytest -ra --cov --cov-report=xml --cov-report=term
--durations=20
--durations=20 -m "(not hardware) and (not tiled)" -s -vv

- name: Upload test artifacts
uses: actions/upload-artifact@v4
with:
name: ${{env.REPOSITORY_NAME}}-py${{env.PYTHONVER}}-${{env.DATETIME_STRING}}
path: /tmp/srx-caproto-iocs/
retention-days: 14

- name: Upload coverage report
uses: codecov/[email protected]
22 changes: 11 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,27 @@ repos:
- id: rst-inline-touching-normal

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.1.0"
rev: "v4.0.0-alpha.8"
hooks:
- id: prettier
types_or: [yaml, markdown, html, css, scss, javascript, json]
args: [--prose-wrap=always]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.14"
rev: "v0.2.1"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.8.0"
hooks:
- id: mypy
files: src|tests
args: []
additional_dependencies:
- pytest
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: "v1.8.0"
# hooks:
# - id: mypy
# files: src|tests
# args: []
# additional_dependencies:
# - pytest

- repo: https://github.com/codespell-project/codespell
rev: "v2.2.6"
Expand All @@ -80,7 +80,7 @@ repos:
additional_dependencies: ["validate-pyproject-schema-store[all]"]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: "0.27.3"
rev: "0.28.0"
hooks:
- id: check-dependabot
- id: check-github-workflows
Expand Down
28 changes: 22 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["hatchling", "hatch-vcs"]
requires = ["hatchling", "hatch-vcs", "setuptools>=61,<67"]
build-backend = "hatchling.build"


Expand Down Expand Up @@ -30,14 +30,25 @@ classifiers = [
"Typing :: Typed",
]
dynamic = ["version"]
dependencies = []
dependencies = [
"caproto",
"h5py",
"numpy",
"ophyd",
"pyepics", # does not work with 'setuptools' version higher than v66.1.1
"scikit-image[data]",
]

[project.optional-dependencies]
test = [
"pytest >=6",
"pytest-cov >=3",
]
dev = [
"ipython",
"nexpy",
"pre-commit",
"pylint",
"pytest >=6",
"pytest-cov >=3",
]
Expand Down Expand Up @@ -76,7 +87,12 @@ log_cli_level = "INFO"
testpaths = [
"tests",
]

markers = [
"hardware: marks tests as requiring the hardware IOC to be available/running (deselect with '-m \"not hardware\"')",
"tiled: marks tests as requiring tiled",
"cloud_friendly: marks tests to be able to execute in the CI in the cloud",
"needs_epics_core: marks tests as requiring epics-core executables such as caget, caput, etc."
]

[tool.coverage]
run.source = ["srx_caproto_iocs"]
Expand Down Expand Up @@ -108,7 +124,7 @@ src = ["src"]
extend-select = [
"B", # flake8-bugbear
"I", # isort
"ARG", # flake8-unused-arguments
# "ARG", # flake8-unused-arguments
"C4", # flake8-comprehensions
"EM", # flake8-errmsg
"ICN", # flake8-import-conventions
Expand All @@ -119,9 +135,9 @@ extend-select = [
"PT", # flake8-pytest-style
"PTH", # flake8-use-pathlib
"RET", # flake8-return
"RUF", # Ruff-specific
# "RUF", # Ruff-specific
"SIM", # flake8-simplify
"T20", # flake8-print
# "T20", # flake8-print
"UP", # pyupgrade
"YTT", # flake8-2020
"EXE", # flake8-executable
Expand Down
7 changes: 7 additions & 0 deletions scripts/run-act.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -vxeuo pipefail

PYTHON_VERSION="${1:-3.11}"

act -W .github/workflows/ci.yml -j checks --matrix python-version:"${PYTHON_VERSION}"
16 changes: 16 additions & 0 deletions scripts/run-caproto-ioc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -vxeuo pipefail

CAPROTO_IOC="${1:-srx_caproto_iocs.base}"
DEFAULT_PREFIX="BASE:{{Dev:Save1}}:"
CAPROTO_IOC_PREFIX="${2:-${DEFAULT_PREFIX}}"
# shellcheck source=/dev/null
if [ -f "/etc/profile.d/epics.sh" ]; then
. /etc/profile.d/epics.sh
fi

export EPICS_CAS_AUTO_BEACON_ADDR_LIST="no"
export EPICS_CAS_BEACON_ADDR_LIST="${EPICS_CA_ADDR_LIST:-127.0.0.255}"

python -m "${CAPROTO_IOC}" --prefix="${CAPROTO_IOC_PREFIX}" --list-pvs
7 changes: 7 additions & 0 deletions scripts/run-caproto-zebra-ioc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -vxeuo pipefail

SCRIPT_DIR="$(dirname "$0")"

bash "${SCRIPT_DIR}/run-caproto-ioc.sh" srx_caproto_iocs.zebra.caproto_ioc "XF:05IDD-ES:1{{Dev:Zebra2}}:"
29 changes: 29 additions & 0 deletions scripts/test-file-saving.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

set -euo pipefail

# shellcheck source=/dev/null
if [ -f "/etc/profile.d/epics.sh" ]; then
. /etc/profile.d/epics.sh
fi

num="${1:-50}"

data_dir="/tmp/test/$(date +%Y/%m/%d)"
mkdir -v -p "${data_dir}"

caput "BASE:{Dev:Save1}:write_dir" "${data_dir}"
caput "BASE:{Dev:Save1}:file_name" "saveme_{num:06d}_{uid}.h5"
caput "BASE:{Dev:Save1}:stage" 1
caget -S "BASE:{Dev:Save1}:full_file_path"
for i in $(seq "$num"); do
echo "$i"
sleep 0.1
caput "BASE:{Dev:Save1}:acquire" 1
done

caput "BASE:{Dev:Save1}:stage" 0

caget -S "BASE:{Dev:Save1}:full_file_path"

exit 0
Loading
Loading