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

CgmesImporter, allow importing with wrong dataextension when the mainfile doesn't exist #3147

Merged
merged 10 commits into from
Sep 23, 2024

Conversation

jonenst
Copy link
Contributor

@jonenst jonenst commented Sep 19, 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?

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?

  • Yes
  • No

Other information:
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 ".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.

…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>
@jonenst jonenst force-pushed the fixcgmesimportonmissingmainfile branch from 7fe3adc to e196ede Compare September 19, 2024 08:36
@jonenst jonenst force-pushed the fixcgmesimportonmissingmainfile branch from d8abbc2 to 1d6a4e7 Compare September 19, 2024 12:51
Comment on lines +68 to +71
Arguments.of("bar", "xml"),
Arguments.of("bar", null),
Arguments.of("bar", ""),
Arguments.of("bar", "notexists")
Copy link
Contributor

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.

Comment on lines +120 to +124
Arguments.of("notexist", "xml", true),
Arguments.of("notexist", "xiidm", true),
Arguments.of("notexist", "notexists", true),
Arguments.of("notexist", "", true),
Arguments.of("notexist", null, true)
Copy link
Contributor

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

jonenst and others added 3 commits September 19, 2024 16:09
…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>
@jonenst jonenst force-pushed the fixcgmesimportonmissingmainfile branch from af7cca2 to 2906e96 Compare September 19, 2024 14:51
Signed-off-by: HARPER Jon <jon.harper87@gmail.com>
Signed-off-by: HARPER Jon <jon.harper87@gmail.com>
Copy link

@flo-dup flo-dup merged commit ed110f3 into main Sep 23, 2024
7 checks passed
@flo-dup flo-dup deleted the fixcgmesimportonmissingmainfile branch September 23, 2024 08:14
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