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

Database disk image is malformed #1973

Open
visr opened this issue Dec 12, 2024 · 1 comment
Open

Database disk image is malformed #1973

visr opened this issue Dec 12, 2024 · 1 comment
Labels
python Relates to one of the Ribasim python packages

Comments

@visr
Copy link
Member

visr commented Dec 12, 2024

Locally I cannot run pixi run generate-testmodels. It tends to fail on basic or basic_arrow. I have no idea why this started happening now. It looks like self.filepath = filepath during model.write is triggering the reading of the database, which doesn't look desirable.

Sometimes can be reproduced by

import ribasim_testmodels
model = ribasim_testmodels.basic_model()
model.write("d:/temp/model/trivial.toml")
Pixi task (generate-testmodels in dev): python utils/generate-testmodels.py
Generating allocation_training
Generating allocation_example
Generating backwater
Generating basic_arrow
Generating basic
Traceback (most recent call last):
  File "A:\repo\ribasim\Ribasim\utils\generate-testmodels.py", line 49, in <module>
    model.write(datadir / model_name / "ribasim.toml")
  File "A:\repo\ribasim\Ribasim\python\ribasim\ribasim\model.py", line 307, in write
    self.filepath = filepath
    ^^^^^^^^^^^^^
  File "A:\repo\ribasim\Ribasim\.pixi\envs\dev\Lib\site-packages\pydantic\main.py", line 923, in __setattr__
    self.__pydantic_validator__.validate_assignment(self, name, value)
  File "A:\repo\ribasim\Ribasim\python\ribasim\ribasim\model.py", line 129, in _ensure_edge_table_is_present
    self.edge.df = self.edge.df.set_geometry("geometry", crs=self.crs)
    ^^^^^^^^^^^^
  File "A:\repo\ribasim\Ribasim\.pixi\envs\dev\Lib\site-packages\pydantic\main.py", line 923, in __setattr__
    self.__pydantic_validator__.validate_assignment(self, name, value)
  File "A:\repo\ribasim\Ribasim\python\ribasim\ribasim\input_base.py", line 121, in _check_filepath
    data = cls._load(filepath)
           ^^^^^^^^^^^^^^^^^^^
  File "A:\repo\ribasim\Ribasim\python\ribasim\ribasim\input_base.py", line 240, in _load
    ddf = cls._from_db(db, cls.tablename())
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "A:\repo\ribasim\Ribasim\python\ribasim\ribasim\input_base.py", line 378, in _from_db
    if exists(connection, table):
       ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "A:\repo\ribasim\Ribasim\python\ribasim\ribasim\db_utils.py", line 15, in exists
    cursor.execute(
sqlite3.DatabaseError: database disk image is malformed
@visr visr added the python Relates to one of the Ribasim python packages label Dec 12, 2024
@github-project-automation github-project-automation bot moved this to To do in Ribasim Dec 12, 2024
@visr
Copy link
Member Author

visr commented Dec 12, 2024

Nevermind, whilst working on an issue I guess I bricked a model database. Removing generated_testmodels\* fixed this. Keeping this open to discuss if we want to trigger this code on self.filepath = filepath.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Relates to one of the Ribasim python packages
Projects
Status: To do
Development

No branches or pull requests

1 participant