diff --git a/templates/galaxy/config/tpv_rules_meta.yml.j2 b/templates/galaxy/config/tpv_rules_meta.yml.j2 index 6ed18b2..e28ebe3 100644 --- a/templates/galaxy/config/tpv_rules_meta.yml.j2 +++ b/templates/galaxy/config/tpv_rules_meta.yml.j2 @@ -62,6 +62,57 @@ tools: cores: int(job.get_param_values(app)['__job_resource']['cores']) context: walltime: "{int(job.get_param_values(app)['__job_resource']['time'])}" +# DEMON: Hopefully, this could be optimized after TPV will get repeated reevaluation of resources (https://github.com/galaxyproject/total-perspective-vortex/issues/189) + toolshed.g2.bx.psu.edu/repos/iuc/kraken2/kraken2/.*: + rules: + - id: set_highmem_based_on_ref_size + if: | + import os + import functools + from typing import Optional + + @functools.lru_cache(maxsize=128) + def get_ref_size(lookup_value: str, table_name: str, lookup_column: str, value_column: str, value_template: str) -> Optional[int]: + ref_size = None # optional int will be None unless set + try: + table_value = app.tool_data_tables.get(table_name).get_entry( + lookup_column, lookup_value, value_column + ) + if table_value is not None: + table_value = value_template.format(value=table_value) + ref_size = int(os.path.getsize(table_value) / 1024**3) + log.debug( + "Data table '%s' lookup '%s=%s: %s=%s': %s GB", + table_name, lookup_column, lookup_value, + value_column, table_value, ref_size + ) + else: + log.warning( + "Data table '%s' lookup '%s=%s: %s=None' returned None!, defaulting to %s", + table_name, lookup_column, lookup_value, + value_column, ref_size + ) + except OSError: + log.exception("Failed to get size of: %s", table_value) + return ref_size + + default_mem = 64 + options = job.get_param_values(app) + lookup_value = options["kraken2_database"] + + ref_size = get_ref_size( + lookup_value=lookup_value, + table_name="kraken2_databases", + lookup_column="value", + value_column="path", + value_template="{value}/hash.k2d", + ) + ref_size is not None and min(ref_size * 1.2 + 48, 980) > 180 + context: + queue: elixircz + scheduling: + require: + - highmem toolshed.g2.bx.psu.edu/repos/iuc/bedtools/bedtools_annotatebed/.*: context: walltime: 48