Skip to content

Conversation

@Tasqu
Copy link
Member

@Tasqu Tasqu commented Dec 29, 2025

Since Spine-DB-API and SpineOpt both support and aim to use "superclasses" and "compound classes", SpineInterface needs to support them as well. Unfortunately, "true" implementation would have required deep renovations of SpineInterface structures, which I couldn't pull off without demolishing a lot of code optimization by @manuelma, essentially murdering the performance and usability of SpineInterface. Thus, I had to implement "pseudo-compound-classes" to replicate the required functionality with minimal impacts to performance critical parts of the code.

In essence, superclasses function similar enough to their Spine-DB-API counterparts:

  • They contain a list of their subclasses, but hold no entities of their own (I don't think I actually enforced this in SpineInterface, though?)
  • When a superclass is called, that call gets passed to its subclasses, their output is merged, and finally returned.

However, "pseudo-compound-classes" work quite differently to their Spine-DB-API counterparts:

  • SpineInterface doesn't allow EntityClasses as dimensions of EntityClasses, so instead:
  • The original compound class gets converted into a superclass.
  • A set of automatically generated subclasses are generated for every possible combination of dimensions (named <superclass_name>__<byclass1>__<byclass2>__...)
  • This replicates the functionality of a compound-class, but not its structure.

Considerations:

  • You might not be able to write superclasses into a Spine DB correctly, as I didn't really test this as it wasn't required for SpineOpt.
  • You definitely can't write "pseudo-compound-classes" into a Spine DB correctly, as they are handled differently in SpineInterface.

Fixes #139

Checklist before merging

  • Documentation is up-to-date
  • Unit tests have been added/updated accordingly
  • Code has been formatted nicely
  • Unit tests pass
  • WILL NEED A VERSION BUMP POST-MERGE!

Tasqu and others added 25 commits March 19, 2025 14:51
ENTITY NAMES NEED TO BE UNIQUE!
Compound RelationshipClasses are separated from the rest, as they need to be treated separately and split into "subclasses"
Original unit tests pass.
Not all of the unit tests I designed for superclass functionality can work as intended with the current pseudo-structure, but at least SpineOpt performance shouold not drastically suffer.
Is this ultimately worth it? This function cannot fix e.g. parameter mappings. The correct place to do this would be in the database, but that's the problem isn't it?
I realized I didn't have to account for the `env_dict` and `_RelationshipClass` separately.
Still could be improved by disallowing `Symbol`, but that would require fixing convenience function generation to treat superclasses differently.
When `extend=true`, already resolved subclasses would be re-evaluated into `Nothing`
@Tasqu Tasqu self-assigned this Dec 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Compound classes" and "superclasses" not supported.

1 participant