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

Merge dev into main #29

Merged
merged 79 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
337812b
Ensure all INP links are valid
AlexanderWells-diamond Mar 30, 2023
1e25c54
Make the LABELS record the same order as PandA sent
AlexanderWells-diamond Mar 30, 2023
cb19511
Publish enums as lists of strings, not ints
AlexanderWells-diamond Mar 31, 2023
085453c
Add metadata to PVAccess for last column in table
AlexanderWells-diamond Mar 31, 2023
0772b53
Add test for PVAccess
AlexanderWells-diamond Apr 4, 2023
db80d54
Set record alarm when PandA disconnects
AlexanderWells-diamond Apr 6, 2023
e38323f
Remove records that we no longer want to publisise
AlexanderWells-diamond Apr 6, 2023
b342348
Add misc comments
AlexanderWells-diamond Apr 6, 2023
966274f
remove bobfile server
tizayi Apr 4, 2023
4606e56
Refactor how bob file screen dir is specified
AlexanderWells-diamond Apr 6, 2023
b4031fc
Fix bobfile tests by regenerating all the files
AlexanderWells-diamond Apr 12, 2023
d3a4f19
Ignore numpy runtime mismatch error
AlexanderWells-diamond Apr 12, 2023
3deab0e
Add extra ignore for Python3.9+
AlexanderWells-diamond Apr 13, 2023
c7499b9
Check we create expected number of files
AlexanderWells-diamond Apr 13, 2023
a8586b9
Update src/pandablocks_ioc/_tables.py
coretl May 22, 2023
ec9cc23
Changed test to use lower case names consistent with PVA
evalott100 Jul 19, 2023
61ff502
Merge pull request #22 from evalott100/fix_failing_unit_test
evalott100 Aug 10, 2023
35dd00d
Changed create_softioc to take a client instead of a hostname, change…
evalott100 Jul 20, 2023
d14baff
Improved functionality of the mocked panda
evalott100 Jul 27, 2023
4b3ebef
Changed tests to fix the new structure
evalott100 Aug 3, 2023
e1c4c2d
made flake8 compatible
evalott100 Aug 3, 2023
1550517
Changing test back a little to see if I can find the issue with one test
evalott100 Aug 3, 2023
0da76d9
fixed a unit test
evalott100 Aug 3, 2023
045c2e5
Fixed linting
evalott100 Aug 4, 2023
b851fc7
Still can't get this test working, going to switch branches to see th…
evalott100 Aug 4, 2023
b370cf3
Using a mocked Asyncio Client for the hdf5 tests
evalott100 Aug 4, 2023
f055f82
Corrected some parts mentioned in the PR
evalott100 Aug 7, 2023
10f70ca
Corrected assorted problems mentioned in the PR
evalott100 Aug 9, 2023
70d15c6
Corrected the time update tests drvl, added sleep statements to tests…
evalott100 Aug 9, 2023
51bab11
Pinned pvi requirement to allow for bobfile consistency between 3.9 a…
evalott100 Aug 10, 2023
a9139d8
added a BaseEventLoop to the mocked_time_record_updater since it will…
evalott100 Aug 10, 2023
f8fa658
Pinned setuptools version and added as a requirement (as well as an i…
evalott100 Aug 10, 2023
9c88dae
Changed tests which use the command_queue
evalott100 Aug 16, 2023
e289cb3
Added a wait on test_bobfiles_created
evalott100 Aug 16, 2023
e292130
Merge pull request #23 from evalott100/adjust_testing_environment
evalott100 Aug 16, 2023
7ded051
Doesn't work on python 3.11, put container back to 3.10
coretl May 16, 2023
88e6a1a
Slim down and correct dev container
coretl May 16, 2023
d2434e2
Correct PVI entries
coretl May 16, 2023
3cf9b62
Fix table support, needs tables branch of pvi
coretl May 16, 2023
acd05a4
Hack PV names to look like the web UI ones
coretl May 16, 2023
8e9488f
Add support for long PV prefix
coretl Jul 12, 2023
ea711d2
Update to use pvi 0.5
GDYendell Aug 9, 2023
4227263
changed pvi dependency to pvi[cli]
evalott100 Aug 11, 2023
4727024
adjusted unit tests to fit the new naming scheme
evalott100 Aug 14, 2023
0c8696c
Changed the pyproject.toml to python 3.10/3.11
evalott100 Aug 15, 2023
515c709
Changed tests which use the command_queue
evalott100 Aug 16, 2023
1bd195e
Added a wait on test_bobfiles_created
evalott100 Aug 16, 2023
b921eb1
Fixed incorrect changes from cherry-pick
evalott100 Aug 16, 2023
2739570
Fixed merge error on TOB.bob
evalott100 Aug 16, 2023
eb0ea2a
Removed
evalott100 Aug 16, 2023
d9cd993
Allowed for the subprocess softioc to be included in coverage
evalott100 Aug 23, 2023
f20a05b
Added a check that there isn't a number in the block name
evalott100 Aug 23, 2023
a3861ce
Made metadata label split into multiple PVs and added tests for it, g…
evalott100 Aug 24, 2023
c13d7aa
Got the *METADATA.LABELS conversion working
evalott100 Aug 31, 2023
20bac0b
Various fixes from the PR
evalott100 Sep 1, 2023
82130ab
Added necessary PVI information for PCAP:ARM
evalott100 Sep 1, 2023
2f4bbe4
Added necessary PVI information for PCAP:ARM
evalott100 Sep 1, 2023
1f8caba
Merge pull request #26 from evalott100/make_pv_names_consistent_with_…
evalott100 Sep 1, 2023
979a104
Fixed incorrect .bob
evalott100 Sep 1, 2023
5874fd3
added pvi fields using `add_pvi_info`
evalott100 Sep 1, 2023
72236b0
Fixed error in metadata parsing
evalott100 Sep 4, 2023
28584d2
Merge branch 'dev' into add_pcap_arm_pvi_entry
evalott100 Sep 4, 2023
6f54f77
Fixed merge problem
evalott100 Sep 4, 2023
102e1aa
Added necessary PVI information for PCAP:ARM
evalott100 Sep 1, 2023
35446c8
Fixed incorrect .bob
evalott100 Sep 1, 2023
cffb958
Fixed error in metadata parsing
evalott100 Sep 4, 2023
6e952e7
Various fixes from the PR
evalott100 Sep 1, 2023
b1fd12c
Fixed merge problem
evalott100 Sep 4, 2023
44df38c
Merge branch 'dev' into pvi_entries_for_hdf_writing
evalott100 Sep 4, 2023
8e86b45
Minor fixes and enabled a fail on trying to overwrite bobfiles if --o…
evalott100 Sep 4, 2023
71a6fbb
Minor fixes and enabled a fail on trying to overwrite bobfiles if --o…
evalott100 Sep 4, 2023
846bad5
Removed uneccesary TODO
evalott100 Sep 4, 2023
defc6f6
Merge pull request #30 from evalott100/add_pcap_arm_pvi_entry
evalott100 Sep 4, 2023
4606954
Merge branch 'dev' into pvi_entries_for_hdf_writing
evalott100 Sep 4, 2023
ad1809a
Merge pull request #31 from evalott100/pvi_entries_for_hdf_writing
evalott100 Sep 4, 2023
14b6e0c
Added a check that the screens directory doesn't contain any files al…
evalott100 Sep 5, 2023
3c75063
Removed filter warnings and flake8 issues
evalott100 Sep 5, 2023
4b34925
Cleaned a regex expression for extracting metadata labels
evalott100 Sep 5, 2023
9fb2d97
Changed the FileExistsError to not specify files
evalott100 Sep 5, 2023
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
15 changes: 4 additions & 11 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,12 @@
"remoteEnv": {
"DISPLAY": "${localEnv:DISPLAY}"
},
// Add the URLs of features you want added when the container is built.
"features": {
"ghcr.io/devcontainers/features/common-utils:1": {
"username": "none",
"upgradePackages": false
}
},
// Set *default* container specific settings.json values on container create.
"settings": {
"python.defaultInterpreterPath": "/venv/bin/python"
},
"customizations": {
"vscode": {
"settings": {
"python.defaultInterpreterPath": "/venv/bin/python"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
Expand All @@ -51,4 +44,4 @@
"workspaceFolder": "${localWorkspaceFolder}",
// After the container is created, install the python project in editable form
"postCreateCommand": "pip install -e '.[dev]'"
}
}
4 changes: 2 additions & 2 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest"] # can add windows-latest, macos-latest
python: ["3.9", "3.10", "3.11"]
python: ["3.10", "3.11"]
install: ["-e .[dev]"]
# Make one version be non-editable to test both paths of version code
include:
- os: "ubuntu-latest"
python: "3.8"
python: "3.10"
install: ".[dev]"

runs-on: ${{ matrix.os }}
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,3 @@ venv*

# further build artifacts
lockfiles/

3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"args": [
"softioc",
"172.23.252.201",
"SOME-PREFIX"
"SOME-PREFIX",
"./screens"
],
"console": "integratedTerminal",
"justMyCode": false
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# The devcontainer should use the build target and run as root with podman
# or docker with user namespaces.
#
FROM python:3.11 as build
FROM python:3.10 as build

ARG PIP_OPTIONS=.

Expand All @@ -24,7 +24,7 @@ WORKDIR /context
# install python package into /venv
RUN pip install ${PIP_OPTIONS}

FROM python:3.11-slim as runtime
FROM python:3.10-slim as runtime

# Add apt-get system dependecies for runtime here if needed

Expand Down
33 changes: 17 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@ name = "PandABlocks-ioc"
classifiers = [
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
description = "One line description of your module"
dependencies = [
"setuptools>=64",
"numpy",
"click",
"h5py",
"softioc>=4.1.0",
"softioc>=4.4.0",
"pandablocks>=0.3.1",
"pvi[cli]>=0.4",
"aiohttp",
"pvi>=0.5",
] # Add project dependencies here, e.g. ["click", "numpy"]
dynamic = ["version"]
license.file = "LICENSE"
Expand All @@ -37,8 +35,9 @@ dev = [
"Flake8-pyproject",
"pipdeptree",
"pre-commit",
"p4p",
"pydata-sphinx-theme>=0.12",
"pytest-asyncio",
"pytest-asyncio>=0.20",
"pytest-cov",
"sphinx-autobuild",
"sphinx-copybutton",
Expand Down Expand Up @@ -88,22 +87,24 @@ addopts = """
--cov=pandablocks_ioc --cov-report term --cov-report xml:cov.xml
"""
# https://iscinumpy.gitlab.io/post/bound-version-constraints/#watch-for-warnings
# The ignores are all related to the test DummyServer, both async and in_thread variants,
# which appear to have issues cleanly shutting down and raise exceptions in their destructors.
# The issue seems like all we need is to add await asyncio.sleep(0) to allow asyncio to
# clean up its connections, but that doesn't seem to behave as expected inside pytest.
# First ignore is due to p4p staticly linking an old numpy version and us installing
# Next is something that needs to be fixed in PandABlocks-client asyncio.py's write_and_drain function
# which triggers a deprecation warning on Python 3.9+. See https://github.com/PandABlocks/PandABlocks-client/issues/47.
# a more recent version with a different C API. See https://github.com/mdavidsaver/p4p/issues/102.
filterwarnings = """
error
ignore:unclosed transport <_SelectorSocketTransport:
ignore:unclosed <socket.socket:
ignore:unclosed event loop <_UnixSelectorEventLoop:
ignore:numpy.ufunc size changed
ignore:The explicit passing of coroutine objects to asyncio.wait()
"""
# ignore::ResourceWarning
# Doctest python code in docs, python code in src docstrings, test functions in tests
testpaths = "docs src tests"
asyncio_mode = "auto"

[tool.coverage.run]
concurrency = ["thread", "multiprocessing"]
data_file = "/tmp/pandablocks_ioc.coverage"
branch = true
omit = ["tests/*"]

[tool.coverage.paths]
# Tests are run from installed location, map back to the src directory
Expand All @@ -120,8 +121,8 @@ skipsdist=True
# Don't create a virtualenv for the command, requires tox-direct plugin
direct = True
passenv = *
allowlist_externals =
pytest
allowlist_externals =
pytest
pre-commit
mypy
sphinx-build
Expand Down
11 changes: 8 additions & 3 deletions src/pandablocks_ioc/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging

import click
from pandablocks.asyncio import AsyncioClient

from pandablocks_ioc.ioc import create_softioc

Expand Down Expand Up @@ -31,11 +32,15 @@ def cli(ctx, log_level: str):
@cli.command()
@click.argument("host")
@click.argument("prefix")
def softioc(host: str, prefix: str):
@click.argument("screens_dir")
def softioc(host: str, prefix: str, screens_dir: str):
"""
Create a soft IOC, using "prefix" for the namespace of the records.
Connect to the given HOST and create an IOC with the given PREFIX.
Create .bob files for screens in the SCREENS_DIR. Directory must exist.
"""
create_softioc(host, prefix)
create_softioc(
client=AsyncioClient(host), record_prefix=prefix, screens_dir=screens_dir
)


# test with: python -m pandablocks_ioc
Expand Down
66 changes: 57 additions & 9 deletions src/pandablocks_ioc/_hdf_ioc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
from softioc import alarm, builder
from softioc.pythonSoftIoc import RecordWrapper

from ._types import ONAM_STR, ZNAM_STR
from ._pvi import PviGroup, add_pvi_info
from ._types import ONAM_STR, ZNAM_STR, EpicsName


class HDF5RecordController:
Expand Down Expand Up @@ -52,51 +53,76 @@ def __init__(self, client: AsyncioClient, record_prefix: str):

# Create the records, including an uppercase alias for each
# Naming convention and settings (mostly) copied from FSCN2 HDF5 records
file_path_record_name = self._HDF5_PREFIX + ":FilePath"
file_path_record_name = EpicsName(self._HDF5_PREFIX + ":FilePath")
self._file_path_record = builder.longStringOut(
file_path_record_name,
length=path_length,
DESC="File path for HDF5 files",
validate=self._parameter_validate,
)
add_pvi_info(
PviGroup.INPUTS,
self._file_path_record,
file_path_record_name,
builder.longStringOut,
)
self._file_path_record.add_alias(
record_prefix + ":" + file_path_record_name.upper()
)

file_name_record_name = self._HDF5_PREFIX + ":FileName"
file_name_record_name = EpicsName(self._HDF5_PREFIX + ":FileName")
self._file_name_record = builder.longStringOut(
file_name_record_name,
length=filename_length,
DESC="File name prefix for HDF5 files",
validate=self._parameter_validate,
)
add_pvi_info(
PviGroup.INPUTS,
self._file_name_record,
file_name_record_name,
builder.longStringOut,
)
self._file_name_record.add_alias(
record_prefix + ":" + file_name_record_name.upper()
)

num_capture_record_name = self._HDF5_PREFIX + ":NumCapture"
num_capture_record_name = EpicsName(self._HDF5_PREFIX + ":NumCapture")
self._num_capture_record = builder.longOut(
num_capture_record_name,
initial_value=0, # Infinite capture
DESC="Number of frames to capture. 0=infinite",
DRVL=0,
)

add_pvi_info(
PviGroup.INPUTS,
self._num_capture_record,
num_capture_record_name,
builder.longOut,
)
# No validate - users are allowed to change this at any time
self._num_capture_record.add_alias(
record_prefix + ":" + num_capture_record_name.upper()
)

flush_period_record_name = self._HDF5_PREFIX + ":FlushPeriod"
flush_period_record_name = EpicsName(self._HDF5_PREFIX + ":FlushPeriod")
self._flush_period_record = builder.aOut(
flush_period_record_name,
initial_value=1.0,
DESC="Frequency that data is flushed (seconds)",
)
add_pvi_info(
PviGroup.INPUTS,
self._flush_period_record,
flush_period_record_name,
builder.aOut,
)
self._flush_period_record.add_alias(
record_prefix + ":" + flush_period_record_name.upper()
)

capture_control_record_name = self._HDF5_PREFIX + ":Capture"
capture_control_record_name = EpicsName(self._HDF5_PREFIX + ":Capture")
self._capture_control_record = builder.boolOut(
capture_control_record_name,
ZNAM=ZNAM_STR,
Expand All @@ -105,27 +131,45 @@ def __init__(self, client: AsyncioClient, record_prefix: str):
validate=self._capture_validate,
DESC="Start/stop HDF5 capture",
)
add_pvi_info(
PviGroup.INPUTS,
self._capture_control_record,
capture_control_record_name,
builder.boolOut,
)
self._capture_control_record.add_alias(
record_prefix + ":" + capture_control_record_name.upper()
)

status_message_record_name = self._HDF5_PREFIX + ":Status"
status_message_record_name = EpicsName(self._HDF5_PREFIX + ":Status")
self._status_message_record = builder.stringIn(
status_message_record_name,
initial_value="OK",
DESC="Reports current status of HDF5 capture",
)
add_pvi_info(
PviGroup.OUTPUTS,
self._status_message_record,
status_message_record_name,
builder.stringIn,
)
self._status_message_record.add_alias(
record_prefix + ":" + status_message_record_name.upper()
)

currently_capturing_record_name = self._HDF5_PREFIX + ":Capturing"
currently_capturing_record_name = EpicsName(self._HDF5_PREFIX + ":Capturing")
self._currently_capturing_record = builder.boolIn(
currently_capturing_record_name,
ZNAM=ZNAM_STR,
ONAM=ONAM_STR,
DESC="If HDF5 file is currently being written",
)
add_pvi_info(
PviGroup.OUTPUTS,
self._currently_capturing_record,
currently_capturing_record_name,
builder.boolIn,
)
self._currently_capturing_record.add_alias(
record_prefix + ":" + currently_capturing_record_name.upper()
)
Expand Down Expand Up @@ -212,8 +256,12 @@ async def _handle_hdf5_data(self) -> None:
pipeline[0].queue.put_nowait(
EndData(captured_frames, EndReason.OK)
)

break
elif not isinstance(data, EndData):
raise RuntimeError(
f"Data was recieved that was of type {type(data)}, not"
"StartData, EndData, ReadyData or FrameData"
)
# Ignore EndData - handle terminating capture with the Capture
# record or when we capture the requested number of frames

Expand Down
Loading
Loading