Refactor structure handling within dataobjects?

Open
#296 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start by perusing the format documentation, then inspect the listed flag-dependent parsing paths in dataobjects: _parse_v2_header, _get_attributes_from_attr_info, _decode_link_info_msg, _decode_link_msg, and determine_data_shape. Done means identifying other unhandled flag-dependent cases and assessing whether a shared wrapper is appropriate; the issue does not specify a particular implementation.

Written by the indexing model from the issue text.

Description

enhancement

In PR #295 which fixes #294, there is an expedient bug fix. The question arises as to whether this bug fix is an example of a pattern which should be refactored.

AI surfaced the following candidates for consideration of using a wrapper around unpack_structure_from which uses flags and structure variants.

  • _parse_v2_header conditionally reads timestamps and adjusts the creation-order size based on flag bits (line 167).
  • _get_attributes_from_attr_info skips an optional field and conditionally reads another address (line 250). The file already defines alternate structure descriptions for this message, which suggests this case is a natural candidate (line 914).
  • _decode_link_info_msg chooses between two address layouts based on a flag (line 803); both layouts are already defined (line 1015).
  • _decode_link_msg has several independently optional fields and a flag-selected name-length format (line 702).
    determine_data_shape conditionally reads maximum dimensions based on a flag (line 866).

Rather than rushing into something to handle these cases, it's probably worth a serious perusal of the documentation to see if we can surface other unhandled examples of flag dependent behaviour.

Dominant language
Python
Stars
105
Forks
29
Avg merge
2d 8h
Merged PRs (30d)
9

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NCAS-CMS/pyfive

All issues in NCAS-CMS/pyfive

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.