Skip to content

asdf info block display#2014

Merged
sydduckworth merged 17 commits intoasdf-format:mainfrom
sydduckworth:asdf_info_block_display
Apr 20, 2026
Merged

asdf info block display#2014
sydduckworth merged 17 commits intoasdf-format:mainfrom
sydduckworth:asdf_info_block_display

Conversation

@sydduckworth
Copy link
Copy Markdown
Contributor

@sydduckworth sydduckworth commented Apr 1, 2026

Description

  • Added block table output which is optionally printed after the tree
  • Added show_blocks parameter to AsdfFile.info method which defaults to False
  • Added --show-blocks argument to info CLI command
  • Format matches the equivalent libasdf command

Closes #1923

Example Output

asdftool info --show-blocks basic.asdf 
root (AsdfObject)
├─asdf_library (Software)
│ ├─author (str): The ASDF Developers
│ ├─homepage (str): http://github.com/asdf-format/asdf
│ ├─name (str): asdf
│ └─version (str): 4.1.0
├─history (dict)
│ └─extensions (list)
│   └─[0] (ExtensionMetadata)
│     ├─extension_class (str): asdf.extension._manifest.ManifestExtension
│     ├─extension_uri (str): asdf://asdf-format.org/core/extensions/core-1.6.0
│     ├─manifest_software (Software)
│     │ ├─name (str): asdf_standard
│     │ └─version (str): 1.1.1
│     └─software (Software)
│       ├─name (str): asdf
│       └─version (str): 4.1.0
└─data (NDArrayType)
  ├─shape (tuple)
  │ └─[0] (int): 8
  └─dtype (Int64DType): int64
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                     Block #0                      ┃
┣━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ flags          │            0x00000000            ┃
┃ compression    │               None               ┃
┃ allocated_size │                64                ┃
┃ used_size      │                64                ┃
┃ data_size      │                64                ┃
┃ checksum       │ 35594cae5fb11be3ea419c26bc4cfbee ┃
┗━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

* `info` now optionally prints a table containing block header metadata
  for each block in the source file
* Added `show_blocks` parameter to enable/disable block tables which
  defaults to `False`
@sydduckworth sydduckworth requested a review from a team as a code owner April 1, 2026 13:34
@sydduckworth sydduckworth requested a review from braingram April 1, 2026 13:37
Copy link
Copy Markdown
Contributor

@braingram braingram left a comment

Choose a reason for hiding this comment

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

Thanks for working on this. I left a few comments. Overall this is an improvement to the inspectability of files.

As noted I'm not against adding type hints. To check those are correct we'd benefit from first adding a type checker. If you're interested in adding type hints would you make a separate PR that sets up mypy for this project as a pre-commit hook (and addresses any configuration and other issues that might uncover)?

Once the comments are addressed would you update this PR with a comment showing some example block info output?

Comment thread asdf/_asdf.py Outdated
Comment thread asdf/_display.py Outdated
Comment thread changes/2014.feature.rst
Comment thread asdf/_asdf.py Outdated
Comment thread asdf/_display.py
Comment thread asdf/_asdf.py Outdated
Comment thread asdf/_tests/test_info.py Outdated
* Non-printing trailing `\0` bytes are now stripped
* Invalid unicode bytes are now replaced with slash escape characters
* Updated block display tests to also check `asdf.info` output
* Converted tests to snapshot tests using syrupy
* Added new `ndarray2.asdf` file which contains multiple blocks with
  different compression types
Comment thread .pre-commit-config.yaml Outdated
Comment thread pyproject.toml
Comment thread asdf/_asdf.py Outdated
@sydduckworth sydduckworth requested a review from braingram April 17, 2026 18:43
Copy link
Copy Markdown
Contributor

@braingram braingram left a comment

Choose a reason for hiding this comment

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

One minor request to update the test data with padded blocks so that used_size != allocated_size.

Comment thread asdf/_tests/data/ndarray2.asdf
Copy link
Copy Markdown
Contributor

@braingram braingram left a comment

Choose a reason for hiding this comment

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

Thanks! This looks great and funny enough I was handed an ASDF file today that I already wanted to use this new feature on :)

@sydduckworth sydduckworth merged commit 2a71490 into asdf-format:main Apr 20, 2026
44 checks passed
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.

add block display to asdf info

2 participants