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

Creating a new model with QGIS in the same folder errors the plugin #1679

Open
deltamarnix opened this issue Aug 1, 2024 · 1 comment
Open
Labels
bug Indicates an unexpected problem or unintended behavior QGIS Ribasim QGIS plugin

Comments

@deltamarnix
Copy link
Contributor

  • Open QGIS and ensure that the Ribasim plugin is installed and enabled.
  • Open the application via the Ribasim button on the QGIS toolbar: Ribasim panel opens.
  • Press the "New" button in the Model tab: file navigation window pops up.
  • Fill in a name ("test1").
  • Press OK: A toml and database file are created on the given location.
  • Press the "New" button in the Model tab: file navigation window pops up.
  • Fill in a name ("test2").
  • Press OK: An error is given that the database.gpkg already exists.

And unfortunately, it still writes test2.toml to disk, although it does not match the database.gpkg.

An error has occurred while executing Python code:

RuntimeError: Layer Node could not be written to geopackage: C:\Users\X\ribasim_models\database.gpkg with error: Creation of data source failed (OGR error: A file system object called 'C:\Users\X\ribasim_models\database.gpkg' already exists.)
Traceback (most recent call last):
File "C:\Users\X\Source\Repos\Ribasim.pixi\qgis_env\profiles\default/python/plugins\ribasim_qgis\widgets\dataset_widget.py", line 261, in new_model
instance.write()
File "C:\Users\X\Source\Repos\Ribasim.pixi\qgis_env\profiles\default/python/plugins\ribasim_qgis\core\nodes.py", line 180, in write
self.layer = geopackage.write_layer(
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\X\Source\Repos\Ribasim.pixi\qgis_env\profiles\default/python/plugins\ribasim_qgis\core\geopackage.py", line 86, in write_layer
raise RuntimeError(
RuntimeError: Layer Node could not be written to geopackage: C:\Users\X\ribasim_models\database.gpkg with error: Creation of data source failed (OGR error: A file system object called 'C:\Users\X\ribasim_models\database.gpkg' already exists.)

@deltamarnix deltamarnix added QGIS Ribasim QGIS plugin bug Indicates an unexpected problem or unintended behavior labels Aug 1, 2024
@Huite
Copy link
Contributor

Huite commented Aug 2, 2024

What would the desired behavior be in this case?

There's a basic inconsistency in the fact that the TOML has a unique name, but the created geopackage does not. So I think a user may reasonably expect there not to be a problem creating a new model with a new TOML name.

You can easily overwrite content with the newfile flag, but that's guaranteed to lead to unwanted deletion of data.

Alternatively, the plugin could create the TOML with a unique name at given location, automatically create an input_directory with the same name and place the database there.

At the least though, there should be a check and a QMessageBox popping up if it can't succesfully write everything.

evetion pushed a commit that referenced this issue Aug 27, 2024
An initial QGIS test plan for the plugin. There are still some tests to
be written.
I have also performed all these tests and created quite some new
reports.
There is also a known issues page for all of Ribasim, as we have some
things that simply don't work as expected.

New issues:

* #1678 
* #1679 
* #1681 
* #1682 
* #1683 
* #1684 
* #1685 
* #1688 
* #1689 
* #1690 

Fixes #320

---------

Co-authored-by: Martijn Visser <mgvisser@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior QGIS Ribasim QGIS plugin
Projects
Status: To do
Development

No branches or pull requests

2 participants