Skip to content

Support arbitrary DD types in HDF5 I/O - #107

Merged
jmcclena merged 3 commits into
masterfrom
feat/ife_dd
Aug 6, 2026
Merged

jmcclena merged 3 commits into
masterfrom
feat/ife_dd

Conversation

@mgyoo86

@mgyoo86 mgyoo86 commented Aug 3, 2026 •

Copy link
Copy Markdown
Member

Summary

imas2hdf already recorded the actual container type in the file's
concrete_type attribute, but hdf2imas was hard-wired to IMASdd.dd{Float64}and ignored it.
Reading back anything other than an IMASdd.dd silently returned
an IMASdd.dd with the unknown fields dropped.

hdf2imas now resolves the recorded type, so any <: IMASdd.DD container, such as one defined by a satellite package (e.g, IFEdd), round-trips through HDF5.

Changes

  • Applies @maybe_nospecializeinfer to cocos_out for consistency.
  • new _resolve_concrete_type helper resolves a stringified type to its Type by searching Base.loaded_modules
  • hdf2imas(filename) derives the type from the file; hdf2imas(filename, ids)` still fills the caller's instance in place
  • files with no concrete_type fall back to dd_nospecialize() as before

mgyoo86 added 3 commits August 3, 2026 14:56
Previously `eval(Meta.parse(conc_type))()` only found types visible from
IMASdd's own scope, so satellite-defined IDS types (e.g. IFEdd.dd_ife)
failed to load. `_resolve_concrete_type` searches `Base.loaded_modules`
for the module defining the type instead.

Also apply `@maybe_nospecializeinfer` to `cocos_out` methods for
consistency with the rest of the codebase's specialization handling.
`_resolve_concrete_type` turned the whole pre-`{` substring into a
Symbol, so `"IMASdd.dd{Float64}"` became `Symbol("IMASdd.dd")` — a
dotted name is never a binding, so `isdefined` always failed and every
qualified type errored out.

Neither IMASdd nor its satellites export their types, so
`string(typeof(ids))` is always module-qualified. That made this break
hdf2imas for every file carrying a `concrete_type` attribute, including
plain `IMASdd.dd`.

Walk the parsed expression down to its root name instead:
`IMASdd.dd{Float64}` => :IMASdd, `dd_ife{Float64}` => :dd_ife.
`hdf2imas(filename)` took `dd_nospecialize()` as a default argument and never
looked at the file's `concrete_type`, so a file written by a satellite package
came back as an `IMASdd.dd` — silently, with satellite-only fields dropped by
the `hasfield` guard in the group walker.

Split that default into two methods, so the two intents stop sharing one
signature:

    hdf2imas(filename)       # the file decides the type (delegates to the "/" form)
    hdf2imas(filename, ids)  # fill the caller's instance in place, never substitute

Keeping the default would have meant swapping out an explicitly passed `ids`,
breaking the in-place contract shared with json2imas/jstr2imas.

Files carrying no `concrete_type` still fall back to `dd_nospecialize()`, so
data written before that attribute existed loads unchanged.

Adds runtests_satellite.jl, which stands up a stand-in satellite package — its
own `my_own_dd <: IMASdd.DD` plus a `my_own_ids` that `IMASdd.dd` has no field
for — and pins the contract IMASdd owes such packages: type resolution,
round-trip, in-place semantics, keyword forwarding, and the legacy fallback.
@mgyoo86
mgyoo86 requested review from Copilot and jmcclena August 4, 2026 00:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.23529% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.92%. Comparing base (b67511b) to head (c0174cf).

Files with missing lines Patch % Lines
src/cocos.jl 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #107      +/-   ##
==========================================
+ Coverage   43.89%   43.92%   +0.02%     
==========================================
  Files          17       16       -1     
  Lines       31538    31551      +13     
==========================================
+ Hits        13845    13859      +14     
+ Misses      17693    17692       -1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mgyoo86

mgyoo86 commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

@jmcclena
FYI, FUSE CI passed.
This PR is safe to merge.

@jmcclena
jmcclena merged commit 8044a17 into master Aug 6, 2026
10 of 11 checks passed
@mgyoo86
mgyoo86 deleted the feat/ife_dd branch August 10, 2026 17:03
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