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

Harmonizes SchemaConfig to a named block structure #89

Merged
merged 9 commits into from
Aug 13, 2024

Conversation

v0idness
Copy link
Member

@v0idness v0idness commented Aug 5, 2024

In the schema config, the changes in this PR remove the "name" property for schemas, fields, exporters, and extractionPipelines, and instead places the name as a key in a map. Addresses issue #80

Copy link
Member

@lucaro lucaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. One thing, though: the indirection of the schema name should be resolved more explicitly.

@@ -31,7 +31,8 @@ fun main(args: Array<String>) {

/* Setup schema manager. */
val manager = SchemaManager()
for (schema in config.schemas) {
for ((name, schema) in config.schemas) {
schema.name = name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic does not really belong here. It makes sense that the schema knows its own name, but that indirection should be resolved in the config object itself.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review! I understand your point. Would it be preferable to assign the name in the ServerConfig (during read) or in an extra step with a dedicated method in the SchemaConfig?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would make sense to have this inside an init block inside the schema config; then, it would also be called once this is deserialized.

@v0idness
Copy link
Member Author

v0idness commented Aug 8, 2024

I have trialed some different approaches; I don't love this approach but it is a bit of a tricky situation to know the name during the initial deserialization. I don't quite see how an init block would help, as then we might as well just pass the name to the constructor.

The other approach that was brought up would be in a similar manner to the initial approach - passing the name to SchemaManager:load as an additional parameter. Happy to hear your thoughts on this matter.

@v0idness
Copy link
Member Author

Kotlinx serializers cannot natively handle the case where a key from a map shall be unpacked into a class attribute in the way this config requires. The only workaround for that is by defining a custom SchemaSerializer, which seems both overkill and generates maintenance overhead for SchemaConfig. I propose this as a simpler alternative, with the name assignment handled by the SchemaManager (in my interpretation, that appears somewhat logical).

@lucaro lucaro self-requested a review August 13, 2024 08:19
@@ -20,15 +20,15 @@ import java.nio.file.Paths
@Serializable
data class SchemaConfig(
/** Name of the [Schema]. */
val name: String = "vitrivr",
var name: String = "vitrivr",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is probably still a nicer way to handle this that does not require this field to be publicly writable, but that can be looked at at a later date and should not prevent us from merging this in a timely fashion.

@ppanopticon ppanopticon merged commit c3895a8 into dev Aug 13, 2024
1 check passed
@lucaro lucaro deleted the feature/harmoniseconfig branch August 13, 2024 08:45
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.

3 participants