Repository navigation
Upgrade to SQLAlchemy 1.4 and dynamicannotationdb 5.15.1 - #281
Merged
Merged
Conversation
dynamicannotationdb 5.15.x requires SQLAlchemy >= 1.4, so the pin moves from <1.4 to >=1.4,<2. The lock also moves geoalchemy2 0.11.1 -> 0.21.0 and emannotationschemas 5.25.1 -> 5.26.3. Changes needed for 1.4: - query_manager: import DeclarativeMeta from sqlalchemy.orm; the sqlalchemy.ext.declarative.api module was removed. - Dialect.has_table() needs a Connection, not an Engine: use inspect(engine).has_table() at the four call sites. - index_manager: 1.4 reports dialect_options for every index on PostgreSQL 11+, so classify an index by its access method. - update_table_metadata: read the version id with .scalar(); a Row is no longer a tuple and psycopg2 cannot adapt it as a parameter. - QueryManager: convert the desired_resolution ratio with float(). 1.4 rendered the numpy float through the integer cast's int(), so 0.5 became 0 and positions came back wrong with a 200. - find_ids_with_specified_roots: compile with literal_binds. 1.4 leaves an IN list as a placeholder in the stringified statement. - DevConfig: postgresql://, since 1.4 rejects the postgres:// scheme. Tests cover the desired_resolution scaling and the root-id statements. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The ubuntu-latest runner is now Ubuntu 26.04, whose pg_dump emits "SET transaction_timeout", which the PostgreSQL 13 service rejects. That failed test_clustered_staging_table_transfers_in_id_order: the transfer copied 0 rows. Move the CI service, and the image the tests' --docker mode starts, from postgis/postgis:13-master to postgis/postgis:18-3.6. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Five test modules need a real redis on localhost:6390 and skip without it, so CI was skipping 53 tests. Add a redis:7 service on that port. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.
Moves MaterializationEngine from SQLAlchemy 1.3.24 to 1.4.54 so it can take
dynamicannotationdb5.15.1, which requires SQLAlchemy >= 1.4.Deploy dependency
Merge and deploy CAVEconnectome/cave-helm-charts#20 first. The chart sets
SQLALCHEMY_DATABASE_URItopostgres://..., and SQLAlchemy 1.4 rejects that scheme (NoSuchModuleError). This PR does not normalise the scheme in code, so with the current chart every database connection would fail. The test suite cannot see this because the test config usespostgresql://.Dependency changes
sqlalchemydynamicannotationdbgeoalchemy2emannotationschemasThe last two are pulled in by the first two, not chosen here.
Code changes
Found by the existing tests:
sqlalchemy.ext.declarative.apino longer exists;query_manager.pyimportsDeclarativeMetafromsqlalchemy.orm.Dialect.has_table()needs aConnection. Four call sites passed anEngine; they now useinspect(engine).has_table().dialect_optionsfor every index on PostgreSQL 11+ ({"postgresql_include": []}), soindex_manager.get_table_indicesleft plain indexes without atype. It now classifies by access method.update_table_metadatapassed a.first()result asanalysisversion_id. A 1.4Rowis not a tuple, so psycopg2 cannot adapt it; it now uses.scalar().Not caught by the existing tests:
desired_resolutionreturned wrong positions with HTTP 200.QueryManagermultiplies an integer cast by a numpy float. 1.4 rendered that literal throughint(), so a 0.5 ratio became 0 and 2.5 became 2. Fixed withfloat().find_ids_with_specified_rootsproduced invalid SQL. It stringified anINquery withoutliteral_binds, which on 1.4 leavesIN (__[POSTCOMPILE_...])in the text.DevConfigusedpostgres://.Tests
TestQueryDesiredResolutionqueries the frozen endpoint at 0.5x, 2.5x and 4x the table resolution on both fetch paths and checks every position column.TestFindIdsWithSpecifiedRootsexecutes the returned statements and checks they select the rows with those root ids.Both fail on 1.4 without their fix. Both also pass against unmodified
masteron 1.3, so they describe existing behaviour.Full suite locally (macOS, PostGIS 18): 905 passed, 2 skipped on 1.4.
masteron 1.3 was 898 passed, 2 skipped before these tests were added.CI
CI now runs against
postgis/postgis:18-3.6instead of13-master(second commit).ubuntu-latestis now Ubuntu 26.04, whosepg_dumpemitsSET transaction_timeout; the PostgreSQL 13 service rejected it, sotest_clustered_staging_table_transfers_in_id_ordercopied 0 rows and failed. This is independent of the SQLAlchemy change and would fail onmastertoo.tests/test_data/mat_metadata.json(the image the tests'--dockermode starts) is changed to match.CI also gets a
redis:7service on port 6390 (third commit). Five test modules need a real redis there and skip without it, so CI had been skipping 55 tests; it now runs all of them: 907 passed, 0 skipped.How this was checked beyond the suite
QueryManagerwas driven offline in both versions across 30 scenarios (live and frozen modes, reference joins, suffixes, spatial filters, sampling). The generated SQL is identical apart from thedesired_resolutioncase fixed here, an equivalent rewrite of emptyIN, andfilter_out_dictwith a list, which is invalid SQL on 1.3 as well.desired_resolution.Not addressed
INlists astext(), so worker memory may grow. Not measured on real workloads.user_idcolumn type. From theemannotationschemasdiff, a few schemas'user_idfields now map toBigIntegerinstead ofInteger. The effect on existing tables and result dtypes was not tested.RemovedIn20Warningfor raw-stringexecute,Row.keys(),from_selfand legacyselect([...]). None break on 1.4.🤖 Generated with Claude Code