Repository navigation
fix: support projects whose session and subject tables have their own classes - #145
Draft
ehennestad wants to merge 6 commits into
Draft
ehennestad wants to merge 6 commits into
ehennestad wants to merge 6 commits into
Conversation
…roots A session resolves each of its data locations against the data location model and, when it has no root yet, takes the last root path of the model's item. A new project's default data locations have no root path until they are configured, so building a session in such a project failed with "Array indices must be positive integers or logical values" (seen when importing a Dataset Structure Model into a new project and creating its session table before configuring the default Processed location). A data location without a root path now leaves the session's RootUid empty, as for a session that has no folder in that location. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
MetaTable.open returns the cached table for a file when its in-memory version number equals the one in the file. Version numbers count the saves of one file, so after a master table is removed and a new one is registered under the same name, the new file can have the same number as the table opened before, and open returned the old table. A caller that then edited and saved it wrote the old entries over the new file (seen when re-importing a Dataset Structure Model into a project). registerMetaTable now puts the table it registers into the cache, replacing whatever was cached for that file. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
updateSubjectTable created the subjects it adds as nansen.metadata.type.Subject unless a class was passed. When the master subject table holds a subclass with more properties, the new rows lack those columns and MetaTable.addTable fails in vertcat. The app calls updateSubjectTable after detecting sessions, so detection failed in such projects. The default class is now the MetaTableClass of the subject table. The loop that sets subject IDs also runs over the new IDs only, instead of over every ID in the session table. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
detectNewSessions created every session it detects as nansen.metadata.type.Session. When the session table holds a subclass with more properties, the app could not add the detected sessions to the table: MetaTable.addTable failed in vertcat because the new rows lack the subclass columns. The sessions are now created with the MetaTableClass of the table that is passed in. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
On start, the app creates a subject table when checkIfSubjectTableExists returns false. The check compared class names with 'nansen.metadata.type.Subject' exactly, so a project whose subject table has a subclass got a new table on every start. Both tables have the default name "Subject" and the same file name, so the new table replaced the project's own. MetaTableCatalog.hasMasterMetaTable(typeName) matches master tables by the rule getMasterMetaTable uses, a case-insensitive substring of the class name, and the app's check calls it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… the path A MetaTable file saved without MetaTableIdVarname gets the name of its ID column from the IDNAME constant of its class. When that class is not on the path, SchemaIdName fell back to 'id', and loading failed with "Unrecognized table variable name 'id'". Loading such a file now fails with NANSEN:MetaTable:ClassNotFound, which names the class and says to add it to the path. Files that store MetaTableIdVarname, and tables of class 'table', load as before. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mechanism
A project can give its session and subject tables a subclass of
nansen.metadata.type.SessionorSubjectwith extra columns. The table records the class inMetaTableClassand takes its ID column name from the class'sIDNAMEwhenMetaTableIdVarnameis empty.MetaTableCachereturns a cached table when the file's version number is not newer.Problem
Failures in projects with subclassed tables:
detectNewSessionsandupdateSubjectTablecreated base-class objects, so adding them to a subclassed table failed invertcat.nansen.metadata.type.Subject, overwriting the project's own table, which has the same default file name.Changes
Session.refreshDataLocationsskips a data location whose root path list is empty.MetaTableCatalog.registerMetaTableadds the registered table toMetaTableCacheafter saving it.updateSubjectTablecreates subjects of the table'sMetaTableClassand assigns IDs to the new subjects only;detectNewSessionscreates sessions withstr2func(metaTable.MetaTableClass).MetaTableCatalog.hasMasterMetaTable(typeName), which applies the rule ofgetMasterMetaTable;App.checkIfSubjectTableExistsuses it.MetaTable.fromFileStructraisesNANSEN:MetaTable:ClassNotFound, naming the class, when the file stores no ID column name and the class is not on the path.SessionDataLocationTest, three inMetaTableTest,UpdateSubjectTableTest,DetectNewSessionsTest, with the helpersLabeledSubjectandLabeledSession.🤖 Generated with Claude Code