Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AmplNetworkWriter: only call getExtension for the ones that have a writer #3313

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jonenst
Copy link
Contributor

@jonenst jonenst commented Feb 7, 2025

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem?

NO

What kind of change does this PR introduce?

Feature/bugfix

Does this PR introduce a new Powsybl Action implying to be implemented in simulators or pypowsybl?

  • Yes, the corresponding issue is here
  • No

What is the current behavior?

when exporting a network in ampl format, we call getExtensions and then we filter to do nothing based on the absence/presence of extension specific writes.

What is the new behavior (if this is a feature change)?
when exporting a network in ampl format, we only call getExtension for data that we will actually serialize

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

Other information:
This is very useful for iidm implementations like network-store which don't have everything loaded in memory and do network requests to load the data

@jonenst jonenst requested a review from flo-dup February 7, 2025 13:05
Comment on lines +253 to +255
List<AmplExtension> extList = extensionMap.computeIfAbsent(ext.getName(), k -> new ArrayList<>());
extList.add(new AmplExtension(extendedNum, extendable, ext));
extensionMap.put(ext.getName(), extList);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
List<AmplExtension> extList = extensionMap.computeIfAbsent(ext.getName(), k -> new ArrayList<>());
extList.add(new AmplExtension(extendedNum, extendable, ext));
extensionMap.put(ext.getName(), extList);
extensionMap.computeIfAbsent(ext.getName(), k -> new ArrayList<>()).add(new AmplExtension(extendedNum, extendable, ext));

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