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

ENH: add diff.py for comparing versions #36

Merged
merged 2 commits into from
Dec 2, 2022
Merged

Conversation

klauer
Copy link
Contributor

@klauer klauer commented Dec 1, 2022

PR changes here can be difficult to interpret. I thought a tool that shows a diff in a human-readable way might be beneficial.

This is just a quick tool based on my deployed IOC status checker, and doesn't need to be merged.

If we did end up liking the output of this, we could consider adding a CI job for it.

Here's some sample output:

$ python diff.py 189b35e aeb32ed

* rix_leviton_r02_t was added
  added key last_edit: Wed Nov 23 15:09:58 2022
  added key output_branches
  added key ioc_name
  added key ioc_release
  added key ioc_type
  added key ioc_arch
  added key device_class: pcdsdevices.fms.PDU_Temp2
  added key name: rix_leviton_r02_t
  added key z: -1.0
  added key args: ['{{prefix}}']
  added key prefix: RIX:PWR:R02
  added key elevations: ['01', '01']
  added key ioc_engineer: Lana Jansen-Whealey
  added key functional_group: PDU_Temp
  added key ioc_hutch
  added key documentation
  added key location_group: RIX
  added key kwargs: {'elevations': '{{elevations}}', 'name': '{{name}}'}
  added key beamline: FMS
  added key _id: rix_leviton_r02_t
  added key creation: Wed Nov 23 15:09:58 2022
  added key input_branches
  added key type: pcdsdevices.happi.containers.Leviton
  added key ioc_location
  added key lightpath: False
  added key stand
  added key active: True

* rix_leviton_r03_t was added
  added key last_edit: Wed Nov 23 15:29:36 2022
  added key output_branches
  added key ioc_name
  added key ioc_release
  added key ioc_type
  added key ioc_arch
  added key device_class: pcdsdevices.fms.PDU_Temp2
  added key name: rix_leviton_r03_t
  added key z: -1.0
  added key args: ['{{prefix}}']
  added key prefix: RIX:PWR:R03
  added key elevations: ['01', '01']
  added key ioc_engineer: Lana Jansen-Whealey
  added key functional_group: PDU_Temp
  added key ioc_hutch
  added key documentation
  added key location_group: RIX
  added key kwargs: {'elevations': '{{elevations}}', 'name': '{{name}}'}
  added key beamline: FMS
  added key _id: rix_leviton_r03_t
  added key creation: Wed Nov 23 15:29:36 2022
  added key input_branches
  added key type: pcdsdevices.happi.containers.Leviton
  added key ioc_location
  added key lightpath: False
  added key stand
  added key active: True

* rix_leviton_r04_t was added
  added key last_edit: Wed Nov 23 15:40:57 2022
  added key output_branches
  added key ioc_name
  added key ioc_release
  added key ioc_type
  added key ioc_arch
  added key device_class: pcdsdevices.fms.PDU_Temp2
  added key name: rix_leviton_r04_t
  added key z: -1.0
  added key args: ['{{prefix}}']
  added key prefix: RIX:PWR:R04
  added key elevations: ['01', '01']
  added key ioc_engineer: Lana Jansen-Whealey
  added key functional_group: PDU_Temp
  added key ioc_hutch
  added key documentation
  added key location_group: RIX
  added key kwargs: {'elevations': '{{elevations}}', 'name': '{{name}}'}
  added key beamline: FMS
  added key _id: rix_leviton_r04_t
  added key creation: Wed Nov 23 15:40:57 2022
  added key input_branches
  added key type: pcdsdevices.happi.containers.Leviton
  added key ioc_location
  added key lightpath: False
  added key stand
  added key active: True

* rix_leviton_r05_t was added
  added key last_edit: Wed Nov 23 16:03:38 2022
  added key output_branches
  added key ioc_name
  added key ioc_release
  added key ioc_type
  added key ioc_arch
  added key device_class: pcdsdevices.fms.PDU_Temp2
  added key name: rix_leviton_r05_t
  added key z: -1.0
  added key args: ['{{prefix}}']
  added key prefix: RIX:PWR:R05
  added key elevations: ['01', '01']
  added key ioc_engineer: Lana Jansen-Whealey
  added key functional_group: PDU_Temp
  added key ioc_hutch
  added key documentation
  added key location_group: RIX
  added key kwargs: {'elevations': '{{elevations}}', 'name': '{{name}}'}
  added key beamline: FMS
  added key _id: rix_leviton_r05_t
  added key creation: Wed Nov 23 15:51:34 2022
  added key input_branches
  added key type: pcdsdevices.happi.containers.Leviton
  added key ioc_location
  added key lightpath: False
  added key stand
  added key active: True

* rix_leviton_r06_h was added
  added key last_edit: Wed Nov 23 16:20:35 2022
  added key output_branches
  added key ioc_name
  added key ioc_release
  added key ioc_type
  added key ioc_arch
  added key device_class: pcdsdevices.fms.PDU_Humidity2
  added key name: rix_leviton_r06_h
  added key z: -1.0
  added key args: ['{{prefix}}']
  added key prefix: RIX:PWR:06
  added key elevations: ['01', '01']
  added key ioc_engineer: Lana Jansen-Whealey
  added key functional_group: PDU_Humidity
  added key ioc_hutch
  added key documentation
  added key location_group: RIX
  added key kwargs: {'elevations': '{{elevations}}', 'name': '{{name}}'}
  added key beamline: FMS
  added key _id: rix_leviton_r06_h
  added key creation: Wed Nov 23 16:20:35 2022
  added key input_branches
  added key type: pcdsdevices.happi.containers.Leviton
  added key ioc_location
  added key lightpath: False
  added key stand
  added key active: True

* rix_leviton_r06_t was added
  added key last_edit: Wed Nov 23 16:08:03 2022
  added key output_branches
  added key ioc_name
  added key ioc_release
  added key ioc_type
  added key ioc_arch
  added key device_class: pcdsdevices.fms.PDU_Temp2
  added key name: rix_leviton_r06_t
  added key z: -1.0
  added key args: ['{{prefix}}']
  added key prefix: RIX:PWR:06
  added key elevations: ['01', '01']
  added key ioc_engineer: Lana Jansen-Whealey
  added key functional_group: PDU_Temp
  added key ioc_hutch
  added key documentation
  added key location_group: RIX
  added key kwargs: {'elevations': '{{elevations}}', 'name': '{{name}}'}
  added key beamline: FMS
  added key _id: rix_leviton_r06_t
  added key creation: Wed Nov 23 16:00:12 2022
  added key input_branches
  added key type: pcdsdevices.happi.containers.Leviton
  added key ioc_location
  added key lightpath: False
  added key stand
  added key active: True

* rix_leviton_r07_t was added
  added key last_edit: Wed Nov 23 16:11:21 2022
  added key output_branches
  added key ioc_name
  added key ioc_release
  added key ioc_type
  added key ioc_arch
  added key device_class: pcdsdevices.fms.PDU_Temp2
  added key name: rix_leviton_r07_t
  added key z: -1.0
  added key args: ['{{prefix}}']
  added key prefix: RIX:PWR:R07
  added key elevations: ['01', '01']
  added key ioc_engineer: Lana Jansen-Whealey
  added key functional_group: PDU_Temp
  added key ioc_hutch
  added key documentation
  added key location_group: RIX
  added key kwargs: {'elevations': '{{elevations}}', 'name': '{{name}}'}
  added key beamline: FMS
  added key _id: rix_leviton_r07_t
  added key creation: Wed Nov 23 16:11:21 2022
  added key input_branches
  added key type: pcdsdevices.happi.containers.Leviton
  added key ioc_location
  added key lightpath: False
  added key stand
  added key active: True

* xpp_leviton_r39_t was added
  added key last_edit: Wed Nov 23 11:42:24 2022
  added key output_branches
  added key ioc_name
  added key ioc_release
  added key ioc_type
  added key ioc_arch
  added key device_class: pcdsdevices.fms.PDU_Temp4
  added key name: xpp_leviton_r39_t
  added key z: -1.0
  added key args: ['{{prefix}}']
  added key prefix: XPP:R39:PWR
  added key elevations: ['01', '01', '02', '02']
  added key ioc_engineer: Cynthia Melendrez
  added key functional_group: PDU_Temp
  added key ioc_hutch
  added key documentation
  added key location_group: XPP
  added key kwargs: {'elevations': '{{elevations}}', 'name': '{{name}}'}
  added key beamline: FMS
  added key _id: xpp_leviton_r39_t
  added key creation: Wed Nov 23 11:17:53 2022
  added key input_branches
  added key type: pcdsdevices.happi.containers.Leviton
  added key ioc_location
  added key lightpath: False
  added key stand
  added key active: False

* xcs_pbt_pim was changed
  added key ioc_engineer
  added key functional_group: "N/A"
  added key ioc_hutch
  added key output_branches: ['L3']
  added key ioc_name
  added key location_group: "N/A"
  added key ioc_release
  added key ioc_type
  added key ioc_arch
  added key input_branches: ['L3']
  added key ioc_location
  changed key last_edit: Tue Nov 22 17:11:38 2022
  changed key lightpath: True

* xpp_leviton_mon_t was changed
  changed key kwargs: {'elevations': '{{elevations}}', 'name': '{{name}}'}
  changed key last_edit: Wed Nov 23 10:16:18 2022

* xpp_leviton_r32_t was changed
  added key elevations: ['06', '06', '37', '37', '37', '37']
  changed key active: True
  changed key creation: Wed Nov 23 10:24:21 2022
  changed key device_class: pcdsdevices.fms.PDU_Temp3
  changed key kwargs: {'elevations': '{{elevations}}', 'name': '{{name}}'}
  changed key last_edit: Wed Nov 23 14:29:59 2022
  changed key type: pcdsdevices.happi.containers.Leviton

* Summary:
  rix_leviton_r02_t was added
  rix_leviton_r03_t was added
  rix_leviton_r04_t was added
  rix_leviton_r05_t was added
  rix_leviton_r06_h was added
  rix_leviton_r06_t was added
  rix_leviton_r07_t was added
  xpp_leviton_r39_t was added
  xcs_pbt_pim was changed
  xpp_leviton_mon_t was changed
  xpp_leviton_r32_t was changed

Device changes 11 of total devices 705

Works with other specifiers like HEAD~1 and tags as well

@ZLLentz
Copy link
Member

ZLLentz commented Dec 2, 2022

When I was reviewing the PR I thought "we need a tool for this" and here you go and write/adapt one before my thought is even done 👍

Copy link
Member

@ZLLentz ZLLentz left a comment

Choose a reason for hiding this comment

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

A generalized dict diff is the kind of thing that maybe belongs in pcdsutils in fully polished form.

This looks good to me and will be useful. May as well merge it in.

Copy link

@tangkong tangkong left a comment

Choose a reason for hiding this comment

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

I saw this and should have approved on sight. I love it <3

@klauer
Copy link
Contributor Author

klauer commented Dec 2, 2022

OK, cool - positive all around it seems. One minor update in 07cacbe (sorting by add/change/delete and the key)

Merge at will if it still is good

@ZLLentz ZLLentz merged commit e32ee8d into pcdshub:master Dec 2, 2022
@klauer klauer deleted the difftool branch December 2, 2022 23:18
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