IBM / dse-decision-optimization-utilities

A Python package with various utilities that speed-up development of Decision Optimization projects in Watson Studio. Implements common tasks and provides best-practice guidelines to architect DO projects.
Apache License 2.0
4 stars 7 forks source link

ScenarioDbManager support for SQLAlchemy 2.0 #55

Closed victorterpstra closed 3 months ago

victorterpstra commented 1 year ago

Using SQLAlchemy 1.4, set the future=True when creating an engine. This will add checks to ensure the usage of SQLAlchemy will be compatible with v2.0.

victorterpstra commented 1 year ago

Open issue: When duplicating or renaming a scenario from the dashboard we get this type of warning: "SELECT statement has a cartesian product between FROM element(s) "PHARMA_ASCM_TEST.scenario" and FROM element "PHARMA_ASCM_TEST.kpis". Apply join condition(s) between each element to resolve." See also: https://docs.sqlalchemy.org/en/14/changelog/migration_14.html#built-in-from-linting-will-warn-for-any-potential-cartesian-products-in-a-select-statement https://moserei.de/2020/01/02/sqlalchemy-prevent-implicit-cross-join.html https://www.reddit.com/r/flask/comments/ufxjuh/sqlalchemy_join_query_cartesian_product_warning/

Warning is probably caused within _duplicate_scenario_in_db_sql: select_sql = (sqlalchemy.select(select_columns).where(sqlalchemy.and_(t.c.scenario_seq == source_scenario_seq, s.c.scenario_seq == new_scenario_seq)))

victorterpstra commented 1 year ago

Note: for future=True, Pandas need to be upgraded to v1.4

victorterpstra commented 3 months ago

Implemented and tested extensively in v0.5.6. From v0.5.7 Future = True will be the default