Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix incorrect handling of core_instant_changes IDS in `imas convert -…
…-convert-to-plasma-ids`
  • Loading branch information
maarten-ic committed Jan 14, 2026
commit 2a3c973c50798ca46fcac4d4b3ed6aa2bd8ecaca
58 changes: 30 additions & 28 deletions imas/command/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ def _check_convert_to_plasma_ids(idss_with_occurrences):
help="Convert core/edge profiles/transport/sources to the corresponding plasma IDS",
)
def convert_ids(
uri_in,
dd_version,
uri_out,
ids,
occurrence,
quiet,
timeit,
no_provenance,
convert_to_plasma_ids,
uri_in: str,
dd_version: str,
uri_out: str,
ids: str,
occurrence: int,
quiet: bool,
timeit: bool,
no_provenance: bool,
convert_to_plasma_ids: bool,
):
"""Convert a Data Entry (or a single IDS) to the target DD version.

Expand Down Expand Up @@ -252,25 +252,27 @@ def convert_ids(
# Convert to plasma_profiles/plasma_sources/plasma_transport IDS
if convert_to_plasma_ids and ids_name.startswith(("core", "edge")):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I guess this test shall be improved, currently it will get also the core_instant_changes IDS (still have to find a data-entry with such IDS).

Otherwise it looks good to me, but I'm waiting an answer to iterorganization/IMAS-Data-Dictionary#191 before approving.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sharp, I didn't think of that indeed! I'll update the logic

suffix = ids_name[4:]
logger.info(
"Storing IDS %s/%d as plasma%s/%d",
ids_name,
occurrence,
suffix,
next_plasma_occurrence[suffix],
)
occurrence = next_plasma_occurrence[suffix]
next_plasma_occurrence[suffix] += 1

name2 = f"[bold green]plasma{suffix}[/][green]/{occurrence}[/]"
progress.update(task, description=f"Converting {name} to {name2}")
if suffix == "_profiles":
ids2 = convert_to_plasma_profiles(ids2)
elif suffix == "_sources":
ids2 = convert_to_plasma_sources(ids2)
elif suffix == "_transport":
ids2 = convert_to_plasma_transport(ids2)
name = name2
# This branch also matches core_instant_changes: check that suffix is ok
if suffix in next_plasma_occurrence:
logger.info(
"Storing IDS %s/%d as plasma%s/%d",
ids_name,
occurrence,
suffix,
next_plasma_occurrence[suffix],
)
occurrence = next_plasma_occurrence[suffix]
next_plasma_occurrence[suffix] += 1

name2 = f"[bold green]plasma{suffix}[/][green]/{occurrence}[/]"
progress.update(task, description=f"Converting {name} to {name2}")
if suffix == "_profiles":
ids2 = convert_to_plasma_profiles(ids2)
elif suffix == "_sources":
ids2 = convert_to_plasma_sources(ids2)
elif suffix == "_transport":
ids2 = convert_to_plasma_transport(ids2)
name = name2

# Store in output entry:
progress.update(task, description=f"Storing {name}", advance=1)
Expand Down
Loading