aiida-core icon indicating copy to clipboard operation
aiida-core copied to clipboard

Directory and inheritance structure of storage backends

Open GeigerJ2 opened this issue 1 year ago • 1 comments

As noted with @rabbull, all ORM entities for the SQLite backends are contained in storage/sqlite_zip/orm.py, while the other SQLite-based storage backends then import from there, e.g.:

https://github.com/aiidateam/aiida-core/blob/dd866ce816e986285f2c5794f431b6e3c68a369b/src/aiida/storage/sqlite_dos/backend.py#L33

While it's not critical, functionality-wise, we could still consider a refactor, as it's a bit confusing that everything sqlite ORM related is contained under sqlite_zip, while sqlite_dos and sqlite_temp are actually implemented in directories at the same level, so one would expect those to stand on equal footing.

Similarly, I wouldn't actually have expected the SqliteDosStorage to inherit from PsqlDosBackend, but rather both of them to have a common parent class, or using composition? Wondering if there was a reason for this structure when the SqliteDosStorage was implemented in #6148. I guess this is mainly historical? Pinging also @unkcpz preaching "composition over inheritance" :D

TODOs:

  • [ ] Move ORM entities for SQLite out of storage/sqlite_zip/orm.py into a shared location
  • [ ] Remove inheritance of SqliteDosStorage from PsqlDosBackend
  • [ ] Move SQLAQueryBuilder out of storage/psql_dos so that SqliteQueryBuilder does not inherit from something in psql_dos (again)

GeigerJ2 avatar Nov 12 '24 15:11 GeigerJ2