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

WIP: add tree command #561

Closed
wants to merge 1 commit into from
Closed

WIP: add tree command #561

wants to merge 1 commit into from

Conversation

bjarthur
Copy link
Member

still a work in progress as i haven't tested all corner cases. please let me know if something doesn't work for you.

for example:

help?> tree
  tree(obj::Union{HDF5File,HDF5Group})

  Display the hierarchical structure of object obj, much like the bash tree command does for file
  system paths. Similar to h5dump on the linux command line but more concise as it omits the full
  contents of datasets.

julia> fid=h5open("plate_001/patch_attempt_0000_000/camera_clamp2_000/000/Clamp2.ma")

julia> tree(fid)
MetaArray: 2
data (80000, 3) Float64
└─ info
   ├─ _metaType_: list
   ├─ 0
   │  ├─ _metaType_: dict
   │  ├─ name: 'Channel'
   │  └─ cols
   │     ├─ _metaType_: list
   │     ├─ 0
   │     │  ├─ _metaType_: dict
   │     │  ├─ name: 'command'
   │     │  └─ units: 'V'
   │     ├─ 1
   │     │  ├─ _metaType_: dict
   │     │  ├─ name: 'primary'
   │     │  └─ units: 'A'
   │     └─ 2
   │        ├─ _metaType_: dict
   │        ├─ name: 'secondary'
   │        └─ units: 'V'
   ├─ 1
   │  ├─ _metaType_: dict
   │  ├─ name: 'Time'
   │  ├─ units: 's'
   │  └─ values (80000,) Float64
   └─ 2
      ├─ _metaType_: dict
      ├─ startTime: 1.5627830491764686e9
      ├─ ClampState
      │  ├─ LPFCutoff: 20000.0
      │  ├─ _metaType_: dict
      │  ├─ extCmdScale: 0.02
      │  ├─ holding: -0.07
      │  ├─ membraneCapacitance: 0.0
      │  ├─ mode: 'VC'
      │  ├─ primaryGain: 2.0
      │  ├─ primaryScaleFactor: 1.0e-9
      │  ├─ primarySignal: 'Membrane Current'
      │  ├─ primaryUnits: 'A'
      │  ├─ secondaryGain: 1.0
      │  ├─ secondaryScaleFactor: 0.1
      │  ├─ secondarySignal: 'Membrane Potential'
      │  ├─ secondaryUnits: 'V'
      │  └─ ClampParams
      │     ├─ BridgeBalEnable: 6004
      │     ├─ BridgeBalResist: 8.413395979806202e-42
      │     ├─ FastCompCap: 1.848093076142754e-12
      │     ├─ FastCompTau: 1.7999999499807018e-6
      │     ├─ Holding: -4.915825115858752e-7
      │     ├─ HoldingEnable: 0
      │     ├─ LeakSubEnable: 0
      │     ├─ LeakSubResist: 4.0950001664e10
      │     ├─ NeutralizationCap: 8.413395979806202e-42
      │     ├─ NeutralizationEnable: 6004
      │     ├─ OutputZeroAmplitude: 0.0
      │     ├─ OutputZeroEnable: 0
      │     ├─ PipetteOffset: 0.038417998701334
      │     ├─ PrimarySignalHPF: 0.0
      │     ├─ PrimarySignalLPF: 20000.0
      │     ├─ RsCompBandwidth: 2867.199951171875
      │     ├─ RsCompCorrection: 0.0
      │     ├─ RsCompEnable: 0
      │     ├─ SlowCompCap: 0.0
      │     ├─ SlowCompTau: 9.999999747378752e-6
      │     ├─ WholeCellCompCap: 2.7520702730599034e-11
      │     ├─ WholeCellCompEnable: 0
      │     ├─ WholeCellCompResist: 8.969545e6
      │     └─ _metaType_: dict
      ├─ DAQ
      │  ├─ _metaType_: dict
      │  ├─ command
      │  │  ├─ _metaType_: dict
      │  │  ├─ holding: -0.07
      │  │  ├─ numPts: 80000L
      │  │  ├─ rate: 40000.0
      │  │  ├─ startTime: 1.5627830491764686e9
      │  │  └─ type: 'ao'
      │  ├─ primary
      │  │  ├─ _metaType_: dict
      │  │  ├─ numPts: 80000L
      │  │  ├─ rate: 40000.0
      │  │  ├─ startTime: 1.5627830491764686e9
      │  │  └─ type: 'ai'
      │  └─ secondary
      │     ├─ _metaType_: dict
      │     ├─ numPts: 80000L
      │     ├─ rate: 40000.0
      │     ├─ startTime: 1.5627830491764686e9
      │     └─ type: 'ai'
      └─ Protocol
         ├─ _metaType_: dict
         ├─ mode: 'VC'
         ├─ primary: None
         ├─ recordState: 1
         └─ secondary: None

@musm
Copy link
Member

musm commented Aug 20, 2019

I wonder if it makes sense to just wrap something like h5dump ?

@musm
Copy link
Member

musm commented Oct 28, 2020

Should we try to get this in? It's pretty nice and we might want to use it for the default show method.

@jmert
Copy link
Contributor

jmert commented Oct 29, 2020

Should we modify this to duplicate the show style from JLD2?

@musm
Copy link
Member

musm commented Oct 29, 2020

That would be a great idea.

@musm
Copy link
Member

musm commented Oct 30, 2020

@bjarthur Any chance you have time to work on this PR?

@bjarthur
Copy link
Member Author

not really, but i could try to find the time. can you give me an example of the show from JLD2.jl? better yet, does anyone have any ideas as to how we could make it possible to interactively collapse and expand the hierarchy in the REPL, much like one can do with dicts in Juno.jl?

@musm
Copy link
Member

musm commented Oct 31, 2020

Here's what JLD2 does https://github.com/JuliaIO/JLD2.jl/blob/e84b06eb72b850048453df13fdd7f685ce213225/src/groups.jl#L417
I think it would be nice to use the same icons.

@jmert
Copy link
Contributor

jmert commented Oct 31, 2020

I took a stab at prototyping an implementation the other day:

julia> HDF5.show_tree(hid)
🗃️ HDF5 data file: /mnt/shared/a_file.h5
├─ 🔖 creator
├─ 🔖 description
├─ 📂 R
│  ├─ 🔖 description
│  ├─ 🔖 format
│  ├─ 🔖 shape
│  ├─ 🔢 data
│  ├─ 🔢 indices
│  └─ 🔢 indptr
├─ 🔢 fields
├─ 📂 pixels_left
│  ├─ 🔖 description
│  ├─ 🔢 dec
│  ├─ 🔢 order
│  ├─ 🔢 ra
│  └─ 🔢 type
└─ 📂 pixels_right
   ├─ 🔖 description
   ├─ 🔢 nside
   ├─ 🔢 pixels
   └─ 🔢 type

I guess icon choices need to be tweaked — on my terminal, the description fields' icons are little tags (my choice of icon for Attributes), but here the bookmark icon doesn't work so well. (Or maybe that just my browser's view?? At any rate, if I can't predict what the icon is going to look like, then it obviously needs to be chosen differently.)

Edit: Terminal view —
image

@musm
Copy link
Member

musm commented Nov 1, 2020

better yet, does anyone have any ideas as to how we could make it possible to interactively collapse and expand the hierarchy in the REPL, much like one can do with dicts in Juno.jl?

https://github.com/pfitzseb/REPLTreeViews.jl maybe?

@bjarthur
Copy link
Member Author

bjarthur commented Nov 1, 2020

REPLTreeViews.jl is totally what i've been looking for! thanks for the link @musm . i've opened an issue over there asking how we could add support for HDF5.

@musm
Copy link
Member

musm commented Nov 3, 2020

@bjarthur many thanks for this PR and starting this effort! I think we can explore further updates using TreeViews etc. to further improve the experience. For now I'll close this since it's implemented in #725

@musm musm closed this Nov 3, 2020
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.

None yet

3 participants