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

Adding records for tracking version of IOC and PandA firmware #150

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

jwlodek
Copy link
Collaborator

@jwlodek jwlodek commented Nov 13, 2024

Would be useful for checking the versions of everything on the floor without needing to get into the IOC console or logging into the IOC server.

(venv) [jwlodek@xf31id1-ws3 PandABlocks-ioc]$ caget TEST:PANDA_SW_VERSION 
TEST:PANDA_SW_VERSION          3.0-11-g6422090

(venv) [jwlodek@xf31id1-ws3 PandABlocks-ioc]$ caget TEST:FPGA_VERSION
TEST:FPGA_VERSION              3.0.0C4 86e5f0a2 07d202f8 

(venv) [jwlodek@xf31id1-ws3 PandABlocks-ioc]$ caget TEST:ROOTFS_VERSION
TEST:ROOTFS_VERSION            PandA 3.1a1-1-g22fdd94

(venv) [jwlodek@xf31id1-ws3 PandABlocks-ioc]$ caget TEST:VERSION
TEST:VERSION                   0.11.4.dev0+g1e1e8cd.d20241113

@jwlodek
Copy link
Collaborator Author

jwlodek commented Nov 13, 2024

TODO: Add / fix tests

Copy link
Contributor

@evalott100 evalott100 left a comment

Choose a reason for hiding this comment

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

This would be a great feature!

src/pandablocks_ioc/ioc.py Outdated Show resolved Hide resolved
src/pandablocks_ioc/ioc.py Outdated Show resolved Hide resolved
src/pandablocks_ioc/ioc.py Outdated Show resolved Hide resolved
src/pandablocks_ioc/ioc.py Outdated Show resolved Hide resolved
@jwlodek
Copy link
Collaborator Author

jwlodek commented Nov 14, 2024

image

Bobfile generation worked great 👍

Copy link

codecov bot commented Nov 14, 2024

Codecov Report

Attention: Patch coverage is 84.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 91.61%. Comparing base (a126c15) to head (7b6f2e1).

Files with missing lines Patch % Lines
src/pandablocks_ioc/ioc.py 83.33% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #150      +/-   ##
==========================================
- Coverage   91.75%   91.61%   -0.14%     
==========================================
  Files           8        8              
  Lines        1394     1419      +25     
  Branches      164      168       +4     
==========================================
+ Hits         1279     1300      +21     
- Misses         82       84       +2     
- Partials       33       35       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +198 to +216
if len(idn.split(":")) / 2 > len(list(firmware_versions.keys())):
logging.error(f"Version string {idn} recieved from PandA could not be parsed!")
else:
for firmware_name in firmware_versions:
pattern = re.compile(
rf'{re.escape(firmware_name)}:\s*([^:]+?)(?=\s*\b(?:{"|".join(map(re.escape, firmware_versions))}):|$)' # noqa: E501
)
if match := pattern.search(idn):
firmware_versions[firmware_name] = match.group(1).strip()
logging.info(
f"{firmware_name} Version: {firmware_versions[firmware_name]}"
)
else:
logging.warning(f"Failed to get {firmware_name} version information!")

return {
EpicsName(firmware_name.upper().replace(" ", "_")): version
for firmware_name, version in firmware_versions.items()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Unnecessary line too long ignore.
  • There's the race condition below which this change fixes.
    • IDN provides an extra key value pair "Some Other Version: 1" in which case we have no way to tell what is in the previous version and what is in the key, but it didn't provide some key rootfs, so the check still passes.
Suggested change
if len(idn.split(":")) / 2 > len(list(firmware_versions.keys())):
logging.error(f"Version string {idn} recieved from PandA could not be parsed!")
else:
for firmware_name in firmware_versions:
pattern = re.compile(
rf'{re.escape(firmware_name)}:\s*([^:]+?)(?=\s*\b(?:{"|".join(map(re.escape, firmware_versions))}):|$)' # noqa: E501
)
if match := pattern.search(idn):
firmware_versions[firmware_name] = match.group(1).strip()
logging.info(
f"{firmware_name} Version: {firmware_versions[firmware_name]}"
)
else:
logging.warning(f"Failed to get {firmware_name} version information!")
return {
EpicsName(firmware_name.upper().replace(" ", "_")): version
for firmware_name, version in firmware_versions.items()
}
if (sum(name in idn for name in firmware_versions) < idn.count(":")):
error_text = f"Version string {idn} received unexpected version numbers!"
logging.error(error_text)
return {
EpicsName(firmware_name.upper().replace(" ", "_")): error_text
for firmware_name in firmware_versions
}
for firmware_name in firmware_versions:
pattern = re.compile(
rf'{re.escape(firmware_name)}:\s*([^:]+?)(?=\s*\b(?:"
rf"{"|".join(map(re.escape, firmware_versions))}):|$)'
)
if match := pattern.search(idn):
firmware_versions[firmware_name] = match.group(1).strip()
logging.info(
f"{firmware_name} Version: {firmware_versions[firmware_name]}"
)
else:
logging.warning(f"Failed to get {firmware_name} version information!")
return {
EpicsName(firmware_name.upper().replace(" ", "_")): version
for firmware_name, version in firmware_versions.items()
}

@@ -1824,6 +1865,40 @@ def create_block_records(

return record_dict

def create_version_records(self, fw_vers_dict: dict[EpicsName, str]):
Copy link
Contributor

Choose a reason for hiding this comment

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

Big preference for unshortened variable names which don't reference type in method definitions.

Suggested change
def create_version_records(self, fw_vers_dict: dict[EpicsName, str]):
def create_version_records(self, firmware_versions: dict[EpicsName, str]):

async def get_panda_versions(
client: AsyncioClient,
) -> dict[EpicsName, str]:
"""Function that gets version information from the PandA using the IDN command
Copy link
Contributor

@evalott100 evalott100 Nov 15, 2024

Choose a reason for hiding this comment

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

Thought it might be good to link:

https://pandablocks-server.readthedocs.io/en/latest/commands.html#system-commands

here too to explain why we need the parsing logic.

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.

3 participants