Skip to content

Conversation

@maarten-ic
Copy link
Collaborator

When constructing a DBEntry, a corresponding IDSFactory is created as well. Previously, constructing an IDSFactory would eagerly load the associated Data Dictionary XML files.

In some use cases (e.g. imas print or visualization libraries like IMAS-Paraview). A default DBEntry is constructed, but all IDSs are read with autoconvert=False. If these IDSs are in an older version of the Data Dictionary, we would previously unnecessarily parse two DD definitions. This was visible to users in the logging output, for example with imas print:

$ imas print imas:ascii?path=imas/assets core_profiles
[...] INFO     Parsing data dictionary version 4.1.0
[...] INFO     Parsing data dictionary version 3.39.0
[...]

This commit defers loading the default Data Dictionary definitions until they are really needed. In the imas print scenario above, this will skip loading the DD 4.1.0 definitions: saving a bit of time and potential confusion for users.

The most visible side effect of this change is in interactive Python sessions:

>>> import imas
>>> factory = imas.IDSFactory()
>>> cp = factory.core_profiles()
[...] INFO     Parsing data dictionary version 4.1.0

Before this change, the INFO log message would appear immediately after constructing the IDSFactory. Now, the XML file is only parsed when we need it for constructing the core_profiles IDS.

N.B. Also fix a couple of type warnings from ty in touched files.

When constructing a DBEntry, a corresponding IDSFactory is created as
well. Previously, constructing an IDSFactory would eagerly load the
associated Data Dictionary XML files.

In some use cases (e.g. `imas print` or visualization libraries like
IMAS-Paraview). A default DBEntry is constructed, but all IDSs are read
with `autoconvert=False`. If these IDSs are in an older version of the
Data Dictionary, we would previously unnecessarily parse two DD
definitions. This was visible to users in the logging output, for
example with `imas print`:

```
$ imas print imas:ascii?path=imas/assets core_profiles
[...] INFO     Parsing data dictionary version 4.1.0
[...] INFO     Parsing data dictionary version 3.39.0
[...]
```

This commit defers loading the default Data Dictionary definitions until
they are really needed. In the `imas print` scenario above, this will
skip loading the DD 4.1.0 definitions: saving a bit of time and
potential confusion for users.

The most visible side effect of this change is in interactive Python
sessions:

```python
>>> import imas
>>> factory = imas.IDSFactory()
>>> cp = factory.core_profiles()
[...] INFO     Parsing data dictionary version 4.1.0
```

Before this change, the INFO log message would appear immediately after
constructing the `IDSFactory`. Now, the XML file is only parsed when we
need it for constructing the `core_profiles` IDS.

N.B. Also fix a couple of type warnings from `ty` in touched files.
@maarten-ic
Copy link
Collaborator Author

N.B. this will cause a merge conflict with #87, to be resolved when either PR is merged.

@MireilleSchneider for your information: this will fix the confusing log message we discussed last week from the waveform-editor training: Link to ITER Confluence 🔒

Co-authored-by: Mike Sanders <61876761+mikesndrs@users.noreply.github.com>
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.

2 participants