Skip to content

fix(session): load and save data variables with function-based adapters - #150

Draft
ehennestad wants to merge 1 commit into
variable-descriptions-csv-copies-and-session-objectsfrom
function-based-adapters-for-variables
Draft

ehennestad wants to merge 1 commit into
variable-descriptions-csv-copies-and-session-objectsfrom
function-based-adapters-for-variables

Conversation

@ehennestad

@ehennestad ehennestad commented Sep 19, 2026 •

Copy link
Copy Markdown
Collaborator

Mechanism

A function-based file adapter, such as MatFile of the core module, is a folder with fileadapter.json and read and write functions. nansen.load wraps it in DynamicFileAdapter, and listFileAdapters lists it with IsDynamic true.

Problem

VariableModel.updateVariableDataType obtained a variable's data type by constructing the adapter class, which fails for a folder, so a variable with such an adapter could not be added. Session.getFileAdapterFcn called the folder's package name as a function. DynamicFileAdapter.writeData did not accept the variable name that FileAdapter.save passes, so Session.saveData failed with "Too many input arguments". The DSM converter gives every .mat pattern the first adapter that lists .mat, which is MatFile.

Changes

  • updateVariableDataType and updateDefaultValues read DataType from the adapter list, which takes it from fileadapter.json.
  • Session.getFileAdapterFcn returns a DynamicFileAdapter constructor for a function-based adapter. DynamicFileAdapter.readData and writeData accept the arguments that FileAdapter.load and save pass on.
  • Tests: FunctionBasedFileAdapterTest (data type, load, save).

🤖 Generated with Claude Code

A function-based file adapter, such as MatFile of the core module, is
a folder with a fileadapter.json and read and write functions, not a
class. VariableModel.updateVariableDataType got a variable's data type
by creating the adapter class, so adding a variable with such an
adapter failed, and Session.loadData called the folder's package name
as a function. The DSM converter gives a .mat file pattern the first
adapter that lists .mat, which is MatFile.

The data type now comes from the adapter list, which reads it from
fileadapter.json. Session wraps a function-based adapter in
DynamicFileAdapter, as nansen.load does. DynamicFileAdapter.readData
and writeData accept the variable name that FileAdapter.load and save
pass on, so Session.saveData no longer fails with "Too many input
arguments".

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ehennestad
ehennestad added this pull request to stack #122 September 19, 2026 16:41
@ehennestad ehennestad changed the title function based adapters for variables fix(session): load and save data variables with function-based adapters Sep 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

447 tests   447 ✅  1m 21s ⏱️
 40 suites    0 💤
  1 files      0 ❌

Results for commit 1e9259e.

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