Skip to content

Commit

Permalink
AIDE v1 detection for branch replacement prep.
Browse files Browse the repository at this point in the history
  • Loading branch information
bkellenb committed Aug 17, 2020
1 parent cc27a1b commit 4718bfb
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 5 deletions.
57 changes: 53 additions & 4 deletions application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion constants/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
2020 Benjamin Kellenberger
'''

AIDE_VERSION = '1.8.200717'
AIDE_VERSION = '1.8.200817'

0 comments on commit 4718bfb

Please sign in to comment.