Skip to content

Commit 2a2cce7

Browse files
author
Tomasz
authored
Merge pull request #2543 from antgonza/split-qiita-cron-job
split qiita cron job
2 parents 9f7e186 + 59b9bcb commit 2a2cce7

File tree

3 files changed

+53
-21
lines changed

3 files changed

+53
-21
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ script:
7373
- nosetests $COVER_PACKAGE --with-doctest --with-coverage --with-timer -v --cover-package=$COVER_PACKAGE
7474
- kill $QIITA_PID
7575
- if [ ${TEST_ADD_STUDIES} == "True" ]; then test_data_studies/commands.sh ; fi
76-
- if [ ${TEST_ADD_STUDIES} == "True" ]; then qiita-cron-job ; fi
77-
- flake8 qiita_* setup.py scripts/*
76+
- if [ ${TEST_ADD_STUDIES} == "True" ]; then all-qiita-cron-job; fi
77+
- flake8 qiita_* setup.py scripts/qiita*
7878
- qiita pet webserver
7979
addons:
8080
postgresql: "9.3"

scripts/all-qiita-cron-job

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
qiita-cron-job empty_trash_upload_folder
4+
qiita-cron-job generate_biom_and_metadata_release
5+
qiita-cron-job purge_filepaths
6+
qiita-cron-job purge_files_from_filesystem
7+
qiita-cron-job update_redis_stats

scripts/qiita-cron-job

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,56 @@
88
# The full license is in the file LICENSE, distributed with this software.
99
# -----------------------------------------------------------------------------
1010

11+
import click
12+
1113
from qiita_db.util import (
12-
purge_filepaths, empty_trash_upload_folder, purge_files_from_filesystem)
14+
purge_filepaths as qiita_purge_filepaths,
15+
empty_trash_upload_folder as qiita_empty_trash_upload_folder,
16+
purge_files_from_filesystem as qiita_purge_files_from_filesystem)
1317
from qiita_db.meta_util import (
14-
update_redis_stats, generate_biom_and_metadata_release)
18+
update_redis_stats as qiita_update_redis_stats,
19+
generate_biom_and_metadata_release as
20+
qiita_generate_biom_and_metadata_release)
1521

1622

17-
# This script will perform these jobs:
18-
# 1. purge_filepaths: remove files from that are leftover in the
19-
# qiita.filepath and are present in the filesystem
20-
# 2. empty_trash_upload_folder: remove files that are present in the trash
21-
# of the upload folders
22-
# 3. update_redis_stats: updates the redis stats information
23-
# 4. generate public releases of biom tables and metadata
24-
#
25-
# Note that is responsability of the Qiita install system admin to add to a
26-
# cron job this script and responsible to define how often it should run
23+
@click.group()
24+
def commands():
25+
pass
26+
27+
28+
@commands.command()
29+
@click.option('--remove/--no-remove', default=True,
30+
help='remove any filepaths from the qiita.filepath table that '
31+
'are not linked to any other table')
32+
def purge_filepaths(remove):
33+
qiita_purge_filepaths(remove)
34+
35+
36+
@commands.command()
37+
@click.option('--remove/--no-remove', default=False,
38+
help='check the filesystem mounts and remove files not used in '
39+
'the database')
40+
def purge_files_from_filesystem(remove):
41+
qiita_purge_files_from_filesystem(remove)
42+
43+
44+
@commands.command()
45+
@click.option('--remove/--no-remove', default=True,
46+
help='remove files from the trash folder within the upload '
47+
'folders')
48+
def empty_trash_upload_folder(remove):
49+
qiita_empty_trash_upload_folder(remove)
50+
51+
52+
@commands.command()
53+
def update_redis_stats():
54+
qiita_update_redis_stats()
2755

2856

29-
def main():
30-
purge_filepaths(True)
31-
purge_files_from_filesystem(False)
32-
empty_trash_upload_folder(True)
33-
update_redis_stats()
34-
generate_biom_and_metadata_release('public')
57+
@commands.command()
58+
def generate_biom_and_metadata_release():
59+
qiita_generate_biom_and_metadata_release('public')
3560

3661

3762
if __name__ == "__main__":
38-
main()
63+
commands()

0 commit comments

Comments
 (0)