Skip to content

Commit 7b9cb33

Browse files
authored
Clean plugins (#3403)
* Update CHANGELOG.md * clean plugins * patch 54.sql * fix Internal Qiita jobs * sample_template.generate_files * rm extra filepath * qiita.filepath_filepath_id_seq * basedir_len * basedir_len * 2 * basedir_len * 3 * get_db_files_base_dir * address @charles-cowart comment
1 parent 748126a commit 7b9cb33

Some content is hidden

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

132 files changed

+6815
-7449
lines changed

.github/workflows/qiita-ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,6 @@ jobs:
154154
155155
echo "5. Setting up qiita"
156156
conda activate qiita
157-
# adapt environment_script for private qiita plugins from travis to github actions.
158-
sed 's#export PATH="/home/travis/miniconda3/bin:$PATH"; source #source /home/runner/.profile; conda #' -i qiita_db/support_files/patches/54.sql
159157
qiita-env make --no-load-ontologies
160158
qiita-test-install
161159
qiita plugins update

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: 20 additions & 24 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,16 @@ 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
283+
else:
284+
raise
278285
qdb.sql_connection.TRN.close()
279286

280287
if is_test_environment:
@@ -369,10 +376,6 @@ def patch(patches_dir=PATCHES_DIR, verbose=False, test=False):
369376
Pulls the current patch from the settings table and applies all subsequent
370377
patches found in the patches directory.
371378
"""
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
376379
with qdb.sql_connection.TRN:
377380
qdb.sql_connection.TRN.add("SELECT current_patch FROM settings")
378381
current_patch = qdb.sql_connection.TRN.execute_fetchlast()
@@ -389,36 +392,31 @@ def patch(patches_dir=PATCHES_DIR, verbose=False, test=False):
389392
else:
390393
next_patch_index = sql_patch_files.index(current_sql_patch_fp) + 1
391394

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

399+
patch_update_sql = "UPDATE settings SET current_patch = %s"
394400
for sql_patch_fp in sql_patch_files[next_patch_index:]:
395401
sql_patch_filename = basename(sql_patch_fp)
396402

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()
403+
patch_prefix = splitext(basename(sql_patch_fp))[0]
404+
py_patch_fp = corresponding_py_patch(f'{patch_prefix}.py')
407405

408406
with qdb.sql_connection.TRN:
409407
with open(sql_patch_fp, newline=None) as patch_file:
410408
if verbose:
411409
print('\tApplying patch %s...' % sql_patch_filename)
410+
412411
qdb.sql_connection.TRN.add(patch_file.read())
413412
qdb.sql_connection.TRN.add(
414413
patch_update_sql, [sql_patch_filename])
415-
416414
qdb.sql_connection.TRN.execute()
417415

418416
if exists(py_patch_fp):
419417
if verbose:
420418
print('\t\tApplying python patch %s...'
421-
% py_patch_filename)
419+
% basename(py_patch_fp))
422420
with open(py_patch_fp) as py_patch:
423421
exec(py_patch.read(), globals())
424422

@@ -427,7 +425,5 @@ def patch(patches_dir=PATCHES_DIR, verbose=False, test=False):
427425
# for the test Study (1) so a lot of the tests actually expect this.
428426
# Now, trying to regenerate directly in the populate_test_db might
429427
# require too many dev hours so the easiest is just do it here
430-
# UPDATE 01/25/2021: moving to 81.sql as we added timestamps to
431-
# prep info files
432-
if test and sql_patch_filename == '81.sql':
433-
qdb.study.Study(1).sample_template.generate_files()
428+
if test:
429+
qdb.study.Study(1).sample_template.generate_files()

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.

0 commit comments

Comments
 (0)