diff --git a/application.py b/application.py index 9183e010..48fa28d6 100644 --- a/application.py +++ b/application.py @@ -12,7 +12,7 @@ from bottle import Bottle from setup.migrate_aide import migrate_aide from util.configDef import Config -from modules import REGISTERED_MODULES +from modules import REGISTERED_MODULES, Database from constants.version import AIDE_VERSION def _verify_unique(instances, moduleClass): @@ -26,6 +26,58 @@ def _verify_unique(instances, moduleClass): if moduleClass.__class__.__name__ == instance.__class__.__name__: raise Exception('Module {} already launched on this server.'.format(moduleClass.__class__.__name__)) +# load configuration +config = Config() + +# check if config file points to unmigrated v1 project +dbConnector = Database(config) +hasAdminTable = dbConnector.execute(''' + SELECT EXISTS ( + SELECT FROM information_schema.tables + WHERE table_schema = 'aide_admin' + AND table_name = 'project' + ); + ''', None, 1) +if not hasAdminTable[0]['exists']: + # not (yet) migrated, raise Exception with instructions to ensure compatibility + print(f''' +The current installation of AIDE: + database host: {config.getProperty('Database', 'host')} + database name: {config.getProperty('Database', 'name')} + schema: {config.getProperty('Database', 'schema', str, '(not specified)')} + +points to an installation of the legacy AIDE v1. +If you wish to continue using AIDE v2, you have to upgrade the project accordingly. +For instructions to do so, see here: + https://github.com/microsoft/aerial_wildlife_detection/blob/multiProject/doc/upgrade_from_v1.md + ''') + import sys + sys.exit(1) + +# check if project has been migrated +dbSchema = config.getProperty('Database', 'schema', str, None) +if dbSchema is not None: + isMigrated = dbConnector.execute(''' + SELECT COUNT(*) AS cnt + FROM aide_admin.project + WHERE shortname = %s; + ''', (dbSchema,), 1) + if isMigrated is not None and len(isMigrated) and isMigrated[0]['cnt'] == 0: + print(f''' +WARNING: the selected configuration .ini file +("{os.environ['AIDE_CONFIG_PATH']}") +points to a project that has not yet been migrated to AIDE v2. +Details: + database host: {config.getProperty('Database', 'host')} + database name: {config.getProperty('Database', 'name')} + schema: {dbSchema} + +If you wish to continue using AIDE v2 for this project, you have to upgrade it +to v2 accordingly. +For instructions to do so, see here: + https://github.com/microsoft/aerial_wildlife_detection/blob/multiProject/doc/upgrade_from_v1.md + ''') + # bring AIDE up-to-date warnings, errors = migrate_aide() if len(warnings) or len(errors): @@ -38,9 +90,6 @@ def _verify_unique(instances, moduleClass): for e in errors: print(f'\t"{e}"') -# load configuration -config = Config() - # prepare bottle app = Bottle() diff --git a/constants/version.py b/constants/version.py index d6dacc71..c749dc83 100644 --- a/constants/version.py +++ b/constants/version.py @@ -10,4 +10,4 @@ 2020 Benjamin Kellenberger ''' -AIDE_VERSION = '1.8.200717' \ No newline at end of file +AIDE_VERSION = '1.8.200817' \ No newline at end of file