Skip to content

Commit

Permalink
Add script
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed May 2, 2024
1 parent a1b3d39 commit 018ecfe
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Empty file.
36 changes: 36 additions & 0 deletions lib/galaxy/model/scripts/prune_history_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import argparse
import os
import sys

from sqlalchemy import create_engine

sys.path.insert(
1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, os.pardir, "lib"))
)

from galaxy.model.orm.scripts import get_config
from galaxy.model.scripts.history_table_pruner import HistoryTablePruner

DESCRIPTION = """Remove unused histories from database.
A history is considered unused if it doesn't have a user and its hid counter has not been incremented.
"""


def main():
args = _get_parser().parse_args()
config = get_config(sys.argv, use_argparse=False, cwd=os.getcwd())
engine = create_engine(config["db_url"])
htp = HistoryTablePruner(engine=engine, batch_size=args.batch, max_create_time=args.created)
htp.run()


def _get_parser():
parser = argparse.ArgumentParser(description=DESCRIPTION)
parser.add_argument("--batch", help="batch size")
parser.add_argument("--created", help="most recent create_time")
return parser


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions packages/data/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ console_scripts =
galaxy-build-objects = galaxy.model.store.build_objects:main
galaxy-load-objects = galaxy.model.store.load_objects:main
galaxy-manage-db = galaxy.model.orm.scripts:manage_db
galaxy-prune-histories = galaxy.model.scripts:prune_history_table

[options.packages.find]
exclude =
Expand Down

0 comments on commit 018ecfe

Please sign in to comment.