Skip to content

fix: support projects whose session and subject tables have their own classes - #145

Draft
ehennestad wants to merge 6 commits into
devfrom
fixes-for-projects-with-own-table-classes
Draft

ehennestad wants to merge 6 commits into
devfrom
fixes-for-projects-with-own-table-classes

Conversation

@ehennestad

Copy link
Copy Markdown
Collaborator

Mechanism

A project can give its session and subject tables a subclass of nansen.metadata.type.Session or Subject with extra columns. The table records the class in MetaTableClass and takes its ID column name from the class's IDNAME when MetaTableIdVarname is empty. MetaTableCache returns a cached table when the file's version number is not newer.

Problem

Failures in projects with subclassed tables:

  • A data location without a root path stopped session construction with "Array indices must be positive integers".
  • Registering a table under the file name of an earlier one returned the stale cached object, whose version number equalled the new file's, and saved it back.
  • detectNewSessions and updateSubjectTable created base-class objects, so adding them to a subclassed table failed in vertcat.
  • The app created a new subject table on every start unless the class was exactly nansen.metadata.type.Subject, overwriting the project's own table, which has the same default file name.
  • A table whose class is not on the path failed with "Unrecognized table variable name 'id'".

Changes

  • Session.refreshDataLocations skips a data location whose root path list is empty.
  • MetaTableCatalog.registerMetaTable adds the registered table to MetaTableCache after saving it.
  • updateSubjectTable creates subjects of the table's MetaTableClass and assigns IDs to the new subjects only; detectNewSessions creates sessions with str2func(metaTable.MetaTableClass).
  • Add MetaTableCatalog.hasMasterMetaTable(typeName), which applies the rule of getMasterMetaTable; App.checkIfSubjectTableExists uses it.
  • MetaTable.fromFileStruct raises NANSEN:MetaTable:ClassNotFound, naming the class, when the file stores no ID column name and the class is not on the path.
  • Tests: SessionDataLocationTest, three in MetaTableTest, UpdateSubjectTableTest, DetectNewSessionsTest, with the helpers LabeledSubject and LabeledSession.

🤖 Generated with Claude Code

ehennestad and others added 6 commits September 19, 2026 17:59
…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>
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

380 tests  +11   380 ✅ +11   52s ⏱️ +25s
 28 suites + 3     0 💤 ± 0 
  1 files   ± 0     0 ❌ ± 0 

Results for commit 122c6ab. ± Comparison against base commit d8ee8c3.

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.

1 participant