Skip to content

Commit

Permalink
Upgrade SQLAlchemy to version 2 (#3734)
Browse files Browse the repository at this point in the history
This is part of supporting Python 3.13 (PR #3646), as a prereq to
upgrading pandas.

# Changed Behaviour

Development environments (which have the requirements in
`test-requirements.txt` installed) will break and need `pip uninstall
sqlalchemy2-stubs` - sqlalchemy packaging does not express a
negative/removal requirement against that transitional package.

non-parsl user code which happens to use the parsl-installed sqlalchemy
might break - for example, see API changes in the test suite in this PR

## Type of change

- Code maintenance/cleanup
  • Loading branch information
benclifford authored Jan 6, 2025
1 parent ed80dad commit a325590
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion parsl/monitoring/db_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(self,

def _get_mapper(self, table_obj: Table) -> Mapper:
all_mappers: Set[Mapper] = set()
for mapper_registry in mapperlib._all_registries(): # type: ignore[attr-defined]
for mapper_registry in mapperlib._all_registries():
all_mappers.update(mapper_registry.mappers)
mapper_gen = (
mapper for mapper in all_mappers
Expand Down
4 changes: 2 additions & 2 deletions parsl/tests/test_monitoring/test_app_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_app_name(get_app, expected_name, expected_result, tmpd_cwd):
with engine.begin() as connection:

def count_rows(table: str):
result = connection.execute(f"SELECT COUNT(*) FROM {table}")
result = connection.execute(sqlalchemy.text(f"SELECT COUNT(*) FROM {table}"))
(c, ) = result.first()
return c

Expand All @@ -81,6 +81,6 @@ def count_rows(table: str):
assert count_rows("try") == 1

# ... and has the expected name.
result = connection.execute("SELECT task_func_name FROM task")
result = connection.execute(sqlalchemy.text("SELECT task_func_name FROM task"))
(c, ) = result.first()
assert c == expected_name
4 changes: 2 additions & 2 deletions parsl/tests/test_monitoring/test_stdouterr.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_stdstream_to_monitoring(stdx, expected_stdx, stream, tmpd_cwd, caplog):
with engine.begin() as connection:

def count_rows(table: str):
result = connection.execute(f"SELECT COUNT(*) FROM {table}")
result = connection.execute(sqlalchemy.text(f"SELECT COUNT(*) FROM {table}"))
(c, ) = result.first()
return c

Expand All @@ -120,7 +120,7 @@ def count_rows(table: str):
assert count_rows("try") == 1

# ... and has the expected name.
result = connection.execute(f"SELECT task_{stream} FROM task")
result = connection.execute(sqlalchemy.text(f"SELECT task_{stream} FROM task"))
(c, ) = result.first()

if isinstance(expected_stdx, str):
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

extras_require = {
'monitoring' : [
'sqlalchemy>=1.4,<2'
# sqlalchemy does not use semantic versioning.
# see https://github.com/sqlalchemy/sqlalchemy/discussions/11391#discussioncomment-9472033
'sqlalchemy>=2,<2.1'
],
'visualization' : [
# this pydot bound is copied from networkx's pyproject.toml,
Expand Down
3 changes: 1 addition & 2 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ mpi4py
# sqlalchemy is needed for typechecking, so it's here
# as well as at runtime for optional monitoring execution
# (where it's specified in setup.py)
sqlalchemy>=1.4,<2
sqlalchemy2-stubs
sqlalchemy>=2,<2.1

Sphinx==4.5.0
twine
Expand Down

0 comments on commit a325590

Please sign in to comment.