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

Import/export network from/to folder #3092

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Import/export network from/to folder #3092

wants to merge 18 commits into from

Conversation

jonenst
Copy link
Contributor

@jonenst jonenst commented Jul 5, 2024

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

What is the current behavior?
Impossible to import a CGMES network described by several files in the same folder (one needs to zip the files)

What is the new behavior (if this is a feature change)?
It is now possible to import/export a CGMES network by giving the corresponding folder using Network::read or Network::write methods

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

  • Yes
  • No

Other information:

alternative to #3086

@jonenst jonenst changed the base branch from main to disambiguateimport July 5, 2024 09:46
@jonenst jonenst mentioned this pull request Sep 9, 2024
5 tasks
@jonenst jonenst changed the base branch from disambiguateimport to main September 9, 2024 12:58
Signed-off-by: HARPER Jon <jon.harper87@gmail.com>
flo-dup and others added 3 commits September 18, 2024 17:47
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
@flo-dup flo-dup changed the title Importfolders2 Import network from folder Sep 23, 2024
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
@flo-dup flo-dup changed the title Import network from folder Import/export network from/to folder Sep 23, 2024
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Copy link

sonarcloud bot commented Sep 24, 2024

filter filenames to only keep those starting with the base name. This behaviour basename-filtering only occurs if
`allFiles` is set to `false` in the datasource.
Setting `allFiles` to `true` is for example very useful for the CGMES use case, in which a network is defined by
several files (TP, EQ, SV, SSH, GL, ...), often without a common prefix (base name).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
several files (TP, EQ, SV, SSH, GL, ...), often without a common prefix (base name).
several files (TP, EQ, SV, SSH, GL, ...), often without a common prefix (base name). This makes the DirectoryDataSource behave just like an ArchiveDataSource.

DataSourceBuilder dataSourceBuilder = new DataSourceBuilder().withObserver(observer);
if (Files.isDirectory(fileOrDirectory)) {
dataSourceBuilder.withDirectory(fileOrDirectory)
.withBaseName(fileOrDirectory.getFileName().toString())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
.withBaseName(fileOrDirectory.getFileName().toString())
// we use the full directoryname here instead of a parsed representation using FileInformation
// this is required for now to allow directories with dots but without the dataextension (like "microgrid.v1.complete/")
// otherwise Fileinformation interprets the part after the dot as the dataextension. This has the drawback that
// directories with a dataextension (e.g. "network.xiidm/") will be rejected/mishandled because we will use
// a file named "network.xiidm.xiidm" inside it
// NOTE: this does not occur if the directory has a dot and also has the dataextension: "microgrid.v1.complete.xml/" works
// NOTE2: Maybe this can be fixed in the future by looking more at what is inside the directory and we can remove this
.withBaseName(fileOrDirectory.getFileName().toString())

Copy link
Member

Choose a reason for hiding this comment

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

This should go in the javadoc more than in a simple comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants