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 PVAccess information to Table records #8

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
35 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
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
2 changes: 1 addition & 1 deletion .github/workflows/code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest"] # can add windows-latest, macos-latest
python: ["3.9", "3.10", "3.11"]
python: ["3.9", "3.10"] # Disable 3.11 until this is fixed:https://github.com/PandABlocks/PandABlocks-client/issues/47
install: ["-e .[dev]"]
# Make one version be non-editable to test both paths of version code
include:
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
14 changes: 10 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ dependencies = [
"numpy",
"click",
"h5py",
"softioc>=4.1.0",
"softioc>=4.3.0",
"pandablocks>=0.3.1",
"pvi[cli]>=0.4",
"aiohttp",
] # Add project dependencies here, e.g. ["click", "numpy"]
dynamic = ["version"]
license.file = "LICENSE"
Expand All @@ -37,6 +36,7 @@ dev = [
"Flake8-pyproject",
"pipdeptree",
"pre-commit",
"p4p",
"pydata-sphinx-theme>=0.12",
"pytest-asyncio",
"pytest-cov",
Expand Down Expand Up @@ -88,19 +88,25 @@ 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,
# 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.
# Remaining 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.
filterwarnings = """
error
ignore:numpy.ufunc size changed
ignore:The explicit passing of coroutine objects to asyncio.wait()
ignore:unclosed transport <_SelectorSocketTransport:
ignore:unclosed <socket.socket:
ignore:unclosed event loop <_UnixSelectorEventLoop:
"""
# 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]
data_file = "/tmp/pandablocks_ioc.coverage"
Expand Down
8 changes: 5 additions & 3 deletions src/pandablocks_ioc/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ 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(host=host, record_prefix=prefix, screens_dir=screens_dir)


# test with: python -m pandablocks_ioc
Expand Down
34 changes: 17 additions & 17 deletions src/pandablocks_ioc/_pvi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
import tempfile
from dataclasses import dataclass
from enum import Enum
from pathlib import Path
Expand Down Expand Up @@ -139,9 +138,13 @@ def add_positions_table_row(
class Pvi:
"""TODO: Docs"""

# pvi_info_dict: Dict[EpicsName, PviInfo] = {}
_screens_dir: Path = Path()
pvi_info_dict: Dict[str, Dict[PviGroup, List[Component]]] = {}
bob_file_dict: Dict[str, str] = {}

@staticmethod
def set_screens_dir(screens_dir: str):
Pvi._screens_dir = Path(screens_dir)
assert Pvi._screens_dir.is_dir(), "Screens directory must exist"

@staticmethod
def add_pvi_info(record_name: EpicsName, group: PviGroup, component: Component):
Expand Down Expand Up @@ -206,22 +209,19 @@ def create_pvi_records(record_prefix: str):
# Create top level Device, with references to all child Devices
device_refs = [DeviceRef(x, x) for x in pvi_records]

# # TODO: What should the label be?
device = Device("TOP", device_refs)
devices.append(device)

# TODO: label widths need some tweaking - some are pretty long right now
# TODO: Need to decide how to handle already existing directory/files.
# Could still be left over stuff from a previous run?
formatter = DLSFormatter(label_width=250)
with tempfile.TemporaryDirectory() as temp_dir:
for device in devices:
try:
formatter.format(
device,
record_prefix + ":",
Path(f"{temp_dir}/{device.label}.bob"),
)
with open(f"{temp_dir}/{device.label}.bob") as f:
Pvi.bob_file_dict.update({f"{device.label}.bob": f.read()})

except NotImplementedError:
logging.exception("Cannot create TABLES yet")
for device in devices:
try:
formatter.format(
device,
record_prefix + ":",
Pvi._screens_dir / Path(f"{device.label}.bob"),
)
except NotImplementedError:
logging.exception("Cannot create TABLES yet")
Loading