Repository navigation
Support arbitrary DD types in HDF5 I/O - #107
Merged
Merged
Conversation
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.
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
Member
Author
jmcclena
approved these changes
Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
imas2hdfalready recorded the actual container type in the file'sconcrete_typeattribute, buthdf2imaswas hard-wired toIMASdd.dd{Float64}and ignored it.Reading back anything other than an
IMASdd.ddsilently returnedan
IMASdd.ddwith the unknown fields dropped.hdf2imasnow resolves the recorded type, so any<: IMASdd.DDcontainer, such as one defined by a satellite package (e.g, IFEdd), round-trips through HDF5.Changes
@maybe_nospecializeinfertococos_outfor consistency._resolve_concrete_typehelper resolves a stringified type to itsTypeby searchingBase.loaded_moduleshdf2imas(filename)derives the type from the file; hdf2imas(filename, ids)` still fills the caller's instance in placeconcrete_typefall back todd_nospecialize()as before