Skip to content

Commit

Permalink
Merge branch 'main' into defense_finder
Browse files Browse the repository at this point in the history
  • Loading branch information
bernt-matthias authored Jun 19, 2024
2 parents 5a37f57 + 534e3a5 commit d315588
Show file tree
Hide file tree
Showing 3 changed files with 336 additions and 33 deletions.
93 changes: 64 additions & 29 deletions scripts/update-tool.py
Original file line number Diff line number Diff line change
@@ -1,72 +1,107 @@
import yaml
import os
import glob
import copy
import argparse
import copy
import glob
import logging
import os
import sys

import yaml
from bioblend import toolshed

ts = toolshed.ToolShedInstance(url='https://toolshed.g2.bx.psu.edu')
ts = toolshed.ToolShedInstance(url="https://toolshed.g2.bx.psu.edu")


def update_file(fn, owner=None, name=None, without=False):
with open(fn + '.lock', 'r') as handle:
success = True
with open(fn + ".lock", "r") as handle:
locked = yaml.safe_load(handle)

# Update any locked tools.
for tool in locked['tools']:
for tool in locked["tools"]:
# If without, then if it is lacking, we should exec.
logging.debug("Examining {owner}/{name}".format(**tool))

if without:
if 'revisions' in tool and not len(tool.get('revisions', [])) == 0:
if "revisions" in tool and not len(tool.get("revisions", [])) == 0:
continue

if not without and owner and tool['owner'] != owner:
if not without and owner and tool["owner"] != owner:
continue

if not without and name and tool['name'] != name:
if not without and name and tool["name"] != name:
continue

logging.info("Fetching updates for {owner}/{name}".format(**tool))

try:
revs = ts.repositories.get_ordered_installable_revisions(tool['name'], tool['owner'])
revs = ts.repositories.get_ordered_installable_revisions(
tool["name"], tool["owner"]
)
except Exception as e:
print(e)
logging.error(
f"Could not get info for {tool['name']} ({tool['owner']}) from TS: {e}"
)
success = False
continue

logging.debug('TS revisions: %s' % ','.join(revs))
if len(revs) == 0:
logging.error(
f"No installable revisions for {tool['name']} ({tool['owner']})"
)
success = False
continue
logging.debug("TS revisions: %s" % ",".join(revs))
latest_rev = revs[-1]
if latest_rev in tool.get('revisions', []):
if latest_rev in tool.get("revisions", []):
# The rev is already known, don't add again.
continue

logging.info("Found newer revision of {owner}/{name} ({rev})".format(rev=latest_rev, **tool))
logging.info(
"Found newer revision of {owner}/{name} ({rev})".format(
rev=latest_rev, **tool
)
)

# Get latest rev, if not already added, add it.
if 'revisions' not in tool:
tool['revisions'] = []
if "revisions" not in tool:
tool["revisions"] = []

if latest_rev not in tool['revisions']:
if latest_rev not in tool["revisions"]:
# TS doesn't support utf8 and we don't want to either.
tool['revisions'].append(str(latest_rev))
tool["revisions"].append(str(latest_rev))

tool['revisions'] = sorted(list(set( tool['revisions'] )))
tool["revisions"] = sorted(list(set(tool["revisions"])))

with open(fn + '.lock', 'w') as handle:
with open(fn + ".lock", "w") as handle:
yaml.dump(locked, handle, default_flow_style=False)
return success



if __name__ == '__main__':
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('fn', type=argparse.FileType('r'), help="Tool.yaml file")
parser.add_argument('--owner', help="Repository owner to filter on, anything matching this will be updated")
parser.add_argument('--name', help="Repository name to filter on, anything matching this will be updated")
parser.add_argument('--without', action='store_true', help="If supplied will ignore any owner/name and just automatically add the latest hash for anything lacking one.")
parser.add_argument('--log', choices=('critical', 'error', 'warning', 'info', 'debug'), default='info')
parser.add_argument("fn", type=argparse.FileType("r"), help="Tool.yaml file")
parser.add_argument(
"--owner",
help="Repository owner to filter on, anything matching this will be updated",
)
parser.add_argument(
"--name",
help="Repository name to filter on, anything matching this will be updated",
)
parser.add_argument(
"--without",
action="store_true",
help="If supplied will ignore any owner/name and just automatically add the latest hash for anything lacking one.",
)
parser.add_argument(
"--log",
choices=("critical", "error", "warning", "info", "debug"),
default="info",
)
args = parser.parse_args()
logging.basicConfig(level=getattr(logging, args.log.upper()))
update_file(args.fn.name, owner=args.owner, name=args.name, without=args.without)
success = update_file(
args.fn.name, owner=args.owner, name=args.name, without=args.without
)
if not success:
sys.exit(1)
21 changes: 17 additions & 4 deletions tool_list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3113,15 +3113,28 @@ tools:
- name: data_manager_build_kraken2_database
owner: iuc
tool_panel_section_label: Data Managers
- name: dose_response_analysis_tool
owner: ufz
tool_panel_section_label: Toxicology
# Can't be deployed https://github.com/galaxyproject/galaxy/issues/18359
# - name: dose_response_analysis_tool
# owner: ufz
# tool_panel_section_label: Toxicology
- name: baseline_toxicity_calculator
owner: ufz
owner: mbernt
tool_panel_section_label: Toxicology
- name: defense_finder
owner: rplanel
tool_panel_section_label: Genome annotation
- name: data_manager_defense_finder
owner: rplanel
tool_panel_section_label: Data Managers
- name: drep_compare
owner: iuc
tool_panel_section_label: Metagenomics
- name: drep_dereplicate
owner: iuc
tool_panel_section_label: Metagenomics
- name: genomad_end_to_end
owner: ufz
tool_panel_section_label: Metagenomics
- name: genomad_build_database
owner: ufz
tool_panel_section_label: Data Managers
Loading

0 comments on commit d315588

Please sign in to comment.