Skip to content

Commit c98b32e

Browse files
committed
clean plugins
1 parent 8edd0c8 commit c98b32e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+6806
-7441
lines changed

qiita_db/artifact.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def create(cls, filepaths, artifact_type, name=None, prep_template=None,
359359
# There are three different ways of creating an Artifact, but all of
360360
# them execute a set of common operations. Declare functions to avoid
361361
# code duplication. These functions should not be used outside of the
362-
# create function, hence declaring them here
362+
# CREATE OR REPLACE FUNCTION, hence declaring them here
363363
def _common_creation_steps(atype, cmd_id, data_type, cmd_parameters):
364364
gen_timestamp = datetime.now()
365365
visibility_id = qdb.util.convert_to_id("sandbox", "visibility")

qiita_db/environment_manager.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ def make_environment(load_ontologies, download_reference, add_demo_user):
200200
with open(SETTINGS_FP, newline=None) as f:
201201
qdb.sql_connection.TRN.add(f.read())
202202
qdb.sql_connection.TRN.execute()
203-
204203
# Insert the settings values to the database
205204
sql = """INSERT INTO settings
206205
(test, base_data_dir, base_work_dir)
@@ -211,7 +210,6 @@ def make_environment(load_ontologies, download_reference, add_demo_user):
211210
qiita_config.working_dir])
212211
qdb.sql_connection.TRN.execute()
213212
create_layout(test=test, verbose=verbose)
214-
215213
patch(verbose=verbose, test=test)
216214

217215
if load_ontologies:
@@ -274,7 +272,14 @@ def drop_environment(ask_for_confirmation):
274272
# Connect to the postgres server
275273
with qdb.sql_connection.TRN:
276274
qdb.sql_connection.TRN.add("SELECT test FROM settings")
277-
is_test_environment = qdb.sql_connection.TRN.execute_fetchflatten()[0]
275+
try:
276+
is_test_environment = \
277+
qdb.sql_connection.TRN.execute_fetchflatten()[0]
278+
except ValueError as e:
279+
# if settings doesn't exist then is fine to treat this as a test
280+
# environment and clean up
281+
if 'UNDEFINED_TABLE. MSG: relation "settings"' in str(e):
282+
is_test_environment = True
278283
qdb.sql_connection.TRN.close()
279284

280285
if is_test_environment:
@@ -369,10 +374,6 @@ def patch(patches_dir=PATCHES_DIR, verbose=False, test=False):
369374
Pulls the current patch from the settings table and applies all subsequent
370375
patches found in the patches directory.
371376
"""
372-
# we are going to open and close 2 main transactions; this is a required
373-
# change since patch 68.sql where we transition to jsonb for all info
374-
# files. The 2 main transitions are: (1) get the current settings,
375-
# (2) each patch in their independent transaction
376377
with qdb.sql_connection.TRN:
377378
qdb.sql_connection.TRN.add("SELECT current_patch FROM settings")
378379
current_patch = qdb.sql_connection.TRN.execute_fetchlast()
@@ -389,36 +390,31 @@ def patch(patches_dir=PATCHES_DIR, verbose=False, test=False):
389390
else:
390391
next_patch_index = sql_patch_files.index(current_sql_patch_fp) + 1
391392

392-
patch_update_sql = "UPDATE settings SET current_patch = %s"
393+
if test:
394+
with qdb.sql_connection.TRN:
395+
_populate_test_db()
393396

397+
patch_update_sql = "UPDATE settings SET current_patch = %s"
394398
for sql_patch_fp in sql_patch_files[next_patch_index:]:
395399
sql_patch_filename = basename(sql_patch_fp)
396400

397-
py_patch_fp = corresponding_py_patch(
398-
splitext(basename(sql_patch_fp))[0] + '.py')
399-
py_patch_filename = basename(py_patch_fp)
400-
401-
# patch 43.sql is when we started testing patches, then in patch
402-
# 68.sql is when we transitioned to jsonb for the info files; let's do
403-
# this in its own transition
404-
if sql_patch_filename == '68.sql' and test:
405-
with qdb.sql_connection.TRN:
406-
_populate_test_db()
401+
patch_prefix = splitext(basename(sql_patch_fp))[0]
402+
py_patch_fp = corresponding_py_patch(f'{patch_prefix}.py')
407403

408404
with qdb.sql_connection.TRN:
409405
with open(sql_patch_fp, newline=None) as patch_file:
410406
if verbose:
411407
print('\tApplying patch %s...' % sql_patch_filename)
408+
412409
qdb.sql_connection.TRN.add(patch_file.read())
413410
qdb.sql_connection.TRN.add(
414411
patch_update_sql, [sql_patch_filename])
415-
416412
qdb.sql_connection.TRN.execute()
417413

418414
if exists(py_patch_fp):
419415
if verbose:
420416
print('\t\tApplying python patch %s...'
421-
% py_patch_filename)
417+
% basename(py_patch_fp))
422418
with open(py_patch_fp) as py_patch:
423419
exec(py_patch.read(), globals())
424420

qiita_db/support_files/patches/0.sql

Lines changed: 0 additions & 61 deletions
This file was deleted.

qiita_db/support_files/patches/1.sql

Lines changed: 0 additions & 49 deletions
This file was deleted.

qiita_db/support_files/patches/10.sql

Lines changed: 0 additions & 9 deletions
This file was deleted.

qiita_db/support_files/patches/11.sql

Lines changed: 0 additions & 49 deletions
This file was deleted.

qiita_db/support_files/patches/12.sql

Lines changed: 0 additions & 8 deletions
This file was deleted.

qiita_db/support_files/patches/13.sql

Lines changed: 0 additions & 3 deletions
This file was deleted.

qiita_db/support_files/patches/14.sql

Lines changed: 0 additions & 4 deletions
This file was deleted.

qiita_db/support_files/patches/15.sql

Lines changed: 0 additions & 4 deletions
This file was deleted.

qiita_db/support_files/patches/16.sql

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)