-
Notifications
You must be signed in to change notification settings - Fork 43
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
CgmesImporter, allow importing with wrong dataextension when the mainfile doesn't exist #3147
Conversation
…file doesn't exist This happens when filenames have the 2 following properties: - the filename contains a dot: - the filename does not contain the dataextension For example this filename triggers the bug: "microgrid.v2.complete.zip" but these work: "microgrid_v2_complete.zip" (because empty dataextension) or "microgrid.v2.complete.xml.zip" (because ".xml" dataextension) The problem is that the main extension is derived as ".v2.complete" but the cgmes importer only accepts an empty dataextension or ".xml" (it checks the dataextension to avoid importing as cgmes from a datasource that was meant by the user to be used as another format). But for now no other importer works without a main file, so when the mainfile doesn't exist so we shouldn't block the import just like when the dataextension is not specified NOTE: this happens because we want to allow archive filenames to be very flexible (with or without the dataextension, and for cgmes even with a totally different basename as what is inside). NOTE: if we ever have another importer that works like the cgmes importer, this means we will not be able to handle the following case: archive/network_EQ.xml archive/network_TP.xml # cgmes files archive/network_foo.other archive/network_bar.other # some new importer format and be able to import from a single directory containing both networks by specifying the dataextension. But this should be a rare case, and moving the data to separate directories or using separate basenames works around the problem. Signed-off-by: HARPER Jon <jon.harper87@gmail.com>
7fe3adc
to
e196ede
Compare
Signed-off-by: HARPER Jon <jon.harper87@gmail.com>
d8abbc2
to
1d6a4e7
Compare
cgmes/cgmes-model/src/test/java/com/powsybl/cgmes/model/CgmesOnDataSourceTest.java
Outdated
Show resolved
Hide resolved
cgmes/cgmes-model/src/test/java/com/powsybl/cgmes/model/CgmesOnDataSourceTest.java
Outdated
Show resolved
Hide resolved
Arguments.of("bar", "xml"), | ||
Arguments.of("bar", null), | ||
Arguments.of("bar", ""), | ||
Arguments.of("bar", "notexists") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are they useful? I think each one corresponds to the same logic as one of the previous arguments.
Arguments.of("notexist", "xml", true), | ||
Arguments.of("notexist", "xiidm", true), | ||
Arguments.of("notexist", "notexists", true), | ||
Arguments.of("notexist", "", true), | ||
Arguments.of("notexist", null, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure those are needed
…nDataSourceTest.java Co-authored-by: Florian Dupuy <66690739+flo-dup@users.noreply.github.com> Signed-off-by: Jon Harper <jon.harper87@gmail.com>
…nDataSourceTest.java Co-authored-by: Florian Dupuy <66690739+flo-dup@users.noreply.github.com> Signed-off-by: Jon Harper <jon.harper87@gmail.com>
Signed-off-by: HARPER Jon <jon.harper87@gmail.com>
af7cca2
to
2906e96
Compare
Signed-off-by: HARPER Jon <jon.harper87@gmail.com>
Signed-off-by: HARPER Jon <jon.harper87@gmail.com>
|
Please check if the PR fulfills these requirements
Does this PR already have an issue describing the problem?
NO
What kind of change does this PR introduce?
Bug fix
What is the current behavior?
can't import a cgmes zip with a dot in the name and not ".xml.zip" as the extension (e.g. microgrid.v2.complete.zip)
What is the new behavior (if this is a feature change)?
can import
Does this PR introduce a breaking change or deprecate an API?
Other information:
This happens when filenames have the 2 following properties:
"microgrid_v2_complete.zip" (because empty dataextension)
or "microgrid.v2.complete.xml.zip" (because ".xml" dataextension)
The problem is that the main extension is derived as ".complete" but the cgmes importer only accepts an empty dataextension or ".xml" (it checks the dataextension to avoid importing as cgmes from a datasource that was meant by the user to be used as another format). But for now no other importer works without a main file, so when the mainfile doesn't exist so we shouldn't block the import just like when the dataextension is not specified
NOTE: this happens because we want to allow archive filenames to be very flexible (with or without the dataextension, and for cgmes even with a totally different basename as what is inside).
NOTE: if we ever have another importer that works like the cgmes importer, this means we will not be able to handle the following case: archive/network_EQ.xml
archive/network_TP.xml # cgmes files
archive/network_foo.other
archive/network_bar.other # some new importer format and be able to import from a single directory containing both networks by specifying the dataextension. But this should be a rare case, and moving the data to separate directories or using separate basenames works around the problem.