Skip to content

fix: build every schema right after login, so none needs dj.conn later - #59

Merged
tabedzki merged 3 commits into
mainfrom
t3/load-schemas-after-login
Dec 1, 2026
Merged

tabedzki merged 3 commits into
mainfrom
t3/load-schemas-after-login

Conversation

@tabedzki

@tabedzki tabedzki commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Fixes #54

Follows #51 (merged). Stacked on #58 (on #57) because all three add to the same test lists; merge those first.

Problem

#51 gets transaction connections from the table with tableConn(<table>) (table.schema.conn). But the first time a schema package is used, its U19-pipeline-matlab getSchema runs dj.Schema(dj.conn, ...). If dj.conn has lost the connect_tech login by then (#50), that first use fails with the same error:

Output argument "connObj" (and possibly others) not assigned a value in the execution with "dj.conn" function.

recording and recording_process load at startup. action first loads in createRecording, just before the surgery dialog. The paramset steps tables can first load in RegisterPreParamList when the params came from Python.

Fix

  • New repo-root helper loadSchemas(packages) calls each <package>.getSchema. The schema, along with the login's dj.Connection, then stays in that function's persistent.
  • configParams calls it right after connect_tech(), for every schema package the GUI uses: action, acquisition, lab, subject, recording, recording_process, pipeline_ephys_element, pipeline_imaging_element. No later table use, and no tableConn call, goes back to dj.conn.
  • loadSchemas catches each package on its own and warns with its name, so one schema that fails (say pipeline_imaging_element on an ephys rig) cannot stop the GUI from opening. That schema then loads on first use, as before.
  • Fallback for the case loading at startup can't cover: clear functions or clear all wipes the saved schemas along with dj.conn's login. tableConn then logs in again once with connect_tech and retries, so the write callbacks still get a connection. Checked against the DB: after clear functions, dj.conn() gives the reported error, and tableConn(action.Surgery) logs in again and returns a connected session that a transaction opens and cancels on.
  • Compiled build: loadSchemas is called directly from configParams, so dependency analysis packages it. It finds getSchema with feval, the same way dj.internal.Table/get.schema already does in the compiled build. That works because the .prj packages the whole U19-pipeline-matlab folder as a resource.
  • Startup cost: building a dj.Schema loads its table list from the server, which moves from first use to startup. startupFcn already loaded recording, recording_process, subject and lab (about 1.7 s). The four new ones add about 1.6 s, measured against the DB from this machine: action 0.4 s, acquisition 0.3 s, pipeline_ephys_element 0.4 s, pipeline_imaging_element 0.5 s.
  • tableConn.m and the GUI README no longer describe this as a known limitation. The README says the loadSchemas list in configParams is kept complete by hand; no test checks it. The vendored toolboxes are untouched, and the write callbacks' catch blocks (A failing rollback skips the rest of the write callbacks' error handling #55, A failed or skipped surgery registration still moves and registers the recording #56) are not changed.

Tests

  • New tests/TestLoadSchemas.m, added to CI, README and AGENTS.md. It needs no DB: the fixture package tests/fixtures/+djschemafixture has a U19-style getSchema, a loginConn that behaves like the vendored dj.conn (no output once its connection is gone), and an OfflineSchema that skips the table-list query.
    • firstUseAfterTheLoginIsLostFails reproduces tableConn still needs dj.conn the first time a schema is used #54: tableConn on a schema that has not been built yet throws MATLAB:unassignedOutputs.
    • loadedSchemaKeepsTheLogin and acceptsOnePackageName: after loadSchemas, tableConn returns the login's connection even after that login is gone.
    • failingPackageOnlyWarns: a package that fails gives loadSchemas:NotLoaded and the packages after it still load.
    • tableConnLogsInAgainOnce: with the login and the saved schema gone, tableConn calls its login function once and returns the new connection. Every test passes a stand-in for connect_tech.
  • All MATLAB suites pass (85 tests, with fix: never let a failed rollback skip the write callbacks' error handling #57 and fix: ask before registering a recording whose surgery was not registered #58), and test_jsonencodepretty passes. uvx prek run --all-files passes.
  • Read-only check against the DB, with U19-pipeline-matlab and modDataJoint on the path: connect_tech, loadSchemas with the eight packages, then clear conn. After that dj.conn() raises the reported error. A table from every package still counts its rows through the same connection, and a transaction opens and cancels on it.

Not tested: the GUI itself, or the compiled build, on a rig.

Assisted-by: ClaudeCode:claude-opus-5-5

@vrrigs
vrrigs force-pushed the t3/load-schemas-after-login branch from 0cac3d4 to e38c9a1 Compare December 1, 2026 20:53
@tabedzki
tabedzki changed the base branch from main to t3/confirm-surgery-registration December 1, 2026 20:53
tableConn takes the connection from table.schema, but the first use of a
schema package still goes through dj.conn: U19 getSchema builds
dj.Schema(dj.conn, ...). Once dj.conn has lost the connect_tech login
(#50), a schema first used after that (action at the surgery dialog, the
paramset steps tables in RegisterPreParamList) failed with 'Output
argument "connObj" ... not assigned'.

configParams now calls the new loadSchemas right after connect_tech, for
all eight schema packages the GUI uses. Each getSchema keeps its schema,
and so the login's connection, in its persistent.

TestLoadSchemas reproduces the failure with an offline fixture package,
checks that a loaded schema keeps the login, and checks that configParams
calls loadSchemas right after connect_tech with every package the GUI code
uses.

Fixes #54

Assisted-by: ClaudeCode:claude-opus-5-5
They regex-searched configParams and the GUI code for the loadSchemas call
and the schema names, so they broke on harmless rewording. The remaining
tests cover loadSchemas itself.

Assisted-by: ClaudeCode:claude-opus-5-5
…e login is lost

loadSchemas ran every getSchema outside any try, in the constructor, so one
schema that failed (say pipeline_imaging_element on an ephys rig) stopped
the GUI from opening. Each package now gets a warning naming it, and the
rest still load.

'clear functions' or 'clear all' wipes the getSchema persistents along with
dj.conn's login, so loading the schemas at startup does not help then.
tableConn now logs in again once with connect_tech when the schema cannot
be built because dj.conn has no login, and retries.

The README no longer says a test checks the loadSchemas list.

Assisted-by: ClaudeCode:claude-opus-5-5
@vrrigs
vrrigs force-pushed the t3/load-schemas-after-login branch from e38c9a1 to 1c38c1a Compare December 1, 2026 21:16
@tabedzki
tabedzki marked this pull request as ready for review December 1, 2026 21:58
Base automatically changed from t3/confirm-surgery-registration to main December 1, 2026 22:18
@tabedzki
tabedzki added this pull request to stack #62 December 1, 2026 22:19
@tabedzki
tabedzki merged commit 9cf9100 into main Dec 1, 2026
7 checks passed
@tabedzki
tabedzki deleted the t3/load-schemas-after-login branch December 1, 2026 22:19
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.

tableConn still needs dj.conn the first time a schema is used

1 participant