Concatenation pass, fstring conversion

This commit is contained in:
Dannon Baker
2021-05-11 13:53:20 -04:00
parent 22e7601653
commit f1ff658cb7
175 changed files with 599 additions and 599 deletions
+3 -3
View File
@@ -152,7 +152,7 @@ class AdminActions:
if len(names) == 1:
raise ActionInputError(f"Quota '{names[0]}' is a default, please unset it as a default before deleting it.")
elif len(names) > 1:
raise ActionInputError("Quotas are defaults, please unset them as defaults before deleting them: " + ', '.join(names))
raise ActionInputError(f"Quotas are defaults, please unset them as defaults before deleting them: {', '.join(names)}")
message = "Deleted %d quotas: " % len(quotas)
for q in quotas:
q.deleted = True
@@ -171,7 +171,7 @@ class AdminActions:
if len(names) == 1:
raise ActionInputError(f"Quota '{names[0]}' has not been deleted, so it cannot be undeleted.")
elif len(names) > 1:
raise ActionInputError("Quotas have not been deleted so they cannot be undeleted: " + ', '.join(names))
raise ActionInputError(f"Quotas have not been deleted so they cannot be undeleted: {', '.join(names)}")
message = "Undeleted %d quotas: " % len(quotas)
for q in quotas:
q.deleted = False
@@ -196,7 +196,7 @@ class AdminActions:
if len(names) == 1:
raise ActionInputError(f"Quota '{names[0]}' has not been deleted, so it cannot be purged.")
elif len(names) > 1:
raise ActionInputError("Quotas have not been deleted so they cannot be undeleted: " + ', '.join(names))
raise ActionInputError(f"Quotas have not been deleted so they cannot be undeleted: {', '.join(names)}")
message = "Purged %d quotas: " % len(quotas)
for q in quotas:
# Delete UserQuotaAssociations
+4 -4
View File
@@ -114,7 +114,7 @@ class CustosAuthnz(IdentityProvider):
log.exception(message)
raise exceptions.AuthenticationFailed(message)
else:
login_redirect_url = login_redirect_url + 'root/login?confirm=true&custos_token=' + json.dumps(token)
login_redirect_url = f"{login_redirect_url}root/login?confirm=true&custos_token={json.dumps(token)}"
return login_redirect_url, None
custos_authnz_token = CustosAuthnzToken(user=user,
@@ -224,7 +224,7 @@ class CustosAuthnz(IdentityProvider):
else:
client_secret = self.config['client_secret']
token_endpoint = self.config['token_endpoint']
clientIdAndSec = self.config['client_id'] + ":" + self.config['client_secret'] # for custos
clientIdAndSec = f"{self.config['client_id']}:{self.config['client_secret']}" # for custos
return oauth2_session.fetch_token(
token_endpoint,
client_secret=client_secret,
@@ -263,7 +263,7 @@ class CustosAuthnz(IdentityProvider):
self.config['credential_url'] = '/'.join([self.config['url'].rstrip('/'), 'credentials'])
self._get_custos_credentials()
# Set custos endpoints
clientIdAndSec = self.config['client_id'] + ":" + self.config['client_secret']
clientIdAndSec = f"{self.config['client_id']}:{self.config['client_secret']}"
eps = requests.get(self.config['well_known_oidc_config_uri'],
headers={"Authorization": f"Basic {util.unicodify(base64.b64encode(util.smart_str(clientIdAndSec)))}"},
verify=False, params={'client_id': self.config['client_id']})
@@ -276,7 +276,7 @@ class CustosAuthnz(IdentityProvider):
self._load_well_known_oidc_config(well_known_oidc_config)
def _get_custos_credentials(self):
clientIdAndSec = self.config['client_id'] + ":" + self.config['client_secret']
clientIdAndSec = f"{self.config['client_id']}:{self.config['client_secret']}"
creds = requests.get(self.config['credential_url'],
headers={"Authorization": f"Basic {util.unicodify(base64.b64encode(util.smart_str(clientIdAndSec)))}"},
verify=False, params={'client_id': self.config['client_id']})
+1 -1
View File
@@ -165,7 +165,7 @@ class PSAAuthnz(IdentityProvider):
on_the_fly_config(trans.sa_session)
self.config[setting_name('LOGIN_REDIRECT_URL')] = login_redirect_url
strategy = Strategy(trans.request, trans.session, Storage, self.config)
strategy.session_set(BACKENDS_NAME[self.config['provider']] + '_state', state_token)
strategy.session_set(f"{BACKENDS_NAME[self.config['provider']]}_state", state_token)
backend = self._load_backend(strategy, self.config['redirect_uri'])
redirect_url = do_complete(
backend,
+1 -1
View File
@@ -815,7 +815,7 @@ class GalaxyAppConfiguration(BaseAppConfiguration, CommonConfigurationMixin):
self.amqp_internal_connection = kwargs.get('amqp_internal_connection')
# TODO Get extra amqp args as necessary for ssl
elif 'database_connection' in kwargs:
self.amqp_internal_connection = "sqlalchemy+" + self.database_connection
self.amqp_internal_connection = f"sqlalchemy+{self.database_connection}"
else:
self.amqp_internal_connection = f"sqlalchemy+sqlite:///{self._in_data_dir('control.sqlite')}?isolation_level=IMMEDIATE"
self.pretty_datetime_format = expand_pretty_datetime_format(self.pretty_datetime_format)
+2 -2
View File
@@ -219,7 +219,7 @@ class ContainerInterface(metaclass=ABCMeta):
}
log.warning("option '%s' not in %s.option_map, guessing flag '%s' type '%s'",
opt, self.__class__.__name__, optdef['flag'], optdef['type'])
opts.append(getattr(self, '_stringify_kwopt_' + optdef['type'])(optdef['flag'], val))
opts.append(getattr(self, f"_stringify_kwopt_{optdef['type']}")(optdef['flag'], val))
return ' '.join(opts)
def _stringify_kwopt_boolean(self, flag, val):
@@ -272,7 +272,7 @@ class ContainerInterface(metaclass=ABCMeta):
return stdout.strip()
else:
msg = f"Command '{command}' returned non-zero exit status {p.returncode}"
log.error(msg + ': ' + stderr.strip())
log.error(f"{msg}: {stderr.strip()}")
raise ContainerCLIError(
msg,
stdout=stdout.strip(),
+3 -3
View File
@@ -168,7 +168,7 @@ class DockerCLIInterface(DockerInterface):
kwopt_list.append('{vol}:{bind}{mode}'.format(
vol=hostvol,
bind=guestopts['bind'],
mode=':' + mode if mode else ''
mode=f":{mode}" if mode else ''
))
return self._stringify_kwopt_list(flag, kwopt_list)
@@ -234,7 +234,7 @@ class DockerAPIClient:
if isinstance(f, partial):
f = f.func
try:
return getattr(f, '__qualname__', f.im_class.__name__ + '.' + f.__name__)
return getattr(f, '__qualname__', f"{f.im_class.__name__}.{f.__name__}")
except AttributeError:
return f.__name__
@@ -489,7 +489,7 @@ class DockerAPIInterface(DockerInterface):
# keyword arguments
spec_kwopts = {}
# retrieve the option map for the docker-py object we're creating
option_map = getattr(self, option_map_name + '_option_map')
option_map = getattr(self, f"{option_map_name}_option_map")
# set defaults
for key in filter(lambda k: option_map[k].get('default'), option_map.keys()):
map_spec = option_map[key]
+3 -3
View File
@@ -24,8 +24,8 @@ from galaxy.util import (
CPUS_LABEL = '_galaxy_cpus'
IMAGE_LABEL = '_galaxy_image'
CPUS_CONSTRAINT = 'node.labels.' + CPUS_LABEL
IMAGE_CONSTRAINT = 'node.labels.' + IMAGE_LABEL
CPUS_CONSTRAINT = f"node.labels.{CPUS_LABEL}"
IMAGE_CONSTRAINT = f"node.labels.{IMAGE_LABEL}"
log = logging.getLogger(__name__)
@@ -676,7 +676,7 @@ class DockerTask:
service = service or interface.service(id=t.get('ServiceID'))
node = node or interface.node(id=t.get('NodeID'))
if service:
name = service.name + '.' + str(t['Slot'])
name = f"{service.name}.{str(t['Slot'])}"
else:
name = t['ID']
image = t['Spec']['ContainerSpec']['Image'].split('@', 1)[0], # remove pin
+2 -2
View File
@@ -426,10 +426,10 @@ class DockerSwarmAPIInterface(DockerSwarmInterface, DockerAPIInterface):
# service constraints
kwopts['constraint'] = kwopts.get('constraint', [])
if self._conf.service_create_image_constraint:
kwopts['constraint'].append(IMAGE_CONSTRAINT + '==' + image)
kwopts['constraint'].append(f"{IMAGE_CONSTRAINT}=={image}")
if self._conf.service_create_cpus_constraint:
cpus = kwopts.get('reserve_cpus', kwopts.get('limit_cpus', '1'))
kwopts['constraint'].append(CPUS_CONSTRAINT + '==' + cpus)
kwopts['constraint'].append(f"{CPUS_CONSTRAINT}=={cpus}")
# ports
if 'publish_port_random' in kwopts:
kwopts['ports'] = [DockerSwarmAPIInterface.create_random_port_spec(kwopts.pop('publish_port_random'))]
+3 -3
View File
@@ -182,11 +182,11 @@ class Velvet(Html):
dataset.metadata.short2_reads = short2_reads
dataset.info = re.sub(r'.*velveth \S+', 'hash_length', re.sub(r'\n', ' ', log_msg))
if paired_end_reads:
gen_msg = gen_msg + ' Paired-End Reads'
gen_msg = f"{gen_msg} Paired-End Reads"
if long_reads:
gen_msg = gen_msg + ' Long Reads'
gen_msg = f"{gen_msg} Long Reads"
if len(gen_msg) > 0:
gen_msg = 'Uses: ' + gen_msg
gen_msg = f"Uses: {gen_msg}"
except Exception:
log.debug(f"Velveth could not read Log file in {efp}")
log.debug(f"Velveth log info {gen_msg}")
+2 -2
View File
@@ -708,7 +708,7 @@ class CRAM(Binary):
def set_meta(self, dataset, overwrite=True, **kwd):
major_version, minor_version = self.get_cram_version(dataset.file_name)
if major_version != -1:
dataset.metadata.cram_version = str(major_version) + "." + str(minor_version)
dataset.metadata.cram_version = f"{str(major_version)}.{str(minor_version)}"
if not dataset.metadata.cram_index:
index_file = dataset.metadata.spec['cram_index'].param.new_file(dataset=dataset)
@@ -788,7 +788,7 @@ class Bcf(BaseBcf):
try:
cmd = ['python', '-c', f"import pysam.bcftools; pysam.bcftools.index('{dataset_symlink}')"]
subprocess.check_call(cmd)
shutil.move(dataset_symlink + '.csi', index_file.file_name)
shutil.move(f"{dataset_symlink}.csi", index_file.file_name)
except Exception as e:
raise Exception(f'Error setting BCF metadata: {util.unicodify(e)}')
finally:
@@ -97,9 +97,9 @@ def main():
# Write padded entries.
with open(out_fname, 'w') as out:
out.write(str(max_len + 1).ljust(max_len) + '\n')
out.write(f"{str(max_len + 1).ljust(max_len)}\n")
for entry in entries:
out.write(entry.ljust(max_len) + '\n')
out.write(f"{entry.ljust(max_len)}\n")
if __name__ == '__main__':
@@ -664,11 +664,11 @@ class SamtoolsDataProvider(line.RegexLineDataProvider):
validated_flag_list.append('S')
if validated_flag_list:
opt_list.append('-' + ''.join(validated_flag_list))
opt_list.append(f"-{''.join(validated_flag_list)}")
for flag, arg in options_dict.items():
if flag in self.FLAGS_W_ARGS:
opt_list.extend(['-' + flag, str(arg)])
opt_list.extend([f"-{flag}", str(arg)])
return opt_list
@@ -172,4 +172,4 @@ class TempfileDataProvider(base.DataProvider):
parent_gen = super().__iter__()
with open(self.tmp_file, 'w') as open_file:
for datum in parent_gen:
open_file.write(datum + '\n')
open_file.write(f"{datum}\n")
+1 -1
View File
@@ -102,7 +102,7 @@ class GenomeGraphs(Tabular):
internal_url = "%s" % app.url_for(controller='dataset',
dataset_id=dataset.id,
action='display_at',
filename='ucsc_' + site_name)
filename=f"ucsc_{site_name}")
display_url = "%s%s/display_as?id=%i&display_app=%s&authz_method=display_at" % (base_url, app.url_for(controller='root'), dataset.id, type)
display_url = quote_plus(display_url)
# was display_url = quote_plus( "%s/display_as?id=%i&display_app=%s" % (base_url, dataset.id, type) )
+1 -1
View File
@@ -288,7 +288,7 @@ class _Isa(data.Data):
html += '<ul>'
for data_file in assay.data_files:
if data_file.filename != '':
html += '<li>' + escape(util.unicodify(str(data_file.filename), 'utf-8')) + ' - ' + escape(util.unicodify(str(data_file.label), 'utf-8')) + '</li>'
html += f"<li>{escape(util.unicodify(str(data_file.filename), 'utf-8'))} - {escape(util.unicodify(str(data_file.label), 'utf-8'))}</li>"
html += '</ul>'
html += '</body></html>'
+3 -3
View File
@@ -1132,8 +1132,8 @@ class ConnectivityTable(Tabular):
edam_format = "format_3309"
file_ext = "ct"
header_regexp = re.compile("^[0-9]+" + "(?:\t|[ ]+)" + ".*?" + "(?:ENERGY|energy|dG)" + "[ \t].*?=")
structure_regexp = re.compile("^[0-9]+" + "(?:\t|[ ]+)" + "[ACGTURYKMSWBDHVN]+" + "(?:\t|[ ]+)" + "[^\t]+" + "(?:\t|[ ]+)" + "[^\t]+" + "(?:\t|[ ]+)" + "[^\t]+" + "(?:\t|[ ]+)" + "[^\t]+")
header_regexp = re.compile(f"^[0-9]+(?: |[ ]+).*?(?:ENERGY|energy|dG)[ ].*?=")
structure_regexp = re.compile(f"^[0-9]+(?: |[ ]+)[ACGTURYKMSWBDHVN]+(?: |[ ]+)[^ ]+(?: |[ ]+)[^ ]+(?: |[ ]+)[^ ]+(?: |[ ]+)[^ ]+")
def __init__(self, **kwd):
super().__init__(**kwd)
@@ -1230,7 +1230,7 @@ class ConnectivityTable(Tabular):
ck_data_body = re.sub('\n[ \t]+', '\n', ck_data_body)
ck_data_body = re.sub('[ ]+', '\t', ck_data_body)
return dumps({'ck_data': util.unicodify(ck_data_header + "\n" + ck_data_body), 'ck_index': ck_index + 1})
return dumps({'ck_data': util.unicodify(f"{ck_data_header}\n{ck_data_body}"), 'ck_index': ck_index + 1})
@build_sniff_from_prefix
+1 -1
View File
@@ -130,7 +130,7 @@ class Rdf(xml.GenericXml, Triples):
def sniff_prefix(self, file_prefix):
# <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" ...
match = re.compile(r'xmlns:([^=]*)="http://www.w3.org/1999/02/22-rdf-syntax-ns#"').search(file_prefix.contents_header)
if not match and (match.group(1) + ":RDF") in file_prefix.contents_header:
if not match and (f"{match.group(1)}:RDF") in file_prefix.contents_header:
return True
return False
+1 -1
View File
@@ -424,7 +424,7 @@ def read_unordered_gtf(iterator, strict=False):
# transcripts with same ID on different chromosomes; this occurs in some popular
# datasources, such as RefGenes in UCSC.
def key_fn(fields):
return fields[0] + '_' + get_transcript_id(fields)
return f"{fields[0]}_{get_transcript_id(fields)}"
# Aggregate intervals by transcript_id and collect comments.
feature_intervals = {}
+1 -1
View File
@@ -161,7 +161,7 @@ class ConditionalDependencies:
def check(self, name):
try:
name = name.replace('-', '_').replace('.', '_')
return getattr(self, 'check_' + name)()
return getattr(self, f"check_{name}")()
except Exception:
return False
+1 -1
View File
@@ -213,7 +213,7 @@ def uri_join(*args):
arg0 = args[0]
if "://" in arg0:
scheme, path = arg0.split("://", 1)
rval = scheme + "://" + (slash_join(path, *args[1:]) if path else slash_join(*args[1:]))
rval = f"{scheme}://{slash_join(path, *args[1:]) if path else slash_join(*args[1:])}"
else:
rval = slash_join(*args)
return rval
+1 -1
View File
@@ -77,7 +77,7 @@ class CorePlugin(InstrumentPlugin):
def __record_seconds_since_epoch_to_file(self, job_directory, name):
path = self._instrument_file_path(job_directory, f"epoch_{name}")
return 'date +"%s" > ' + path
return f"date +\"%s\" > {path}"
def __read_seconds_since_epoch(self, job_directory, name):
path = self._instrument_file_path(job_directory, f"epoch_{name}")
+4 -4
View File
@@ -785,7 +785,7 @@ class JobConfiguration(ConfiguresHandlers):
# Name to load was specified as '<module>'
if '.' not in load:
# For legacy reasons, try from galaxy.jobs.runners first if there's no '.' in the name
module_name = 'galaxy.jobs.runners.' + load
module_name = f"galaxy.jobs.runners.{load}"
try:
module = __import__(module_name)
except ImportError:
@@ -1521,10 +1521,10 @@ class JobWrapper(HasResourceParameters):
dataset.info = (dataset.info or '')
if context['stdout'].strip():
# Ensure white space between entries
dataset.info = dataset.info.rstrip() + "\n" + context['stdout'].strip()
dataset.info = f"{dataset.info.rstrip()}\n{context['stdout'].strip()}"
if context['stderr'].strip():
# Ensure white space between entries
dataset.info = dataset.info.rstrip() + "\n" + context['stderr'].strip()
dataset.info = f"{dataset.info.rstrip()}\n{context['stderr'].strip()}"
dataset.tool_version = self.version_string
dataset.set_size()
if 'uuid' in context:
@@ -2204,7 +2204,7 @@ class JobWrapper(HasResourceParameters):
elif job.history is not None and job.history.user is not None:
return job.history.user.email
elif job.galaxy_session is not None:
return 'anonymous@' + job.galaxy_session.remote_addr.split()[-1]
return f"anonymous@{job.galaxy_session.remote_addr.split()[-1]}"
else:
return 'anonymous@unknown'
+3 -3
View File
@@ -47,7 +47,7 @@ class EmailAction(DefaultJobAction):
try:
frm = app.config.email_from
history_id_encoded = app.security.encode_id(job.history_id)
link = app.config.galaxy_infrastructure_url + "/histories/view?id=" + history_id_encoded
link = f"{app.config.galaxy_infrastructure_url}/histories/view?id={history_id_encoded}"
if frm is None:
if action.action_arguments and 'host' in action.action_arguments:
host = action.action_arguments['host']
@@ -191,7 +191,7 @@ class RenameDatasetAction(DefaultJobAction):
if len(fields) > 1:
temp = ""
for i in range(1, len(fields) - 1):
temp += "." + fields[i]
temp += f".{fields[i]}"
replacement += temp
elif operation == "upper":
replacement = replacement.upper()
@@ -313,7 +313,7 @@ class ColumnSetAction(DefaultJobAction):
@classmethod
def get_short_str(cls, pja):
return "Set the following metadata values:<br/>" + "<br/>".join('{} : {}'.format(escape(k), escape(v)) for k, v in pja.action_arguments.items())
return f"Set the following metadata values:<br/>{'<br/>'.join('{} : {}'.format(escape(k), escape(v)) for k, v in pja.action_arguments.items())}"
class SetMetadataAction(DefaultJobAction):
+68 -68
View File
@@ -352,9 +352,9 @@ class RuleValidator:
if "nice_value" in rule:
if rule["nice_value"] < -20 or rule["nice_value"] > 20:
error = "nice_value goes from -20 to 20; rule " + str(counter)
error += " in '" + str(tool) + "' has a nice_value of '"
error += str(rule["nice_value"]) + "'."
error = f"nice_value goes from -20 to 20; rule {str(counter)}"
error += f" in '{str(tool)}' has a nice_value of '"
error += f"{str(rule['nice_value'])}'."
if not return_bool:
error += " Setting nice_value to 0."
rule["nice_value"] = 0
@@ -364,8 +364,8 @@ class RuleValidator:
valid_rule = False
else:
error = "No nice_value found for rule " + str(counter) + " in '"
error += str(tool) + "'."
error = f"No nice_value found for rule {str(counter)} in '"
error += f"{str(tool)}'."
if not return_bool:
error += " Setting nice_value to 0."
rule["nice_value"] = 0
@@ -394,8 +394,8 @@ class RuleValidator:
if "fail_message" in rule:
if "destination" not in rule or rule['destination'] != "fail":
error = "Found a fail_message for rule " + str(counter)
error += " in '" + str(tool) + "', but destination is not 'fail'!"
error = f"Found a fail_message for rule {str(counter)}"
error += f" in '{str(tool)}', but destination is not 'fail'!"
if not return_bool:
error += " Setting destination to 'fail'."
if verbose:
@@ -409,12 +409,12 @@ class RuleValidator:
suggestion = None
if isinstance(rule["destination"], str):
if rule["destination"] == "fail" and "fail_message" not in rule:
error = "Missing a fail_message for rule " + str(counter)
error += " in '" + str(tool) + "'."
error = f"Missing a fail_message for rule {str(counter)}"
error += f" in '{str(tool)}'."
if not return_bool:
error += " Adding generic fail_message."
message = "Invalid parameters for rule " + str(counter)
message += " in '" + str(tool) + "'."
message = f"Invalid parameters for rule {str(counter)}"
message += f" in '{str(tool)}'."
rule["fail_message"] = message
if verbose:
log.debug(error)
@@ -432,12 +432,12 @@ class RuleValidator:
for priority in rule["destination"]["priority"]:
if priority not in priority_list:
error = "Invalid priority '"
error += str(priority) + "' for rule "
error += str(counter) + " in '" + str(tool) + "'."
error += f"{str(priority)}' for rule "
error += f"{str(counter)} in '{str(tool)}'."
suggestion = get_typo_correction(priority,
priority_list, max_edit_dist)
if suggestion:
error += " Did you mean '" + str(suggestion) + "'?"
error += f" Did you mean '{str(suggestion)}'?"
if not return_bool:
error += " Ignoring..."
if verbose:
@@ -447,8 +447,8 @@ class RuleValidator:
elif not isinstance(rule["destination"]["priority"][priority], str):
error = "Cannot parse tool destination '"
error += str(rule["destination"]["priority"][priority])
error += "' for rule " + str(counter)
error += " in '" + str(tool) + "'."
error += f"' for rule {str(counter)}"
error += f" in '{str(tool)}'."
if not return_bool:
error += " Ignoring..."
if verbose:
@@ -463,24 +463,24 @@ class RuleValidator:
if not is_valid:
valid_rule = False
else:
error = "No destination specified for rule " + str(counter)
error += " in '" + str(tool) + "'."
error = f"No destination specified for rule {str(counter)}"
error += f" in '{str(tool)}'."
if not return_bool:
error += " Ignoring..."
if verbose:
log.debug(error)
valid_rule = False
else:
error = "No destination specified for rule " + str(counter)
error += " in '" + str(tool) + "'."
error = f"No destination specified for rule {str(counter)}"
error += f" in '{str(tool)}'."
if not return_bool:
error += " Ignoring..."
if verbose:
log.debug(error)
valid_rule = False
else:
error = "No destination specified for rule " + str(counter)
error += " in '" + str(tool) + "'."
error = f"No destination specified for rule {str(counter)}"
error += f" in '{str(tool)}'."
if not return_bool:
error += " Ignoring..."
if verbose:
@@ -542,8 +542,8 @@ class RuleValidator:
if upper_bound != -1 and lower_bound > upper_bound:
error = "lower_bound exceeds upper_bound for rule " + str(counter)
error += " in '" + str(tool) + "'."
error = f"lower_bound exceeds upper_bound for rule {str(counter)}"
error += f" in '{str(tool)}'."
if not return_bool:
error += " Reversing bounds."
temp_upper_bound = rule["upper_bound"]
@@ -555,8 +555,8 @@ class RuleValidator:
valid_rule = False
else:
error = "Missing bounds for rule " + str(counter)
error += " in '" + str(tool) + "'."
error = f"Missing bounds for rule {str(counter)}"
error += f" in '{str(tool)}'."
if not return_bool:
error += " Ignoring rule."
rule = None
@@ -594,8 +594,8 @@ class RuleValidator:
"""
if "arguments" not in rule or not isinstance(rule["arguments"], dict):
error = "No arguments found for rule " + str(counter) + " in '"
error += str(tool) + "' despite being of type arguments."
error = f"No arguments found for rule {str(counter)} in '"
error += f"{str(tool)}' despite being of type arguments."
if not return_bool:
error += " Ignoring rule."
rule = None
@@ -638,9 +638,9 @@ class RuleValidator:
if isinstance(rule["users"], list):
for user in reversed(rule["users"]):
if not isinstance(user, str):
error = "Entry '" + str(user) + "' in users for rule "
error += str(counter) + " in tool '" + str(tool)
error += "' is in an " + "invalid format!"
error = f"Entry '{str(user)}' in users for rule "
error += f"{str(counter)} in tool '{str(tool)}"
error += f"' is in an invalid format!"
if not return_bool:
error += " Ignoring entry."
if verbose:
@@ -650,9 +650,9 @@ class RuleValidator:
else:
if re.match(emailregex, user) is None:
error = "Supplied email '" + str(user)
error += "' for rule " + str(counter) + " in tool '"
error += str(tool) + "' is in " + "an invalid format!"
error = f"Supplied email '{str(user)}"
error += f"' for rule {str(counter)} in tool '"
error += f"{str(tool)}' is in an invalid format!"
if not return_bool:
error += " Ignoring email."
if verbose:
@@ -672,8 +672,8 @@ class RuleValidator:
# post-processing checking to make sure we didn't just remove all the users
# if we did, we should ignore the rule
if rule is not None and rule["users"] is not None and len(rule["users"]) == 0:
error = "No valid user emails were specified for rule " + str(counter)
error += " in tool '" + str(tool) + "'!"
error = f"No valid user emails were specified for rule {str(counter)}"
error += f" in tool '{str(tool)}'!"
if not return_bool:
error += " Ignoring rule."
rule = None
@@ -786,7 +786,7 @@ def validate_destination(app, destination: str, err_message: str, err_message_co
if not valid_destination:
error = err_message % err_message_contents
if suggestion:
error += " Did you mean '" + suggestion + "'?"
error += f" Did you mean '{suggestion}'?"
if not return_bool:
error += " Ignoring..."
if verbose:
@@ -828,7 +828,7 @@ def validate_config(obj: dict, app=None, return_bool: bool = False):
else:
valid_config = False
if obj:
log.debug("Verbose value '" + str(obj['verbose']) + "' is not True or False! Falling back to verbose...")
log.debug(f"Verbose value '{str(obj['verbose'])}' is not True or False! Falling back to verbose...")
verbose = True
if not return_bool and verbose:
@@ -891,7 +891,7 @@ def validate_config(obj: dict, app=None, return_bool: bool = False):
suggestion = get_typo_correction(obj['default_priority'],
priority_list, max_edit_dist)
if suggestion:
error += " Did you mean '" + str(suggestion) + "'?"
error += f" Did you mean '{str(suggestion)}'?"
if verbose:
log.debug(error)
else:
@@ -946,17 +946,17 @@ def validate_config(obj: dict, app=None, return_bool: bool = False):
suggestion = get_typo_correction(curr['priority'],
priority_list, max_edit_dist)
if suggestion:
error += " Did you mean '" + str(suggestion) + "'?"
error += f" Did you mean '{str(suggestion)}'?"
if verbose:
log.debug(error)
valid_config = False
else:
error = "User '" + user + "' is missing a priority!"
error = f"User '{user}' is missing a priority!"
if verbose:
log.debug(error)
valid_config = False
else:
error = "User '" + user + "' is missing a priority!"
error = f"User '{user}' is missing a priority!"
if verbose:
log.debug(error)
valid_config = False
@@ -1027,13 +1027,13 @@ def validate_config(obj: dict, app=None, return_bool: bool = False):
suggestion = get_typo_correction(priority,
priority_list, max_edit_dist)
if suggestion:
error += " Did you mean '" + str(suggestion) + "'?"
error += f" Did you mean '{str(suggestion)}'?"
if verbose:
log.debug(error)
valid_config = False
else:
error = "No default priority destinations specified"
error += " for " + str(tool) + " in config!"
error += f" for {str(tool)} in config!"
if verbose:
log.debug(error)
valid_config = False
@@ -1081,8 +1081,8 @@ def validate_config(obj: dict, app=None, return_bool: bool = False):
# if rule['rule_type'] in available_rule_types
else:
error = "Unrecognized rule_type '"
error += rule['rule_type'] + "' "
error += "found in '" + str(tool) + "'. "
error += f"{rule['rule_type']}' "
error += f"found in '{str(tool)}'. "
if not return_bool:
error += "Ignoring..."
if verbose:
@@ -1094,7 +1094,7 @@ def validate_config(obj: dict, app=None, return_bool: bool = False):
counter += 1
error = "No rule_type found for rule "
error += str(counter)
error += " in '" + str(tool) + "'."
error += f" in '{str(tool)}'."
if verbose:
log.debug(error)
valid_config = False
@@ -1102,7 +1102,7 @@ def validate_config(obj: dict, app=None, return_bool: bool = False):
# if "rules" in curr and isinstance(curr['rules'], list):
elif not tool_has_default:
valid_config = False
error = "Tool '" + str(tool) + "' does not have"
error = f"Tool '{str(tool)}' does not have"
error += " rules nor a default_destination!"
if verbose:
log.debug(error)
@@ -1110,7 +1110,7 @@ def validate_config(obj: dict, app=None, return_bool: bool = False):
# if obj['tools'][tool] is not None:
else:
valid_config = False
error = "Config section for tool '" + str(tool) + "' is blank!"
error = f"Config section for tool '{str(tool)}' is blank!"
if verbose:
log.debug(error)
@@ -1128,7 +1128,7 @@ def validate_config(obj: dict, app=None, return_bool: bool = False):
# quickly run through categories to detect unrecognized types
for category in obj.keys():
if category not in valid_categories:
error = "Unrecognized category '" + category
error = f"Unrecognized category '{category}"
error += "' found in config file!"
if verbose:
log.debug(error)
@@ -1225,7 +1225,7 @@ def str_to_bytes(size):
try:
curr_size = float(curr_size)
except ValueError:
error = "Unable to convert size " + str(size)
error = f"Unable to convert size {str(size)}"
raise MalformedYMLException(error)
# Get the unit and convert to bytes
@@ -1234,7 +1234,7 @@ def str_to_bytes(size):
for _ in range(pos, 1, -1):
curr_size *= 1024
except ValueError:
error = "Unable to convert size " + str(size)
error = f"Unable to convert size {str(size)}"
raise MalformedYMLException(error)
except NameError:
pass
@@ -1343,7 +1343,7 @@ def map_tool_to_destination(
if inp_data[da] is not None and os.path.isfile(inp_data[da].file_name):
num_input_datasets += 1
if verbose:
message = "Loading file: " + str(da)
message = f"Loading file: {str(da)}"
message += str(inp_data[da].file_name)
log.debug(message)
@@ -1367,15 +1367,15 @@ def map_tool_to_destination(
except AttributeError:
# Otherwise, say that input isn't a file
if verbose:
log.debug("Not a file: " + str(inp_data[da]))
log.debug(f"Not a file: {str(inp_data[da])}")
if verbose:
if filesize_rule_present:
log.debug("Total size: " + bytes_to_str(file_size))
log.debug(f"Total size: {bytes_to_str(file_size)}")
if records_rule_present:
log.debug("Total amount of records: " + str(records))
log.debug(f"Total amount of records: {str(records)}")
if num_input_datasets_rule_present:
log.debug("Total number of files: " + str(num_input_datasets))
log.debug(f"Total number of files: {str(num_input_datasets)}")
matched_rule = None
user_authorized = None
@@ -1516,7 +1516,7 @@ def map_tool_to_destination(
except KeyError:
matched = False
if verbose:
error = "Argument '" + str(arg)
error = f"Argument '{str(arg)}"
error += "' not recognized!"
log.debug(error)
@@ -1528,15 +1528,15 @@ def map_tool_to_destination(
# if user_authorized
else:
if verbose:
error = "User email '" + str(user_email) + "' not "
error = f"User email '{str(user_email)}' not "
error += "specified in list of authorized users for "
error += "rule " + str(rule_counter) + " in tool '"
error += str(tool.old_id) + "'! Ignoring rule."
error += f"rule {str(rule_counter)} in tool '"
error += f"{str(tool.old_id)}'! Ignoring rule."
log.debug(error)
# if str(tool.old_id) in config
else:
error = "Tool '" + str(tool.old_id) + "' not specified in config. "
error = f"Tool '{str(tool.old_id)}' not specified in config. "
error += "Using default destination."
if verbose:
log.debug(error)
@@ -1565,7 +1565,7 @@ def map_tool_to_destination(
# if "default_destination" in config
else:
destination = "fail"
fail_message = "Job '" + str(tool.old_id) + "' failed; "
fail_message = f"Job '{str(tool.old_id)}' failed; "
fail_message += "no global default destination specified in config!"
# if fail_message is not None
@@ -1582,11 +1582,11 @@ def map_tool_to_destination(
if config is not None:
if destination == "fail":
output = "An error occurred: " + fail_message
output = f"An error occurred: {fail_message}"
log.debug(output)
else:
output = "Running '" + str(tool.old_id) + "' with '"
output += destination + "'."
output = f"Running '{str(tool.old_id)}' with '"
output += f"{destination}'."
log.debug(output)
return destination
@@ -1650,7 +1650,7 @@ def get_destination_list_from_job_config(job_config_location) -> set:
destination_list.add(destination.get("id"))
else:
error = "Destination ID '" + str(destination)
error = f"Destination ID '{str(destination)}"
error += "' in job configuration file cannot be"
error += " parsed. Things may not work as expected!"
log.debug(error)
@@ -1783,7 +1783,7 @@ if __name__ == '__main__':
'-j', '--job-config', dest='job_config')
parser.add_argument(
'-V', '--version', action='version', version="%(prog)s " + __version__)
'-V', '--version', action='version', version=f"%(prog)s {__version__}")
args = parser.parse_args()
+1 -1
View File
@@ -1022,7 +1022,7 @@ class DefaultJobDispatcher:
# URLs can have their URL params converted to the destination's param
# dict by the plugin.
self.app.job_config.convert_legacy_destinations(self.job_runners)
log.debug("Loaded job runners plugins: " + ':'.join(self.job_runners.keys()))
log.debug(f"Loaded job runners plugins: {':'.join(self.job_runners.keys())}")
def __get_runner_name(self, job_wrapper):
if job_wrapper.can_split():
+1 -1
View File
@@ -574,7 +574,7 @@ class JobState:
job_name += f'_{self.job_wrapper.tool.old_id}'
if not self.redact_email_in_job_name and self.job_wrapper.user:
job_name += f'_{self.job_wrapper.user}'
self.job_name = ''.join(x if x in (string.ascii_letters + string.digits + '_') else '_' for x in job_name)
self.job_name = ''.join(x if x in (f"{string.ascii_letters + string.digits}_") else '_' for x in job_name)
@staticmethod
def default_job_file(files_dir, id_tag):
+4 -4
View File
@@ -147,10 +147,10 @@ class ChronosJobRunner(AsynchronousJobRunner):
@handle_exception_call
def queue_job(self, job_wrapper):
LOGGER.debug("Starting queue_job for job " + job_wrapper.get_id_tag())
LOGGER.debug(f"Starting queue_job for job {job_wrapper.get_id_tag()}")
if not self.prepare_job(job_wrapper, include_metadata=False,
modify_command_for_container=False):
LOGGER.debug("Not ready " + job_wrapper.get_id_tag())
LOGGER.debug(f"Not ready {job_wrapper.get_id_tag()}")
return
job_destination = job_wrapper.job_destination
chronos_job_spec = self._get_job_spec(job_wrapper)
@@ -279,7 +279,7 @@ class ChronosJobRunner(AsynchronousJobRunner):
if not os.path.exists(job_wrapper.working_directory):
LOGGER.error("No working directory found")
path = job_wrapper.working_directory + '/chronos_' + job_wrapper.get_id_tag() + '.sh'
path = f"{job_wrapper.working_directory}/chronos_{job_wrapper.get_id_tag()}.sh"
mode = 0o755
with open(path, 'w', encoding='utf-8') as f:
@@ -295,7 +295,7 @@ class ChronosJobRunner(AsynchronousJobRunner):
template = {
'async': False,
# 'command': job_wrapper.runner_command_line,
'command': '$SHELL ' + command_script_path,
'command': f"$SHELL {command_script_path}",
'owner': self.runner_params['owner'],
'disabled': False,
'schedule': 'R1//PT1S',
+2 -2
View File
@@ -43,8 +43,8 @@ class ShellJobRunner(AsynchronousJobRunner):
params = {}
shell_params, job_params = url.split('/')[2:4]
# split 'foo=bar&baz=quux' into { 'foo' : 'bar', 'baz' : 'quux' }
shell_params = {'shell_' + k: v for k, v in [kv.split('=', 1) for kv in shell_params.split('&')]}
job_params = {'job_' + k: v for k, v in [kv.split('=', 1) for kv in job_params.split('&')]}
shell_params = {f"shell_{k}": v for k, v in [kv.split('=', 1) for kv in shell_params.split('&')]}
job_params = {f"job_{k}": v for k, v in [kv.split('=', 1) for kv in job_params.split('&')]}
params.update(shell_params)
params.update(job_params)
log.debug(f"Converted URL '{url}' to destination runner=cli, params={params}")
+6 -6
View File
@@ -45,8 +45,8 @@ class DRMAAJobRunner(AsynchronousJobRunner):
runner_param_specs = {
'drmaa_library_path': dict(map=str, default=os.environ.get('DRMAA_LIBRARY_PATH', None))}
for retry_exception in RETRY_EXCEPTIONS_LOWER:
runner_param_specs[retry_exception + '_state'] = dict(map=str, valid=lambda x: x in (model.Job.states.OK, model.Job.states.ERROR), default=model.Job.states.OK)
runner_param_specs[retry_exception + '_retries'] = dict(map=int, valid=lambda x: int(x) >= 0, default=0)
runner_param_specs[f"{retry_exception}_state"] = dict(map=str, valid=lambda x: x in (model.Job.states.OK, model.Job.states.ERROR), default=model.Job.states.OK)
runner_param_specs[f"{retry_exception}_retries"] = dict(map=int, valid=lambda x: int(x) >= 0, default=0)
if 'runner_param_specs' not in kwargs:
kwargs['runner_param_specs'] = dict()
@@ -283,11 +283,11 @@ class DRMAAJobRunner(AsynchronousJobRunner):
state = self.ds.job_status(external_job_id)
# Reset exception retries
for retry_exception in RETRY_EXCEPTIONS_LOWER:
setattr(ajs, retry_exception + '_retries', 0)
setattr(ajs, f"{retry_exception}_retries", 0)
except (drmaa.InternalException, drmaa.InvalidJobException) as e:
ecn = type(e).__name__
retry_param = ecn.lower() + '_retries'
state_param = ecn.lower() + '_state'
retry_param = f"{ecn.lower()}_retries"
state_param = f"{ecn.lower()}_state"
retries = getattr(ajs, retry_param, 0)
log.warning("(%s/%s) unable to check job status because of %s exception for %d consecutive tries: %s", galaxy_id_tag, external_job_id, ecn, retries + 1, e)
if self.runner_params[retry_param] > 0:
@@ -436,7 +436,7 @@ class DRMAAJobRunner(AsynchronousJobRunner):
job_name += f'_{job_wrapper.tool.old_id}'
if not self.redact_email_in_job_name and external_runjob_script is None:
job_name += f'_{job_wrapper.user}'
job_name = ''.join(x if x in (string.ascii_letters + string.digits + '_') else '_' for x in job_name)
job_name = ''.join(x if x in (f"{string.ascii_letters + string.digits}_") else '_' for x in job_name)
if self.restrict_job_name_length:
job_name = job_name[:self.restrict_job_name_length]
return job_name
+17 -17
View File
@@ -157,7 +157,7 @@ class GodockerJobRunner(AsynchronousJobRunner):
log.error("Job creation failure. No Response from GoDocker")
job_wrapper.fail("Not submitted")
else:
log.debug("Starting queue_job for job " + job_id)
log.debug(f"Starting queue_job for job {job_id}")
# Create an object of AsynchronousJobState and add it to the monitor queue.
ajs = AsynchronousJobState(files_dir=job_wrapper.working_directory, job_wrapper=job_wrapper, job_id=job_id, job_destination=job_destination)
self.monitor_queue.put(ajs)
@@ -180,7 +180,7 @@ class GodockerJobRunner(AsynchronousJobRunner):
""" Get task from GoDocker """
job_persisted_state = job_state.job_wrapper.get_state()
job_status_god = self.get_task(job_state.job_id)
log.debug("Job ID: " + str(job_state.job_id) + " Job Status: " + str(job_status_god['status']['primary']))
log.debug(f"Job ID: {str(job_state.job_id)} Job Status: {str(job_status_god['status']['primary'])}")
if job_status_god['status']['primary'] == "over" or job_persisted_state == model.Job.states.STOPPED:
job_state.running = False
@@ -234,7 +234,7 @@ class GodockerJobRunner(AsynchronousJobRunner):
No Return data expected
'''
job_id = job_wrapper.job_id
log.debug("STOP JOB EXECUTION OF JOB ID: " + str(job_id))
log.debug(f"STOP JOB EXECUTION OF JOB ID: {str(job_id)}")
# Get task status from GoDocker.
job_status_god = self.get_task_status(job_id)
if job_status_god['status']['primary'] != "over":
@@ -276,8 +276,8 @@ class GodockerJobRunner(AsynchronousJobRunner):
if vol['name'] == "go-docker":
path = str(vol['path'])
if path:
god_output_file = path + "/god.log"
god_error_file = path + "/god.err"
god_output_file = f"{path}/god.log"
god_error_file = f"{path}/god.err"
try:
# Read from GoDocker output_file and write it into galaxy output_file.
f = open(god_output_file)
@@ -299,9 +299,9 @@ class GodockerJobRunner(AsynchronousJobRunner):
log_file.write(out_log)
log_file.close()
f.close()
log.debug("CREATE OUTPUT FILE: " + job_state.output_file)
log.debug("CREATE ERROR FILE: " + job_state.error_file)
log.debug("CREATE EXIT CODE FILE: " + job_state.exit_code_file)
log.debug(f"CREATE OUTPUT FILE: {job_state.output_file}")
log.debug(f"CREATE ERROR FILE: {job_state.error_file}")
log.debug(f"CREATE EXIT CODE FILE: {job_state.exit_code_file}")
except OSError as e:
log.error('Could not access task log file: %s', unicodify(e))
log.debug("IO Error occurred when accessing the files.")
@@ -315,7 +315,7 @@ class GodockerJobRunner(AsynchronousJobRunner):
Create Login model schema of GoDocker and call the http_post_request method.
"""
log.debug("LOGIN TASK TO BE EXECUTED \n")
log.debug("GODOCKER LOGIN: " + str(login))
log.debug(f"GODOCKER LOGIN: {str(login)}")
data = json.dumps({'user': login, 'apikey': apikey})
# Create object of Godocker class
g_auth = Godocker(server, login, apikey, noCert)
@@ -378,11 +378,11 @@ class GodockerJobRunner(AsynchronousJobRunner):
if(job_destination.params["virtualenv"] == "true"):
GALAXY_VENV_TEMPLATE = """GALAXY_VIRTUAL_ENV="%s"; if [ "$GALAXY_VIRTUAL_ENV" != "None" -a -z "$VIRTUAL_ENV" -a -f "$GALAXY_VIRTUAL_ENV/bin/activate" ]; then . "$GALAXY_VIRTUAL_ENV/bin/activate"; fi;"""
venv = GALAXY_VENV_TEMPLATE % job_wrapper.galaxy_virtual_env
command = "#!/bin/bash\n" + "cd " + job_wrapper.working_directory + "\n" + venv + "\n" + job_wrapper.runner_command_line
command = f"#!/bin/bash\ncd {job_wrapper.working_directory}\n{venv}\n{job_wrapper.runner_command_line}"
else:
command = "#!/bin/bash\n" + "cd " + job_wrapper.working_directory + "\n" + job_wrapper.runner_command_line
command = f"#!/bin/bash\ncd {job_wrapper.working_directory}\n{job_wrapper.runner_command_line}"
except Exception:
command = "#!/bin/bash\n" + "cd " + job_wrapper.working_directory + "\n" + job_wrapper.runner_command_line
command = f"#!/bin/bash\ncd {job_wrapper.working_directory}\n{job_wrapper.runner_command_line}"
# GoDocker Job model schema
job = {
@@ -424,7 +424,7 @@ class GodockerJobRunner(AsynchronousJobRunner):
result = self.auth.http_post_request(
"/api/1.0/task", json.dumps(job),
{'Authorization': 'Bearer ' + self.auth.token, 'Content-type': 'application/json', 'Accept': 'application/json'}
{'Authorization': f"Bearer {self.auth.token}", 'Content-type': 'application/json', 'Accept': 'application/json'}
)
# Return job_id
return str(result.json()['id'])
@@ -435,7 +435,7 @@ class GodockerJobRunner(AsynchronousJobRunner):
"""
job = False
if self.auth.token:
result = self.auth.http_get_request("/api/1.0/task/" + str(job_id), {'Authorization': 'Bearer ' + self.auth.token})
result = self.auth.http_get_request(f"/api/1.0/task/{str(job_id)}", {'Authorization': f"Bearer {self.auth.token}"})
job = result.json()
# Return the job
return job
@@ -446,7 +446,7 @@ class GodockerJobRunner(AsynchronousJobRunner):
"""
job = False
if self.auth.token:
result = self.auth.http_get_request("/api/1.0/task/" + str(job_id) + "/suspend", {'Authorization': 'Bearer ' + self.auth.token})
result = self.auth.http_get_request(f"/api/1.0/task/{str(job_id)}/suspend", {'Authorization': f"Bearer {self.auth.token}"})
job = result.json()
# Return the job
return job
@@ -457,7 +457,7 @@ class GodockerJobRunner(AsynchronousJobRunner):
"""
job = False
if self.auth.token:
result = self.auth.http_get_request("/api/1.0/task/" + str(job_id) + "/status", {'Authorization': 'Bearer ' + self.auth.token})
result = self.auth.http_get_request(f"/api/1.0/task/{str(job_id)}/status", {'Authorization': f"Bearer {self.auth.token}"})
job = result.json()
# Return task status
return job
@@ -468,7 +468,7 @@ class GodockerJobRunner(AsynchronousJobRunner):
"""
job = False
if self.auth.token:
result = self.auth.http_delete_request("/api/1.0/task/" + str(job_id), {'Authorization': 'Bearer ' + self.auth.token})
result = self.auth.http_delete_request(f"/api/1.0/task/{str(job_id)}", {'Authorization': f"Bearer {self.auth.token}"})
job = result.json()
# Return the job
return job
+6 -6
View File
@@ -127,7 +127,7 @@ class KubernetesJobRunner(AsynchronousJobRunner):
# prepare the job
# We currently don't need to include_metadata or include_work_dir_outputs, as working directory is the same
# where galaxy will expect results.
log.debug("Starting queue_job for job " + job_wrapper.get_id_tag())
log.debug(f"Starting queue_job for job {job_wrapper.get_id_tag()}")
ajs = AsynchronousJobState(files_dir=job_wrapper.working_directory,
job_wrapper=job_wrapper,
job_destination=job_wrapper.job_destination)
@@ -240,7 +240,7 @@ class KubernetesJobRunner(AsynchronousJobRunner):
"""
label_val = self.LABEL_REGEX.sub("_", value)
if not self.LABEL_START.search(label_val):
label_val = 'x' + label_val
label_val = f"x{label_val}"
if not self.LABEL_END.search(label_val):
label_val += 'x'
return label_val
@@ -521,14 +521,14 @@ class KubernetesJobRunner(AsynchronousJobRunner):
repo = ""
owner = ""
if 'repo' in job_destination.params:
repo = job_destination.params['repo'] + "/"
repo = f"{job_destination.params['repo']}/"
if 'owner' in job_destination.params:
owner = job_destination.params['owner'] + "/"
owner = f"{job_destination.params['owner']}/"
k8s_cont_image = repo + owner + job_destination.params['image']
if 'tag' in job_destination.params:
k8s_cont_image += ":" + job_destination.params['tag']
k8s_cont_image += f":{job_destination.params['tag']}"
return k8s_cont_image
@@ -788,7 +788,7 @@ class KubernetesJobRunner(AsynchronousJobRunner):
def recover(self, job, job_wrapper):
"""Recovers jobs stuck in the queued/running state when Galaxy started"""
job_id = job.get_job_runner_external_id()
log.debug("k8s trying to recover job: " + job_id)
log.debug(f"k8s trying to recover job: {job_id}")
if job_id is None:
self.put(job_wrapper)
return
+4 -4
View File
@@ -140,7 +140,7 @@ class PBSJobRunner(AsynchronousJobRunner):
assert opts != ['']
# stripping the - comes later (in parse_destination_params)
for i, opt in enumerate(opts):
opts[i] = '-' + opt
opts[i] = f"-{opt}"
except Exception:
opts = []
for opt in opts:
@@ -184,7 +184,7 @@ class PBSJobRunner(AsynchronousJobRunner):
rval.append(dict(name=pbs.ATTR_l, value=val, resource=res))
else:
try:
rval.append(dict(name=getattr(pbs, 'ATTR_' + arg), value=value))
rval.append(dict(name=getattr(pbs, f"ATTR_{arg}"), value=value))
except AttributeError as e:
raise Exception(f"Invalid parameter '{arg}': {e}")
return rval
@@ -242,8 +242,8 @@ class PBSJobRunner(AsynchronousJobRunner):
# If an application server is set, we're staging
if self.app.config.pbs_application_server:
pbs_ofile = self.app.config.pbs_application_server + ':' + ofile
pbs_efile = self.app.config.pbs_application_server + ':' + efile
pbs_ofile = f"{self.app.config.pbs_application_server}:{ofile}"
pbs_efile = f"{self.app.config.pbs_application_server}:{efile}"
output_files = [str(o) for o in output_fnames]
output_files.append(ecfile)
stagein = self.get_stage_in_out(job_wrapper.get_input_fnames() + output_files, symlink=True)
+1 -1
View File
@@ -85,7 +85,7 @@ class SlurmJobRunner(DRMAAJobRunner):
job_info_values.append(v)
except ValueError:
# Some value may contain spaces (e.g. `Comment=** time_limit (60m) min_nodes (1) **`)
job_info_values[-1] += ' ' + job_info
job_info_values[-1] += f" {job_info}"
job_info_dict = dict(zip(job_info_keys, job_info_values))
return job_info_dict['JobState']
+2 -2
View File
@@ -66,7 +66,7 @@ class LSF(BaseJobExec):
return "bjobs -a -o \"id stat\" -noheader" # check this
def get_single_status(self, job_id):
return "bjobs -o stat -noheader " + job_id
return f"bjobs -o stat -noheader {job_id}"
def parse_status(self, status, job_ids):
# Get status for each job, skipping header.
@@ -91,7 +91,7 @@ class LSF(BaseJobExec):
return self._get_job_state(status)
def get_failure_reason(self, job_id):
return "bjobs -l " + job_id
return f"bjobs -l {job_id}"
def parse_failure_reason(self, reason, job_id):
# LSF will produce the following in the job output file:
@@ -52,7 +52,7 @@ class Slurm(BaseJobExec):
return "squeue -a -o '%A %t'"
def get_single_status(self, job_id):
return "squeue -a -o '%A %t' -j " + job_id
return f"squeue -a -o '%A %t' -j {job_id}"
def parse_status(self, status, job_ids):
# Get status for each job, skipping header.
@@ -60,10 +60,10 @@ def build_submit_description(executable, output, error, user_log, query_params):
submit_description = []
for key, value in all_query_params.items():
submit_description.append(f'{key} = {value}')
submit_description.append('executable = ' + executable)
submit_description.append('output = ' + output)
submit_description.append('error = ' + error)
submit_description.append('log = ' + user_log)
submit_description.append(f"executable = {executable}")
submit_description.append(f"output = {output}")
submit_description.append(f"error = {error}")
submit_description.append(f"log = {user_log}")
submit_description.append('queue')
return '\n'.join(submit_description)
@@ -109,15 +109,15 @@ def summarize_condor_log(log_file, external_id):
s1 = s4 = s7 = s5 = s9 = False
with open(log_file) as log_handle:
for line in log_handle:
if '001 (' + log_job_id + '.' in line:
if f"001 ({log_job_id}." in line:
s1 = True
if '004 (' + log_job_id + '.' in line:
if f"004 ({log_job_id}." in line:
s4 = True
if '007 (' + log_job_id + '.' in line:
if f"007 ({log_job_id}." in line:
s7 = True
if '005 (' + log_job_id + '.' in line:
if f"005 ({log_job_id}." in line:
s5 = True
if '009 (' + log_job_id + '.' in line:
if f"009 ({log_job_id}." in line:
s9 = True
file_size = log_handle.tell()
return s1, s4, s7, s5, s9, file_size
+2 -2
View File
@@ -83,7 +83,7 @@ def find_job_object_by_name(pykube_api, job_name, namespace=None):
def find_pod_object_by_name(pykube_api, job_name, namespace=None):
return Pod.objects(pykube_api).filter(selector="job-name=" + job_name, namespace=namespace)
return Pod.objects(pykube_api).filter(selector=f"job-name={job_name}", namespace=namespace)
def is_pod_unschedulable(pykube_api, pod, namespace=None):
@@ -145,7 +145,7 @@ def job_object_dict(params, job_prefix, spec):
"apiVersion": params.get('k8s_job_api_version', DEFAULT_JOB_API_VERSION),
"kind": "Job",
"metadata": {
"generateName": job_prefix + "-",
"generateName": f"{job_prefix}-",
"namespace": params.get('k8s_namespace', DEFAULT_NAMESPACE),
},
"spec": spec,
+4 -4
View File
@@ -101,7 +101,7 @@ def do_split(job_wrapper):
for file in names:
os.symlink(file, os.path.join(dir, os.path.basename(file)))
tasks = []
prepare_files = os.path.join(util.galaxy_directory(), 'extract_dataset_parts.sh') + ' %s'
prepare_files = f"{os.path.join(util.galaxy_directory(), 'extract_dataset_parts.sh')} %s"
for dir in task_dirs:
task = model.Task(parent_job, dir, prepare_files % dir)
tasks.append(task)
@@ -167,7 +167,7 @@ def do_merge(job_wrapper, task_wrappers):
msg = 'nothing to merge for %s (expected %i files)' \
% (output_file_name, len(task_dirs))
log.debug(msg)
stderr += msg + "\n"
stderr += f"{msg}\n"
elif output in pickone_outputs:
# just pick one of them
if output not in pickone_done:
@@ -189,7 +189,7 @@ def do_merge(job_wrapper, task_wrappers):
out = tw.get_task().stdout.strip()
err = tw.get_task().stderr.strip()
if len(out) > 0:
stdout += "\n" + tw.working_directory + ':\n' + out
stdout += f"\n{tw.working_directory}:\n{out}"
if len(err) > 0:
stderr += "\n" + tw.working_directory + ':\n' + err
stderr += f"\n{tw.working_directory}:\n{err}"
return (stdout, stderr)
+5 -5
View File
@@ -267,9 +267,9 @@ class ModelManager:
try:
return query.one()
except sqlalchemy.orm.exc.NoResultFound:
raise exceptions.ObjectNotFound(self.model_class.__name__ + ' not found')
raise exceptions.ObjectNotFound(f"{self.model_class.__name__} not found")
except sqlalchemy.orm.exc.MultipleResultsFound:
raise exceptions.InconsistentDatabase('found more than one ' + self.model_class.__name__)
raise exceptions.InconsistentDatabase(f"found more than one {self.model_class.__name__}")
def _one_or_none(self, query):
"""
@@ -622,7 +622,7 @@ class ModelSerializer(HasAModelManager):
return self.serializers[original_key]
if original_key in self.serializable_keyset:
return lambda i, k, **c: self.default_serializer(i, original_key, **c)
raise KeyError('serializer not found for remap: ' + original_key)
raise KeyError(f"serializer not found for remap: {original_key}")
def default_serializer(self, item, key, **context):
"""
@@ -1053,7 +1053,7 @@ class ModelFilterParser(HasAModelManager):
# correct op_string to usable function key
fn_name = op_string
if op_string in self.UNDERSCORED_OPS:
fn_name = '__' + op_string + '__'
fn_name = f"__{op_string}__"
elif op_string == 'in':
fn_name = 'in_'
@@ -1084,7 +1084,7 @@ class ModelFilterParser(HasAModelManager):
return True
if bool_string in ('False', False):
return False
raise ValueError('invalid boolean: ' + str(bool_string))
raise ValueError(f"invalid boolean: {str(bool_string)}")
def parse_id_list(self, id_list_string, sep=','):
"""
+1 -1
View File
@@ -46,7 +46,7 @@ class DoiCache:
self._cache = CacheManager(**parse_cache_config_options(cache_opts)).get_cache('doi')
def _raw_get_bibtex(self, doi):
doi_url = "https://doi.org/" + doi
doi_url = f"https://doi.org/{doi}"
headers = {'Accept': 'application/x-bibtex'}
req = requests.get(doi_url, headers=headers)
req.encoding = req.apparent_encoding
+2 -2
View File
@@ -92,7 +92,7 @@ class LibraryFolderAsContainerManagerMixin(ContainerManagerMixin):
return self.lda_manager
elif isinstance(content, model.LibraryFolder):
return self.folder_manager
raise TypeError('Unknown contents class: ' + str(content))
raise TypeError(f"Unknown contents class: {str(content)}")
class DatasetCollectionAsContainerManagerMixin(ContainerManagerMixin):
@@ -111,4 +111,4 @@ class DatasetCollectionAsContainerManagerMixin(ContainerManagerMixin):
return self.collection_manager
elif isinstance(content, model.DatasetCollection):
return self.collection_manager
raise TypeError('Unknown contents class: ' + str(content))
raise TypeError(f"Unknown contents class: {str(content)}")
+2 -2
View File
@@ -489,7 +489,7 @@ class _UnflattenedMetadataDatasetAssociationSerializer(base.ModelSerializer,
'genome_build': lambda i, k, **c: i.dbkey,
# derived (not mapped) attributes
'data_type': lambda i, k, **c: i.datatype.__class__.__module__ + '.' + i.datatype.__class__.__name__,
'data_type': lambda i, k, **c: f"{i.datatype.__class__.__module__}.{i.datatype.__class__.__name__}",
'converted': self.serialize_converted_datasets,
# TODO: metadata/extra files
@@ -636,7 +636,7 @@ class DatasetAssociationSerializer(_UnflattenedMetadataDatasetAssociationSeriali
# prefix each key within and return
prefixed = {}
for key, val in metadata.items():
prefixed_key = 'metadata_' + key
prefixed_key = f"metadata_{key}"
prefixed[prefixed_key] = val
return prefixed
+1 -1
View File
@@ -25,7 +25,7 @@ def artifact_class(trans, as_dict):
else:
for item in graph:
found_id = item.get("id")
if found_id == object_id or found_id == "#" + object_id:
if found_id == object_id or found_id == f"#{object_id}":
target_object = item
if target_object and target_object.get("class"):
+2 -2
View File
@@ -135,9 +135,9 @@ class FolderManager:
"""
folder_dict = folder.to_dict(view='element')
folder_dict = trans.security.encode_all_ids(folder_dict, True)
folder_dict['id'] = 'F' + folder_dict['id']
folder_dict['id'] = f"F{folder_dict['id']}"
if folder_dict['parent_id'] is not None:
folder_dict['parent_id'] = 'F' + folder_dict['parent_id']
folder_dict['parent_id'] = f"F{folder_dict['parent_id']}"
folder_dict['update_time'] = folder.update_time.strftime("%Y-%m-%d %I:%M %p")
return folder_dict
+3 -3
View File
@@ -45,7 +45,7 @@ class LDDAManager(DatasetAssociationManager):
else:
invalid_access_roles_ids.append(role_id)
if len(invalid_access_roles_ids) > 0:
log.warning("The following roles could not be added to the dataset access permission: " + str(invalid_access_roles_ids))
log.warning(f"The following roles could not be added to the dataset access permission: {str(invalid_access_roles_ids)}")
access_permission = dict(access=valid_access_roles)
trans.app.security_agent.set_dataset_permission(dataset, access_permission)
@@ -61,7 +61,7 @@ class LDDAManager(DatasetAssociationManager):
else:
invalid_manage_roles_ids.append(role_id)
if len(invalid_manage_roles_ids) > 0:
log.warning("The following roles could not be added to the dataset manage permission: " + str(invalid_manage_roles_ids))
log.warning(f"The following roles could not be added to the dataset manage permission: {str(invalid_manage_roles_ids)}")
manage_permission = {trans.app.security_agent.permitted_actions.DATASET_MANAGE_PERMISSIONS: valid_manage_roles}
trans.app.security_agent.set_dataset_permission(dataset, manage_permission)
@@ -76,6 +76,6 @@ class LDDAManager(DatasetAssociationManager):
else:
invalid_modify_roles_ids.append(role_id)
if len(invalid_modify_roles_ids) > 0:
log.warning("The following roles could not be added to the dataset modify permission: " + str(invalid_modify_roles_ids))
log.warning(f"The following roles could not be added to the dataset modify permission: {str(invalid_modify_roles_ids)}")
modify_permission = {trans.app.security_agent.permitted_actions.LIBRARY_MODIFY: valid_modify_roles}
trans.app.security_agent.set_library_item_permission(library_dataset, modify_permission)
+6 -6
View File
@@ -56,7 +56,7 @@ class LibraryManager:
except NoResultFound:
raise exceptions.RequestParameterInvalidException('No library found with the id provided.')
except Exception as e:
raise exceptions.InternalServerError('Error loading from the database.' + unicodify(e))
raise exceptions.InternalServerError(f"Error loading from the database.{unicodify(e)}")
library = self.secure(trans, library, check_accessible)
return library
@@ -558,7 +558,7 @@ class LibrariesManager:
else:
invalid_access_roles_names.append(role_id)
if len(invalid_access_roles_names) > 0:
log.warning("The following roles could not be added to the library access permission: " + str(invalid_access_roles_names))
log.warning(f"The following roles could not be added to the library access permission: {str(invalid_access_roles_names)}")
# ADD TO LIBRARY ROLES
valid_add_roles = []
@@ -571,7 +571,7 @@ class LibrariesManager:
else:
invalid_add_roles_names.append(role_id)
if len(invalid_add_roles_names) > 0:
log.warning("The following roles could not be added to the add library item permission: " + str(invalid_add_roles_names))
log.warning(f"The following roles could not be added to the add library item permission: {str(invalid_add_roles_names)}")
# MANAGE LIBRARY ROLES
valid_manage_roles = []
@@ -584,7 +584,7 @@ class LibrariesManager:
else:
invalid_manage_roles_names.append(role_id)
if len(invalid_manage_roles_names) > 0:
log.warning("The following roles could not be added to the manage library permission: " + str(invalid_manage_roles_names))
log.warning(f"The following roles could not be added to the manage library permission: {str(invalid_manage_roles_names)}")
# MODIFY LIBRARY ROLES
valid_modify_roles = []
@@ -597,7 +597,7 @@ class LibrariesManager:
else:
invalid_modify_roles_names.append(role_id)
if len(invalid_modify_roles_names) > 0:
log.warning("The following roles could not be added to the modify library permission: " + str(invalid_modify_roles_names))
log.warning(f"The following roles could not be added to the modify library permission: {str(invalid_modify_roles_names)}")
permissions = {trans.app.security_agent.permitted_actions.LIBRARY_ACCESS: valid_access_roles}
permissions.update({trans.app.security_agent.permitted_actions.LIBRARY_ADD: valid_add_roles})
@@ -623,7 +623,7 @@ class LibrariesManager:
params = util.Params(payload)
permissions = {}
for k, v in trans.app.model.Library.permitted_actions.items():
role_params = params.get(k + '_in', [])
role_params = params.get(f"{k}_in", [])
in_roles = [trans.sa_session.query(trans.app.model.Role).get(trans.security.decode_id(x)) for x in util.listify(role_params)]
permissions[trans.app.security_agent.get_action(v.action)] = in_roles
trans.app.security_agent.set_all_library_permissions(trans, library, permissions)
+4 -4
View File
@@ -43,7 +43,7 @@ class LibraryDatasetsManager(datasets.DatasetAssociationManager):
try:
ld = trans.sa_session.query(trans.app.model.LibraryDataset).filter(trans.app.model.LibraryDataset.table.c.id == decoded_library_dataset_id).one()
except Exception as e:
raise InternalServerError('Error loading from the database.' + util.unicodify(e))
raise InternalServerError(f"Error loading from the database.{util.unicodify(e)}")
ld = self.secure(trans, ld, check_accessible)
return ld
@@ -232,7 +232,7 @@ class LibraryDatasetsManager(datasets.DatasetAssociationManager):
if ldda.dataset.uuid:
rval['uuid'] = str(ldda.dataset.uuid)
rval['deleted'] = ld.deleted
rval['folder_id'] = 'F' + rval['folder_id']
rval['folder_id'] = f"F{rval['folder_id']}"
rval['full_path'] = full_path
rval['file_size'] = util.nice_size(int(ldda.get_size()))
rval['date_uploaded'] = ldda.create_time.strftime("%Y-%m-%d %I:%M %p")
@@ -259,10 +259,10 @@ class LibraryDatasetsManager(datasets.DatasetAssociationManager):
path_to_root = []
if folder.parent_id is None:
# We are almost in root
path_to_root.append(('F' + trans.security.encode_id(folder.id), folder.name))
path_to_root.append((f"F{trans.security.encode_id(folder.id)}", folder.name))
else:
# We add the current folder and traverse up one folder.
path_to_root.append(('F' + trans.security.encode_id(folder.id), folder.name))
path_to_root.append((f"F{trans.security.encode_id(folder.id)}", folder.name))
upper_folder = trans.sa_session.query(trans.app.model.LibraryFolder).get(folder.parent_id)
path_to_root.extend(self._build_path(trans, upper_folder))
return path_to_root
+1 -1
View File
@@ -47,7 +47,7 @@ FUNCTION_ARG = r'\s*[\w\|]+\s*=\s*(?:%s)\s*' % ARG_VAL_REGEX
# embed commas between arguments
FUNCTION_MULTIPLE_ARGS = fr'(?P<firstargcall>{FUNCTION_ARG})(?P<restargcalls>(?:,{FUNCTION_ARG})*)'
FUNCTION_MULTIPLE_ARGS_PATTERN = re.compile(FUNCTION_MULTIPLE_ARGS)
FUNCTION_CALL_LINE_TEMPLATE = r'\s*%s\s*\((?:' + FUNCTION_MULTIPLE_ARGS + r')?\)\s*'
FUNCTION_CALL_LINE_TEMPLATE = f"\\s*%s\\s*\\((?:{FUNCTION_MULTIPLE_ARGS})?\\)\\s*"
GALAXY_MARKDOWN_FUNCTION_CALL_LINE = re.compile(FUNCTION_CALL_LINE_TEMPLATE % GALAXY_FLAVORED_MARKDOWN_CONTAINER_REGEX)
WHITE_SPACE_ONLY_PATTERN = re.compile(r"^[\s]+$")
+3 -3
View File
@@ -452,7 +452,7 @@ class ToBasicMarkdownDirectiveHandler(GalaxyInternalMarkdownDirectiveHandler):
def walk_elements(collection, element_prefix=""):
if ":" in collection.collection_type:
for element in collection.elements:
walk_elements(element.child_collection, element_prefix + element.element_identifier + ":")
walk_elements(element.child_collection, f"{element_prefix + element.element_identifier}:")
else:
for element in collection.elements:
markdown_wrapper[0] += f"**Element:** {element_prefix}{element.element_identifier}\n\n"
@@ -495,7 +495,7 @@ class ToBasicMarkdownDirectiveHandler(GalaxyInternalMarkdownDirectiveHandler):
markdown += "| "
depth = parameter["depth"]
if depth > 1:
markdown += ">" * (parameter["depth"] - 1) + " "
markdown += f"{'>' * (parameter['depth'] - 1)} "
markdown += parameter["text"]
markdown += " | "
value = parameter["value"]
@@ -767,7 +767,7 @@ def _remap_galaxy_markdown_calls(func, markdown):
if matching_line:
match = GALAXY_MARKDOWN_FUNCTION_CALL_LINE.match(line)
return func(match.group(1), matching_line + "\n")
return func(match.group(1), f"{matching_line}\n")
else:
return (container, True)
+2 -2
View File
@@ -485,9 +485,9 @@ class PageContentProcessor(HTMLParser):
def _shorttag_replace(self, match):
tag = match.group(1)
if tag in self.elements_no_end_tag:
return '<' + tag + ' />'
return f"<{tag} />"
else:
return '<' + tag + '></' + tag + '>'
return f"<{tag}></{tag}>"
def feed(self, data):
data = re.compile(r'<!((?!DOCTYPE|--|\[))', re.IGNORECASE).sub(r'&lt;!\1', data)
+1 -1
View File
@@ -81,7 +81,7 @@ class DatasetRBACPermission(RBACPermission):
# ---- double secrect probation
def __assert_action(self):
if not self.action_name:
raise NotImplementedError("abstract parent class" + " needs action_name")
raise NotImplementedError(f"abstract parent class needs action_name")
# ---- interface
def by_dataset(self, dataset):
+1 -1
View File
@@ -73,7 +73,7 @@ class RoleManager(base.ModelManager):
except sqlalchemy_exceptions.NoResultFound:
raise galaxy.exceptions.RequestParameterInvalidException('No accessible role found with the id provided.')
except Exception as e:
raise galaxy.exceptions.InternalServerError('Error loading from the database.' + unicodify(e))
raise galaxy.exceptions.InternalServerError(f"Error loading from the database.{unicodify(e)}")
if not (trans.user_is_admin or trans.app.security_agent.ok_to_display(trans.user, role)):
raise galaxy.exceptions.RequestParameterInvalidException('No accessible role found with the id provided.')
+2 -2
View File
@@ -21,7 +21,7 @@ def _tag_str_gen(item):
for tag in item.tags:
tag_str = tag.user_tname
if tag.value is not None:
tag_str += ":" + tag.user_value
tag_str += f":{tag.user_value}"
yield tag_str
@@ -111,7 +111,7 @@ class TaggableFilterMixin:
class_name = 'HistoryDatasetCollection'
target_model = getattr(model, f"{class_name}TagAssociation")
id_column = f"{target_model.table.name.rsplit('_tag_association')[0]}_id"
column = target_model.table.c.user_tname + ":" + target_model.table.c.user_value
column = f"{target_model.table.c.user_tname}:{target_model.table.c.user_value}"
if op == 'eq':
if ':' not in val:
# We require an exact match and the tag to look for has no user_value,
+4 -4
View File
@@ -426,7 +426,7 @@ class UserManager(base.ModelManager, deletable.PurgableManagerMixin):
# boil the tag tuples down into a sorted list of DISTINCT name:val strings
tags = all_tags_query.distinct().all()
tags = [((name + ':' + val) if val else name) for name, val in tags]
tags = [(f"{name}:{val}" if val else name) for name, val in tags]
return sorted(tags)
def change_password(self, trans, password=None, confirm=None, token=None, id=None, current=None):
@@ -493,7 +493,7 @@ class UserManager(base.ModelManager, deletable.PurgableManagerMixin):
host = self.__get_host(trans)
custom_message = ''
if self.app.config.custom_activation_email_message:
custom_message = self.app.config.custom_activation_email_message + '\n\n'
custom_message = f"{self.app.config.custom_activation_email_message}\n\n"
body = ("Hello %s,\n\n"
"In order to complete the activation process for %s begun on %s at %s, please click "
"on the following link to verify your account:\n\n" "%s \n\n"
@@ -518,7 +518,7 @@ class UserManager(base.ModelManager, deletable.PurgableManagerMixin):
custom_message)
)
to = email
frm = self.app.config.email_from or 'galaxy-no-reply@' + host
frm = self.app.config.email_from or f"galaxy-no-reply@{host}"
subject = 'Galaxy Account Activation'
try:
util.send_mail(frm, to, subject, body, self.app.config)
@@ -558,7 +558,7 @@ class UserManager(base.ModelManager, deletable.PurgableManagerMixin):
reset_url = url_for(controller='root', action='login', token=prt.token)
body = PASSWORD_RESET_TEMPLATE % (host, prt.expiration_time.strftime(trans.app.config.pretty_datetime_format),
trans.request.host, reset_url)
frm = trans.app.config.email_from or 'galaxy-no-reply@' + host
frm = trans.app.config.email_from or f"galaxy-no-reply@{host}"
subject = 'Galaxy Password Reset'
try:
util.send_mail(frm, email, subject, body, self.app.config)
+3 -3
View File
@@ -721,17 +721,17 @@ class WorkflowContentsManager(UsesAnnotations):
nested_input_dict = {}
index = repeat_values[i]['__index__']
nested_input_dict["title"] = "%i. %s" % (i + 1, input.title)
nested_input_dict["inputs"] = do_inputs(input.inputs, repeat_values[i], prefix + input.name + "_" + str(index) + "|", step, other_values)
nested_input_dict["inputs"] = do_inputs(input.inputs, repeat_values[i], f"{prefix + input.name}_{str(index)}|", step, other_values)
nested_input_dicts.append(nested_input_dict)
input_dict["inputs"] = nested_input_dicts
elif input.type == "conditional":
group_values = values[input.name]
current_case = group_values['__current_case__']
new_prefix = prefix + input.name + "|"
new_prefix = f"{prefix + input.name}|"
row_for_param(input_dict, input.test_param, group_values[input.test_param.name], other_values, prefix, step)
input_dict["inputs"] = do_inputs(input.cases[current_case].inputs, group_values, new_prefix, step, other_values)
elif input.type == "section":
new_prefix = prefix + input.name + "|"
new_prefix = f"{prefix + input.name}|"
group_values = values[input.name]
input_dict["title"] = input.title
input_dict["inputs"] = do_inputs(input.inputs, group_values, new_prefix, step, other_values)
+2 -2
View File
@@ -265,10 +265,10 @@ def set_metadata_portable():
dataset.info = (dataset.info or '')
if context['stdout'].strip():
# Ensure white space between entries
dataset.info = dataset.info.rstrip() + "\n" + context['stdout'].strip()
dataset.info = f"{dataset.info.rstrip()}\n{context['stdout'].strip()}"
if context['stderr'].strip():
# Ensure white space between entries
dataset.info = dataset.info.rstrip() + "\n" + context['stderr'].strip()
dataset.info = f"{dataset.info.rstrip()}\n{context['stderr'].strip()}"
dataset.tool_version = version_string
dataset.set_size()
if 'uuid' in context:
+10 -10
View File
@@ -158,7 +158,7 @@ class HasTags:
for tag in self.tags:
tag_str = tag.user_tname
if tag.value is not None:
tag_str += ":" + tag.user_value
tag_str += f":{tag.user_value}"
tags_str_list.append(tag_str)
return tags_str_list
@@ -349,7 +349,7 @@ class JobLike:
def stdout(self):
stdout = self.tool_stdout or ''
if self.job_stdout:
stdout += "\n" + self.job_stdout
stdout += f"\n{self.job_stdout}"
return stdout
@stdout.setter
@@ -360,7 +360,7 @@ class JobLike:
def stderr(self):
stderr = self.tool_stderr or ''
if self.job_stderr:
stderr += "\n" + self.job_stderr
stderr += f"\n{self.job_stderr}"
return stderr
@stderr.setter
@@ -3524,7 +3524,7 @@ class HistoryDatasetAssociation(DatasetInstance, HasTags, Dictifiable, UsesAnnot
file_size=int(hda.get_size()),
create_time=hda.create_time.isoformat(),
update_time=hda.update_time.isoformat(),
data_type=hda.datatype.__class__.__module__ + '.' + hda.datatype.__class__.__name__,
data_type=f"{hda.datatype.__class__.__module__}.{hda.datatype.__class__.__name__}",
genome_build=hda.dbkey,
validated_state=hda.validated_state,
validated_state_message=hda.validated_state_message,
@@ -3552,7 +3552,7 @@ class HistoryDatasetAssociation(DatasetInstance, HasTags, Dictifiable, UsesAnnot
# If no value for metadata, look in datatype for metadata.
elif not hda.metadata.element_is_set(name) and hasattr(hda.datatype, name):
val = getattr(hda.datatype, name)
rval['metadata_' + name] = val
rval[f"metadata_{name}"] = val
return rval
def unpause_dependent_jobs(self, jobs=None):
@@ -3651,7 +3651,7 @@ class Library(Dictifiable, HasName, RepresentById):
"""
rval = super().to_dict(view=view, value_mapper=value_mapper)
if 'root_folder_id' in rval:
rval['root_folder_id'] = 'F' + str(rval['root_folder_id'])
rval['root_folder_id'] = f"F{str(rval['root_folder_id'])}"
return rval
def get_active_folders(self, folder, folders=None):
@@ -3831,7 +3831,7 @@ class LibraryDataset(RepresentById):
update_time=ldda.update_time.isoformat(),
file_size=int(ldda.get_size()),
file_ext=ldda.ext,
data_type=ldda.datatype.__class__.__module__ + '.' + ldda.datatype.__class__.__name__,
data_type=f"{ldda.datatype.__class__.__module__}.{ldda.datatype.__class__.__name__}",
genome_build=ldda.dbkey,
misc_info=ldda.info,
misc_blurb=ldda.blurb,
@@ -3846,7 +3846,7 @@ class LibraryDataset(RepresentById):
val = val.file_name
elif isinstance(val, list):
val = ', '.join(str(v) for v in val)
rval['metadata_' + name] = val
rval[f"metadata_{name}"] = val
return rval
@@ -3975,7 +3975,7 @@ class LibraryDatasetDatasetAssociation(DatasetInstance, HasName, RepresentById):
file_name=ldda.file_name,
update_time=ldda.update_time.isoformat(),
file_ext=ldda.ext,
data_type=ldda.datatype.__class__.__module__ + '.' + ldda.datatype.__class__.__name__,
data_type=f"{ldda.datatype.__class__.__module__}.{ldda.datatype.__class__.__name__}",
genome_build=ldda.dbkey,
misc_info=ldda.info,
misc_blurb=ldda.blurb,
@@ -3994,7 +3994,7 @@ class LibraryDatasetDatasetAssociation(DatasetInstance, HasName, RepresentById):
# If no value for metadata, look in datatype for metadata.
elif val is None and hasattr(ldda.datatype, name):
val = getattr(ldda.datatype, name)
rval['metadata_' + name] = val
rval[f"metadata_{name}"] = val
return rval
def update_parent_folder_update_times(self):
+1 -1
View File
@@ -226,7 +226,7 @@ def library_folder_parent_library_id_filter(item, left, operator, right):
def library_path_filter(item, left, operator, right):
lpath = "/" + "/".join(item.library_path)
lpath = f"/{'/'.join(item.library_path)}"
if operator == '=':
return lpath == right
if operator == '!=':
+4 -4
View File
@@ -104,7 +104,7 @@ class GalaxyRBACAgent(RBACAgent):
roles = []
if query not in [None, '']:
query = query.strip().replace('_', '/_').replace('%', '/%').replace('/', '//')
search_query = query + '%'
search_query = f"{query}%"
else:
search_query = None
# Limit the query only to get the page needed
@@ -718,7 +718,7 @@ class GalaxyRBACAgent(RBACAgent):
def get_sharing_roles(self, user):
return self.sa_session.query(self.model.Role) \
.filter(and_((self.model.Role.table.c.name).like("Sharing role for: %" + user.email + "%"),
.filter(and_((self.model.Role.table.c.name).like(f"Sharing role for: %{user.email}%"),
self.model.Role.table.c.type == self.model.Role.types.SHARING))
def user_set_default_permissions(self, user, permissions=None, history=False, dataset=False, bypass_manage_permission=False, default_access_private=False):
@@ -911,7 +911,7 @@ class GalaxyRBACAgent(RBACAgent):
sharing_role = role
break
if sharing_role is None:
sharing_role = self.model.Role(name="Sharing role for: " + ", ".join(u.email for u in users),
sharing_role = self.model.Role(name=f"Sharing role for: {', '.join(u.email for u in users)}",
type=self.model.Role.types.SHARING)
self.sa_session.add(sharing_role)
self.sa_session.flush()
@@ -1119,7 +1119,7 @@ class GalaxyRBACAgent(RBACAgent):
# Change for removing the prefix '_in' from the roles select box
in_roles = [self.sa_session.query(self.model.Role).get(x) for x in listify(kwd[k])]
if not in_roles:
in_roles = [self.sa_session.query(self.model.Role).get(x) for x in listify(kwd.get(k + '_in', []))]
in_roles = [self.sa_session.query(self.model.Role).get(x) for x in listify(kwd.get(f"{k}_in", []))]
if v == self.permitted_actions.DATASET_ACCESS and in_roles:
if library:
item = self.sa_session.query(self.model.Library).get(item_id)
+3 -3
View File
@@ -794,7 +794,7 @@ class BaseDirectoryImportModelStore(ModelImportStore):
def datasets_properties(self):
datasets_attrs_file_name = os.path.join(self.archive_dir, ATTRS_FILENAME_DATASETS)
datasets_attrs = load(open(datasets_attrs_file_name))
provenance_file_name = datasets_attrs_file_name + ".provenance"
provenance_file_name = f"{datasets_attrs_file_name}.provenance"
if os.path.exists(provenance_file_name):
provenance_attrs = load(open(provenance_file_name))
@@ -1240,7 +1240,7 @@ class DirectoryModelExportStore(ModelExportStore):
with open(datasets_attrs_filename, 'w') as datasets_attrs_out:
datasets_attrs_out.write(to_json(datasets_attrs))
with open(datasets_attrs_filename + ".provenance", 'w') as provenance_attrs_out:
with open(f"{datasets_attrs_filename}.provenance", 'w') as provenance_attrs_out:
provenance_attrs_out.write(to_json(provenance_attrs))
libraries_attrs_filename = os.path.join(export_directory, ATTRS_FILENAME_LIBRARIES)
@@ -1460,7 +1460,7 @@ def get_export_dataset_filename(name, ext, hid):
Builds a filename for a dataset using its name an extension.
"""
base = ''.join(c in FILENAME_VALID_CHARS and c or '_' for c in name)
return base + f"_{hid}.{ext}"
return f"{base}_{hid}.{ext}"
def imported_store_for_metadata(directory, object_store=None):
+3 -3
View File
@@ -204,7 +204,7 @@ class TagHandler:
for tag in tags:
tag_str = tag.user_tname
if tag.value is not None:
tag_str += ":" + tag.user_value
tag_str += f":{tag.user_value}"
tags_str_list.append(tag_str)
return ", ".join(tags_str_list)
@@ -284,7 +284,7 @@ class TagHandler:
# Strip unicode control characters
tag_str = strip_control_characters(tag_str)
# Split tags based on separators.
reg_exp = re.compile('[' + self.tag_separators + ']')
reg_exp = re.compile(f"[{self.tag_separators}]")
raw_tags = reg_exp.split(tag_str)
return self.parse_tags_list(raw_tags)
@@ -344,7 +344,7 @@ class TagHandler:
# Use regular expression to parse name, value.
if tag_str.startswith('#'):
tag_str = f"name:{tag_str[1:]}"
reg_exp = re.compile("[" + self.key_value_separators + "]")
reg_exp = re.compile(f"[{self.key_value_separators}]")
name_value_pair = reg_exp.split(tag_str, 1)
# Add empty slot if tag does not have value.
if len(name_value_pair) < 2:
@@ -383,7 +383,7 @@ class ToolShedRepository(_HasTable):
value_mapper = {}
rval = {}
try:
visible_keys = self.__getattribute__('dict_' + view + '_visible_keys')
visible_keys = self.__getattribute__(f"dict_{view}_visible_keys")
except AttributeError:
raise Exception(f'Unknown API view: {view}')
for key in visible_keys:
+1 -1
View File
@@ -288,7 +288,7 @@ class BaseObjectStore(ObjectStore):
return obj.id
def _invoke(self, delegate, obj=None, **kwargs):
return self.__getattribute__("_" + delegate)(obj=obj, **kwargs)
return self.__getattribute__(f"_{delegate}")(obj=obj, **kwargs)
def exists(self, obj, **kwargs):
return self._invoke('exists', obj, **kwargs)
+15 -15
View File
@@ -210,7 +210,7 @@ class IRODSObjectStore(DiskObjectStore, CloudConfigMixin):
if irods is None:
raise Exception(IRODS_IMPORT_MESSAGE)
self.home = "/" + self.zone + "/home/" + self.username
self.home = f"/{self.zone}/home/{self.username}"
if irods is None:
raise Exception(IRODS_IMPORT_MESSAGE)
@@ -296,8 +296,8 @@ class IRODSObjectStore(DiskObjectStore, CloudConfigMixin):
data_object_name = p.stem + p.suffix
subcollection_name = p.parent
collection_path = self.home + "/" + str(subcollection_name)
data_object_path = collection_path + "/" + str(data_object_name)
collection_path = f"{self.home}/{str(subcollection_name)}"
data_object_path = f"{collection_path}/{str(data_object_name)}"
try:
data_obj = self.session.data_objects.get(data_object_path)
@@ -318,8 +318,8 @@ class IRODSObjectStore(DiskObjectStore, CloudConfigMixin):
data_object_name = p.stem + p.suffix
subcollection_name = p.parent
collection_path = self.home + "/" + str(subcollection_name)
data_object_path = collection_path + "/" + str(data_object_name)
collection_path = f"{self.home}/{str(subcollection_name)}"
data_object_path = f"{collection_path}/{str(data_object_name)}"
try:
self.session.data_objects.get(data_object_path)
@@ -358,8 +358,8 @@ class IRODSObjectStore(DiskObjectStore, CloudConfigMixin):
data_object_name = p.stem + p.suffix
subcollection_name = p.parent
collection_path = self.home + "/" + str(subcollection_name)
data_object_path = collection_path + "/" + str(data_object_name)
collection_path = f"{self.home}/{str(subcollection_name)}"
data_object_path = f"{collection_path}/{str(data_object_name)}"
data_obj = None
try:
@@ -409,8 +409,8 @@ class IRODSObjectStore(DiskObjectStore, CloudConfigMixin):
return False
# Check if the data object exists in iRODS
collection_path = self.home + "/" + str(subcollection_name)
data_object_path = collection_path + "/" + str(data_object_name)
collection_path = f"{self.home}/{str(subcollection_name)}"
data_object_path = f"{collection_path}/{str(data_object_name)}"
exists = False
try:
exists = self.session.data_objects.exists(data_object_path)
@@ -440,7 +440,7 @@ class IRODSObjectStore(DiskObjectStore, CloudConfigMixin):
log.debug("Pushing cache file '%s' of size %s bytes to collection '%s'", source_file, os.path.getsize(source_file), rel_path)
# Add the source file to the irods collection
self.session.data_objects.put(source_file, collection_path + "/", **options)
self.session.data_objects.put(source_file, f"{collection_path}/", **options)
end_time = datetime.now()
log.debug("Pushed cache file '%s' to collection '%s' (%s bytes transfered in %s sec)",
@@ -565,7 +565,7 @@ class IRODSObjectStore(DiskObjectStore, CloudConfigMixin):
if entire_dir and extra_dir:
shutil.rmtree(self._get_cache_path(rel_path))
col_path = self.home + "/" + str(rel_path)
col_path = f"{self.home}/{str(rel_path)}"
col = None
try:
col = self.session.collections.get(col_path)
@@ -600,8 +600,8 @@ class IRODSObjectStore(DiskObjectStore, CloudConfigMixin):
data_object_name = p.stem + p.suffix
subcollection_name = p.parent
collection_path = self.home + "/" + str(subcollection_name)
data_object_path = collection_path + "/" + str(data_object_name)
collection_path = f"{self.home}/{str(subcollection_name)}"
data_object_path = f"{collection_path}/{str(data_object_name)}"
try:
data_obj = self.session.data_objects.get(data_object_path)
@@ -716,8 +716,8 @@ class IRODSObjectStore(DiskObjectStore, CloudConfigMixin):
data_object_name = p.stem + p.suffix
subcollection_name = p.parent
collection_path = self.home + "/" + str(subcollection_name)
data_object_path = collection_path + "/" + str(data_object_name)
collection_path = f"{self.home}/{str(subcollection_name)}"
data_object_path = f"{collection_path}/{str(data_object_name)}"
return data_object_path
+1 -1
View File
@@ -259,7 +259,7 @@ def reload_job_rules(app, **kwargs):
for module in job_rule_modules(app):
rules_module_name = module.__name__
for name, module in sys.modules.items():
if ((name == rules_module_name or name.startswith(rules_module_name + '.'))
if ((name == rules_module_name or name.startswith(f"{rules_module_name}."))
and ismodule(module)):
log.debug("Reloading job rules module: %s", name)
importlib.reload(module)
+1 -1
View File
@@ -121,7 +121,7 @@ class _cipher_cache(collections.defaultdict):
def __missing__(self, key):
assert len(key) < 15, KIND_TOO_LONG_MESSAGE
secret = self.secret_base + "__" + key
secret = f"{self.secret_base}__{key}"
return Blowfish.new(_last_bits(secret), mode=Blowfish.MODE_ECB)
+1 -1
View File
@@ -49,7 +49,7 @@ class SelectorTemplate(Target):
else:
selector = has_selector
return SelectorTemplate(self.selector + " " + selector, self.selector_type, kwds=self.__kwds, children=self._children)
return SelectorTemplate(f"{self.selector} {selector}", self.selector_type, kwds=self.__kwds, children=self._children)
def __call__(self, **kwds):
new_kwds = self.__kwds.copy()
+2 -2
View File
@@ -152,8 +152,8 @@ class NoopDisplay:
def _which(file):
# http://stackoverflow.com/questions/5226958/which-equivalent-function-in-python
for path in os.environ["PATH"].split(":"):
if os.path.exists(path + "/" + file):
return path + "/" + file
if os.path.exists(f"{path}/{file}"):
return f"{path}/{file}"
return None
+6 -6
View File
@@ -184,7 +184,7 @@ class NavigatesGalaxy(HasDriver):
def api_get(self, endpoint, data=None, raw=False):
data = data or {}
full_url = self.build_url("api/" + endpoint, for_selenium=False)
full_url = self.build_url(f"api/{endpoint}", for_selenium=False)
response = requests.get(full_url, data=data, cookies=self.selenium_to_requests_cookies())
if raw:
return response
@@ -193,12 +193,12 @@ class NavigatesGalaxy(HasDriver):
def api_post(self, endpoint, data=None):
data = data or {}
full_url = self.build_url("api/" + endpoint, for_selenium=False)
full_url = self.build_url(f"api/{endpoint}", for_selenium=False)
response = requests.post(full_url, data=data, cookies=self.selenium_to_requests_cookies())
return response.json()
def api_delete(self, endpoint, raw=False):
full_url = self.build_url("api/" + endpoint, for_selenium=False)
full_url = self.build_url(f"api/{endpoint}", for_selenium=False)
response = requests.delete(full_url, cookies=self.selenium_to_requests_cookies())
if raw:
return response
@@ -302,7 +302,7 @@ class NavigatesGalaxy(HasDriver):
self.history_item_wait_for(history_item_selector, allowed_force_refreshes)
except self.TimeoutException as e:
contents_elements = self.find_elements(self.navigation.history_panel.selectors.contents)
div_ids = [("#" + d.get_attribute('id')) for d in contents_elements]
div_ids = [f"#{d.get_attribute('id')}" for d in contents_elements]
template = "Failed waiting on history item %d to become visible, visible datasets include [%s]."
message = template % (hid, ",".join(div_ids))
raise self.prepend_timeout_message(e, message)
@@ -419,7 +419,7 @@ class NavigatesGalaxy(HasDriver):
def _get_random_email(self, username=None, domain=None):
username = username or 'test'
domain = domain or 'test.test'
return self._get_random_name(prefix=username, suffix="@" + domain)
return self._get_random_name(prefix=username, suffix=f"@{domain}")
# Creates a random password of length len by creating an array with all ASCII letters and the numbers 0 to 9,
# then using the random number generator to pick one elemenent to concatinate it to the end of the password string until
@@ -1121,7 +1121,7 @@ class NavigatesGalaxy(HasDriver):
for i, tag in enumerate(tags):
if auto_closes or i == 0:
tag_area = parent_selector + ".tags-input input[type='text']"
tag_area = f"{parent_selector}.tags-input input[type='text']"
tag_area = self.wait_for_selector_clickable(tag_area)
tag_area.click()
@@ -159,10 +159,10 @@ class InstallEnvironment:
# being installed.
llog_name = __name__
if len(job_name) > 0:
llog_name += ':' + job_name
llog_name += f":{job_name}"
llog = logging.getLogger(llog_name)
# Print the command we're about to execute, ``set -x`` style.
llog.debug('+ ' + str(command))
llog.debug(f"+ {str(command)}")
# Launch the command as subprocess. A bufsize of 1 means line buffered.
process_handle = subprocess.Popen(str(command),
stdout=subprocess.PIPE,
+1 -1
View File
@@ -148,7 +148,7 @@ def _to_cwl_tool_object(tool_path=None, tool_object=None, cwl_tool_object=None,
path = tool_directory
if path is None:
path = os.getcwd()
uri = ref_resolver.file_uri(path) + "/"
uri = f"{ref_resolver.file_uri(path)}/"
sourceline.add_lc_filename(tool_object, uri)
raw_process_reference = schema_loader.raw_process_reference_for_object(
tool_object,
+1 -1
View File
@@ -51,7 +51,7 @@ class SchemaLoader:
""")
processed_path = os.path.join(output_dir, os.path.basename(path))
path = os.path.abspath(path)
uri = "file://" + path
uri = f"file://{path}"
loading_context = loading_context or self.loading_context()
if REWRITE_EXPRESSIONS:
from cwl_utils import cwl_v1_0_expression_refactor
+3 -3
View File
@@ -513,7 +513,7 @@ def __action(sys):
def recipe_cellar_path(cellar_path, recipe, version):
recipe_base = recipe.split("/")[-1]
recipe_base_path = os.path.join(cellar_path, recipe_base, version)
revision_paths = glob.glob(recipe_base_path + "_*")
revision_paths = glob.glob(f"{recipe_base_path}_*")
if revision_paths:
revisions = map(lambda x: int(x.rsplit("_", 1)[-1]), revision_paths)
max_revision = max(revisions)
@@ -547,8 +547,8 @@ def ensure_brew_on_path(args):
def which(file):
# http://stackoverflow.com/questions/5226958/which-equivalent-function-in-python
for path in os.environ["PATH"].split(":"):
if os.path.exists(path + "/" + file):
return path + "/" + file
if os.path.exists(f"{path}/{file}"):
return f"{path}/{file}"
return None
@@ -114,7 +114,7 @@ def identifier_to_cached_target(identifier, hash_func, namespace=None):
prefix = ""
if namespace is not None:
prefix = f"quay.io/{namespace}/"
if image_name.startswith(prefix + "mulled-v1-"):
if image_name.startswith(f"{prefix}mulled-v1-"):
if hash_func == "v2":
return None
@@ -123,7 +123,7 @@ def identifier_to_cached_target(identifier, hash_func, namespace=None):
if version and version.isdigit():
build = version
image = CachedV1MulledImageMultiTarget(hash, build, identifier)
elif image_name.startswith(prefix + "mulled-v2-"):
elif image_name.startswith(f"{prefix}mulled-v2-"):
if hash_func == "v1":
return None
+3 -3
View File
@@ -140,13 +140,13 @@ class ContainerFinder:
repo_key = f"{container_type}_repo_{mode}"
owner_key = f"{container_type}_owner_{mode}"
if repo_key in destination_info:
repo = destination_info[repo_key] + "/"
repo = f"{destination_info[repo_key]}/"
if owner_key in destination_info:
owner = destination_info[owner_key] + "/"
owner = f"{destination_info[owner_key]}/"
cont_id = repo + owner + destination_info[f"{container_type}_image_{mode}"]
tag_key = f"{container_type}_tag_{mode}"
if tag_key in destination_info:
cont_id += ":" + destination_info[tag_key]
cont_id += f":{destination_info[tag_key]}"
return cont_id
def __default_container_id(self, container_type, destination_info):
@@ -269,7 +269,7 @@ def mull_targets(
involucro_args.insert(6, '-set')
involucro_args.insert(7, f"TEST_BINDS={','.join(test_bind)}")
cmd = involucro_context.build_command(involucro_args)
print('Executing: ' + ' '.join(shlex.quote(_) for _ in cmd))
print(f"Executing: {' '.join(shlex.quote(_) for _ in cmd)}")
if dry_run:
return 0
ensure_installed(involucro_context, True)
@@ -57,7 +57,7 @@ def generate_targets(target_source):
"""Generate all targets from TSV files in specified file or directory."""
target_source = os.path.abspath(target_source)
if os.path.isdir(target_source):
target_source_files = glob.glob(target_source + "/*.tsv")
target_source_files = glob.glob(f"{target_source}/*.tsv")
else:
target_source_files = [target_source]
@@ -119,7 +119,7 @@ class CondaSearch():
"""
if run_command is None:
raise Exception("Invalid search destination. " + deps_error_message("conda"))
raise Exception(f"Invalid search destination. {deps_error_message('conda')}")
raw_out, err, exit_code = run_command(
'search', '-c',
self.channel,
@@ -22,7 +22,7 @@ def docker_to_singularity(container, installation, filepath, no_sudo=False):
"""
Convert docker to singularity container.
"""
cmd = [installation, 'build', '/'.join((filepath, container)), 'docker://quay.io/biocontainers/' + container]
cmd = [installation, 'build', '/'.join((filepath, container)), f"docker://quay.io/biocontainers/{container}"]
try:
if no_sudo:
check_output(cmd, stderr=subprocess.STDOUT)
@@ -68,7 +68,7 @@ def singularity_container_test(tests, installation, filepath):
if test.get('imports', False):
for imp in test['imports']:
try:
check_output(exec_command.extend([test['import_lang'], 'import ' + imp]), stderr=subprocess.STDOUT)
check_output(exec_command.extend([test['import_lang'], f"import {imp}"]), stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
errors.append({'import': imp, 'output': unicodify(e.output)})
test_passed = False
@@ -168,7 +168,7 @@ def container_testing(args=None):
f.write(f"\n\t\t{container['container']}")
for error in container['errors']:
f.write('\n\t\t\tCOMMAND: {}\n\t\t\t\tERROR:{}'.format(error.get(
'command', 'import' + error.get('import', 'nothing found')), error['output']))
'command', f"import{error.get('import', 'nothing found')}"), error['output']))
f.write('\n\tNO TEST AVAILABLE:')
for container in test_results['notest']:
f.write(f'\n\t\t{container}')
@@ -37,7 +37,7 @@ from .galaxy_packages import BaseGalaxyPackageDependencyResolver
log = logging.getLogger(__name__)
MANUAL = "manual"
PREFERRED_OWNERS = MANUAL + ",iuc,devteam"
PREFERRED_OWNERS = f"{MANUAL},iuc,devteam"
class UnlinkedToolShedPackageDependencyResolver(BaseGalaxyPackageDependencyResolver):
@@ -84,7 +84,7 @@ class UnlinkedToolShedPackageDependencyResolver(BaseGalaxyPackageDependencyResol
for owner in listdir(path):
owner_path = join(path, owner)
for package_name in listdir(owner_path):
if package_name.lower().startswith("package_" + name.lower()):
if package_name.lower().startswith(f"package_{name.lower()}"):
package_path = join(owner_path, package_name)
for revision in listdir(package_path):
revision_path = join(package_path, revision)
+2 -2
View File
@@ -258,12 +258,12 @@ def _find_tool_files(path_or_uri_like, recursive, enable_beta_formats):
else:
if enable_beta_formats:
if not recursive:
files = glob.glob(path + "/*")
files = glob.glob(f"{path}/*")
else:
files = _find_files(path, "*")
else:
if not recursive:
files = glob.glob(path + "/*.xml")
files = glob.glob(f"{path}/*.xml")
else:
files = _find_files(path, "*.xml")
return [os.path.abspath(_) for _ in files]
+1 -1
View File
@@ -19,7 +19,7 @@ class DockStoreResolver(ToolLocationResolver):
tool_id, version = tool_id.split(":", 1)
else:
tool_id, version = tool_id, "latest"
tmp_path = self._temp_path(uri_like + ".cwl")
tmp_path = self._temp_path(f"{uri_like}.cwl")
cwl_str = _Ga4ghToolClient().get_tool_cwl(tool_id, version=version, as_string=True)
with open(tmp_path, "wb") as f:
f.write(cwl_str)
+2 -2
View File
@@ -162,11 +162,11 @@ def __regex_err_msg(match, stream, regex):
that will contain the string matched on.
"""
# Get the description for the error level:
desc = StdioErrorLevel.desc(regex.error_level) + ": "
desc = f"{StdioErrorLevel.desc(regex.error_level)}: "
mstart = match.start()
mend = match.end()
if mend - mstart > 256:
match_str = match.string[mstart:mstart + 256] + "..."
match_str = f"{match.string[mstart:mstart + 256]}..."
else:
match_str = match.string[mstart:mend]
@@ -14,7 +14,7 @@ assertion_module_names = ['text', 'tabular', 'xml', 'hdf5', 'archive', 'size']
# <MODULE_NAME> to the list of assertion module names defined above.
assertion_modules = []
for assertion_module_name in assertion_module_names:
full_assertion_module_name = 'galaxy.tool_util.verify.asserts.' + assertion_module_name
full_assertion_module_name = f"galaxy.tool_util.verify.asserts.{assertion_module_name}"
try:
# Dynamically import module
__import__(full_assertion_module_name)
@@ -33,7 +33,7 @@ def verify_assertions(data, assertion_description_list):
def verify_assertion(data, assertion_description):
tag = assertion_description["tag"]
assert_function_name = "assert_" + tag
assert_function_name = f"assert_{tag}"
assert_function = None
for assertion_module in assertion_modules:
if hasattr(assertion_module, assert_function_name):
+6 -6
View File
@@ -369,7 +369,7 @@ class GalaxyInteractorApi:
if force_path_paste:
file_path = self.test_data_path(tool_id, file_name)
tool_input.update({
"files_%d|url_paste" % i: "file://" + file_path
"files_%d|url_paste" % i: f"file://{file_path}"
})
else:
file_content = self.test_data_download(tool_id, file_name, is_output=False)
@@ -388,7 +388,7 @@ class GalaxyInteractorApi:
if force_path_paste:
file_name = self.test_data_path(tool_id, fname)
tool_input.update({
"files_0|url_paste": "file://" + file_name
"files_0|url_paste": f"file://{file_name}"
})
else:
file_content = self.test_data_download(tool_id, fname, is_output=False)
@@ -1175,11 +1175,11 @@ def _verify_outputs(testdef, history, jobs, tool_id, data_list, data_collection_
for job_message in job_messages:
message_type = job_message.get("type")
if message_type == "regex" and job_message.get("stream") == "stderr":
stderr_prefix += (job_message.get("desc") or '') + "\n"
stderr_prefix += f"{job_message.get('desc') or ''}\n"
elif message_type == "regex" and job_message.get("stream") == "stdout":
stdout_prefix += (job_message.get("desc") or '') + "\n"
stdout_prefix += f"{job_message.get('desc') or ''}\n"
elif message_type == "exit_code":
stderr_prefix += (job_message.get("desc") or '') + "\n"
stderr_prefix += f"{job_message.get('desc') or ''}\n"
else:
raise Exception(f"Unknown job message type [{message_type}] in [{job_message}]")
@@ -1226,7 +1226,7 @@ def _format_stream(output, stream, format):
output = output or ''
if format:
msg = f"---------------------- >> begin tool {stream} << -----------------------\n"
msg += output + "\n"
msg += f"{output}\n"
msg += f"----------------------- >> end tool {stream} << ------------------------\n"
else:
msg = output
+6 -6
View File
@@ -232,14 +232,14 @@ def _test_id_for_reference(test_reference):
tool_version = test_reference.tool_version
test_index = test_reference.test_index
if tool_version and tool_id.endswith("/" + tool_version):
tool_id = tool_id[:-len("/" + tool_version)]
if tool_version and tool_id.endswith(f"/{tool_version}"):
tool_id = tool_id[:-len(f"/{tool_version}")]
label_base = tool_id
if tool_version:
label_base += "/" + str(tool_version)
label_base += f"/{str(tool_version)}"
test_id = label_base + "-" + str(test_index)
test_id = f"{label_base}-{str(test_index)}"
return test_id
@@ -258,8 +258,8 @@ def _test_tool(
test_index = test_reference.test_index
# If given a tool_id with a version suffix, strip it off so we can treat tool_version
# correctly at least in client_test_config.
if tool_version and tool_id.endswith("/" + tool_version):
tool_id = tool_id[:-len("/" + tool_version)]
if tool_version and tool_id.endswith(f"/{tool_version}"):
tool_id = tool_id[:-len(f"/{tool_version}")]
test_id = _test_id_for_reference(test_reference)
+7 -7
View File
@@ -876,7 +876,7 @@ class Tool(Dictifiable):
executable = self.version_string_cmd.split()[0]
abs_executable = os.path.abspath(os.path.join(self.tool_dir, executable))
command_line = self.version_string_cmd.replace(executable, abs_executable, 1)
self.version_string_cmd = version_cmd_interpreter + " " + command_line
self.version_string_cmd = f"{version_cmd_interpreter} {command_line}"
# Parallelism for tasks, read from tool config.
self.parallelism = tool_source.parse_parallelism()
@@ -1149,7 +1149,7 @@ class Tool(Dictifiable):
raise Exception('URL parameters in a non-default tool action can not be used '
'in conjunction with nginx upload. Please convert them to '
'hidden POST parameters')
self.action = (self.app.config.nginx_upload_path + '?nginx_redir=',
self.action = (f"{self.app.config.nginx_upload_path}?nginx_redir=",
unquote_plus(self.action))
self.target = input_elem.get("target", self.target)
self.method = input_elem.get("method", self.method)
@@ -2032,7 +2032,7 @@ class Tool(Dictifiable):
for data_table_filename in data_table.filenames:
# FIXME: from_shed_config seems to always be False.
if not data_table.filenames[data_table_filename]['from_shed_config']:
tar_file = data_table.filenames[data_table_filename]['filename'] + '.sample'
tar_file = f"{data_table.filenames[data_table_filename]['filename']}.sample"
sample_file = os.path.join(data_table.filenames[data_table_filename]['tool_data_path'],
tar_file)
# Use the .sample file, if one exists. If not, skip this data table.
@@ -2550,10 +2550,10 @@ class DataSourceTool(OutputParameterJSONTool):
wrapped_data = param_dict.get(out_name)
# allow multiple files to be created
cur_base_param_name = f'GALAXY|{out_name}|'
cur_name = param_dict.get(cur_base_param_name + 'name', name)
cur_dbkey = param_dict.get(cur_base_param_name + 'dkey', dbkey)
cur_info = param_dict.get(cur_base_param_name + 'info', info)
cur_data_type = param_dict.get(cur_base_param_name + 'data_type', data_type)
cur_name = param_dict.get(f"{cur_base_param_name}name", name)
cur_dbkey = param_dict.get(f"{cur_base_param_name}dkey", dbkey)
cur_info = param_dict.get(f"{cur_base_param_name}info", info)
cur_data_type = param_dict.get(f"{cur_base_param_name}data_type", data_type)
if cur_name:
data.name = cur_name
if not data.info and cur_info:
+1 -1
View File
@@ -801,7 +801,7 @@ class DefaultToolAction:
def _get_default_data_name(self, dataset, tool, on_text=None, trans=None, incoming=None, history=None, params=None, job_params=None, **kwd):
name = tool.name
if on_text:
name += (" on " + on_text)
name += f" on {on_text}"
return name
+2 -2
View File
@@ -764,10 +764,10 @@ class TabularToolDataField(Dictifiable):
return path
def clean_base_dir(self, path):
return re.sub("^" + self.get_base_dir() + r"/*", "", path)
return re.sub(f"^{self.get_base_dir()}/*", "", path)
def get_files(self):
return glob(self.get_base_path() + "*")
return glob(f"{self.get_base_path()}*")
def get_filesize_map(self, rm_base_dir=False):
out = {}
+3 -3
View File
@@ -142,7 +142,7 @@ def _fetch_target(upload_config, target):
name = item.get("name") or 'Composite Dataset'
dataset_bunch.name = name
primary_file = sniff.stream_to_file(StringIO(datatype.generate_primary_file(dataset_bunch)), prefix='upload_auto_primary_file', dir=".")
extra_files_path = primary_file + "_extra"
extra_files_path = f"{primary_file}_extra"
os.mkdir(extra_files_path)
rval = {
"name": name,
@@ -172,7 +172,7 @@ def _fetch_target(upload_config, target):
key,
writable_file.is_binary,
".",
os.path.basename(extra_files_path) + "_",
f"{os.path.basename(extra_files_path)}_",
composite_item,
)
composite_item_idx += 1
@@ -262,7 +262,7 @@ def _fetch_target(upload_config, target):
if extra_files:
# TODO: optimize to just copy the whole directory to extra files instead.
assert not upload_config.link_data_only, "linking composite dataset files not yet implemented"
extra_files_path = path + "_extra"
extra_files_path = f"{path}_extra"
staged_extra_files = extra_files_path
os.mkdir(extra_files_path)
@@ -56,7 +56,7 @@ class BaseGitPlugin(ErrorPlugin, metaclass=ABCMeta):
return None
try:
if job.tool_id not in self.ts_repo_cache:
ts_repo_request_data = requests.get(ts_url + "/api/repositories?tool_ids=" + str(job.tool_id)).json()
ts_repo_request_data = requests.get(f"{ts_url}/api/repositories?tool_ids={str(job.tool_id)}").json()
for repoinfo in ts_repo_request_data.values():
if isinstance(repoinfo, dict):
+1 -1
View File
@@ -244,7 +244,7 @@ class EmailErrorReporter(ErrorReporter):
frm = self.app.config.email_from
error_msg = validate_email_str(email)
if not error_msg and self._can_access_dataset(user):
to += ', ' + email.strip()
to += f", {email.strip()}"
subject = f"Galaxy tool error report from {email}"
try:
subject = "{} ({})".format(
+1 -1
View File
@@ -27,7 +27,7 @@ def evaluate(config, input):
close_fds=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
input_str = json.dumps(new_input) + "\n\n"
input_str = f"{json.dumps(new_input)}\n\n"
input_bytes = input_str.encode("utf-8")
(stdoutdata, stderrdata) = sp.communicate(input_bytes)
if sp.returncode != 0:
+8 -8
View File
@@ -162,7 +162,7 @@ def visit_input_values(inputs, input_values, callback, name_prefix='', label_pre
visit_input_values(input.inputs, d, callback, new_name_prefix, new_label_prefix, parent_prefix=new_name_prefix, **payload)
elif isinstance(input, Conditional):
values = input_values[input.name] = input_values.get(input.name, {})
new_name_prefix = name_prefix + input.name + '|'
new_name_prefix = f"{name_prefix + input.name}|"
case_error = None if get_current_case(input, values) >= 0 else 'The selected case is unavailable/invalid.'
callback_helper(input.test_param, values, new_name_prefix, label_prefix, parent_prefix=name_prefix, context=context, error=case_error)
values['__current_case__'] = get_current_case(input, values)
@@ -170,7 +170,7 @@ def visit_input_values(inputs, input_values, callback, name_prefix='', label_pre
visit_input_values(input.cases[values['__current_case__']].inputs, values, callback, new_name_prefix, label_prefix, parent_prefix=name_prefix, **payload)
elif isinstance(input, Section):
values = input_values[input.name] = input_values.get(input.name, {})
new_name_prefix = name_prefix + input.name + '|'
new_name_prefix = f"{name_prefix + input.name}|"
visit_input_values(input.inputs, values, callback, new_name_prefix, label_prefix, parent_prefix=name_prefix, **payload)
else:
callback_helper(input, input_values, name_prefix, label_prefix, parent_prefix=parent_prefix, context=context)
@@ -260,12 +260,12 @@ def params_to_incoming(incoming, inputs, input_values, app, name_prefix=""):
elif isinstance(input, Conditional):
values = input_values[input.name]
current = values['__current_case__']
new_name_prefix = name_prefix + input.name + '|'
new_name_prefix = f"{name_prefix + input.name}|"
incoming[new_name_prefix + input.test_param.name] = values[input.test_param.name]
params_to_incoming(incoming, input.cases[current].inputs, values, app, new_name_prefix)
elif isinstance(input, Section):
values = input_values[input.name]
new_name_prefix = name_prefix + input.name + '|'
new_name_prefix = f"{name_prefix + input.name}|"
params_to_incoming(incoming, input.inputs, values, app, new_name_prefix)
else:
value = input_values.get(input.name)
@@ -419,7 +419,7 @@ def _populate_state_legacy(request_context, inputs, incoming, state, errors, pre
if rep_index < input.max:
new_state = {'__index__': rep_index}
group_state.append(new_state)
_populate_state_legacy(request_context, input.inputs, incoming, new_state, errors, prefix=rep_prefix + '|', context=context, check=check, simple_errors=simple_errors)
_populate_state_legacy(request_context, input.inputs, incoming, new_state, errors, prefix=f"{rep_prefix}|", context=context, check=check, simple_errors=simple_errors)
rep_index += 1
elif input.type == 'conditional':
if input.value_ref and not input.value_ref_in_group:
@@ -467,11 +467,11 @@ def _get_incoming_value(incoming, key, default):
Fetch value from incoming dict directly or check special nginx upload
created variants of this key.
"""
if '__' + key + '__is_composite' in incoming:
composite_keys = incoming['__' + key + '__keys'].split()
if f"__{key}__is_composite" in incoming:
composite_keys = incoming[f"__{key}__keys"].split()
value = dict()
for composite_key in composite_keys:
value[composite_key] = incoming[key + '_' + composite_key]
value[composite_key] = incoming[f"{key}_{composite_key}"]
return value
else:
return incoming.get(key, default)
+2 -2
View File
@@ -1177,7 +1177,7 @@ class SelectTagParameter(SelectToolParameter):
"""
options = []
for tag in self.get_tag_list(other_values):
options.append(('Tags: ' + tag, tag, False))
options.append((f"Tags: {tag}", tag, False))
return options
def get_initial_value(self, trans, other_values):
@@ -1350,7 +1350,7 @@ class ColumnListParameter(SelectToolParameter):
if isinstance(col, tuple) and len(col) == 2:
options.append((col[1], col[0], False))
else:
options.append(('Column: ' + col, col, False))
options.append((f"Column: {col}", col, False))
return options
def get_initial_value(self, trans, other_values):
+2 -2
View File
@@ -43,7 +43,7 @@ class ToolParameterSanitizer:
True
"""
VALID_PRESET = {'default': (string.ascii_letters + string.digits + " -=_.()/+*^,:?!"), 'none': ''}
VALID_PRESET = {'default': (f"{string.ascii_letters + string.digits} -=_.()/+*^,:?!"), 'none': ''}
MAPPING_PRESET = {'default': galaxy.util.mapped_chars, 'none': {}}
DEFAULT_INVALID_CHAR = 'X'
@@ -101,7 +101,7 @@ class ToolParameterSanitizer:
if split_name.startswith('string.'):
string_constant = split_name[7:]
if string_constant in ('letters', 'lowercase', 'uppercase'):
split_name = 'string.ascii_' + string_constant
split_name = f"string.ascii_{string_constant}"
try:
value = eval(split_name)
except NameError as e:
+1 -1
View File
@@ -79,7 +79,7 @@ class ToolRecommendations():
# iterate through all the attributes of the model to find weights of neural network layers
for item in trained_model.keys():
if "weight_" in item:
weight = trained_model["weight_" + str(counter_layer_weights)][()]
weight = trained_model[f"weight_{str(counter_layer_weights)}"][()]
model_weights.append(weight)
counter_layer_weights += 1
self.loaded_model = tf.keras.models.model_from_json(model_config)
+2 -2
View File
@@ -190,7 +190,7 @@ class ToolBoxSearch:
else:
cleaned_query = ' '.join(token.text for token in self.rex(cleaned_query))
# Use asterisk Whoosh wildcard so e.g. 'bow' easily matches 'bowtie'
parsed_query = self.parser.parse('*' + cleaned_query + '*')
parsed_query = self.parser.parse(f"*{cleaned_query}*")
hits = self.searcher.search(parsed_query, limit=float(tool_search_limit), sortedby='')
return [hit['id'] for hit in hits]
@@ -205,7 +205,7 @@ class ToolBoxSearch:
ngrams = [token.text for token in token_analyzer(cleaned_query)]
for query in ngrams:
# Get the tool list with respective scores for each qgram
curr_hits = self.searcher.search(self.parser.parse('*' + query + '*'), limit=float(tool_search_limit))
curr_hits = self.searcher.search(self.parser.parse(f"*{query}*"), limit=float(tool_search_limit))
for i, curr_hit in enumerate(curr_hits):
is_present = False
for prev_hit in hits_with_score:
+9 -9
View File
@@ -558,7 +558,7 @@ class AbstractToolBox(Dictifiable, ManagesIntegratedToolPanelMixin):
elem = etree.Element('label')
elem.attrib['text'] = self.edam[term]['label']
elem.attrib['id'] = term
self._tool_panel['label_' + term] = ToolSectionLabel(elem)
self._tool_panel[f"label_{term}"] = ToolSectionLabel(elem)
for (term, tool_id, key, val, val_name) in operations[term].values():
section = self._get_section(term, self.edam[term]['label'])
@@ -572,7 +572,7 @@ class AbstractToolBox(Dictifiable, ManagesIntegratedToolPanelMixin):
elem = etree.Element('label')
elem.attrib['text'] = self.edam[term]['label']
elem.attrib['id'] = term
self._tool_panel['label_' + term] = ToolSectionLabel(elem)
self._tool_panel[f"label_{term}"] = ToolSectionLabel(elem)
for (term, tool_id, key, val, val_name) in topics[term].values():
section = self._get_section(term, self.edam[term]['label'])
@@ -587,7 +587,7 @@ class AbstractToolBox(Dictifiable, ManagesIntegratedToolPanelMixin):
def _sort_edam_key(self, x):
if x in ('operation_0004', 'topic_0003'):
return '!' + x
return f"!{x}"
else:
return self.edam[x]['label']
@@ -683,8 +683,8 @@ class AbstractToolBox(Dictifiable, ManagesIntegratedToolPanelMixin):
if "/repos/" in tool_id: # test if tool came from a toolshed
tool_id_without_tool_shed = tool_id.split("/repos/")[1]
available_tool_sheds = [urlparse(_) for _ in self.app.tool_shed_registry.tool_sheds.values()]
available_tool_sheds = [url.geturl().replace(url.scheme + "://", '', 1) for url in available_tool_sheds]
tool_ids = [tool_shed + "repos/" + tool_id_without_tool_shed for tool_shed in available_tool_sheds]
available_tool_sheds = [url.geturl().replace(f"{url.scheme}://", '', 1) for url in available_tool_sheds]
tool_ids = [f"{tool_shed}repos/{tool_id_without_tool_shed}" for tool_shed in available_tool_sheds]
if tool_id in tool_ids: # move original tool_id to the top of tool_ids
tool_ids.remove(tool_id)
tool_ids.insert(0, tool_id)
@@ -953,7 +953,7 @@ class AbstractToolBox(Dictifiable, ManagesIntegratedToolPanelMixin):
workflow_id = item.get('id')
workflow = self._load_workflow(workflow_id)
self._workflows_by_id[workflow_id] = workflow
key = 'workflow_' + workflow_id
key = f"workflow_{workflow_id}"
if load_panel_dict:
panel_dict[key] = workflow
# Always load workflows into the integrated_panel_dict.
@@ -963,7 +963,7 @@ class AbstractToolBox(Dictifiable, ManagesIntegratedToolPanelMixin):
def _load_label_tag_set(self, item, panel_dict, integrated_panel_dict, load_panel_dict, index=None):
label = ToolSectionLabel(item)
key = 'label_' + label.id
key = f"label_{label.id}"
if load_panel_dict:
panel_dict[key] = label
integrated_panel_dict.update_or_append(index, key, label)
@@ -1156,7 +1156,7 @@ class AbstractToolBox(Dictifiable, ManagesIntegratedToolPanelMixin):
new_tool.installed_changeset_revision = old_tool.installed_changeset_revision
new_tool.old_id = old_tool.old_id
# Replace old_tool with new_tool in self._tool_panel
tool_key = 'tool_' + tool_id
tool_key = f"tool_{tool_id}"
for key, val in self._tool_panel.items():
if key == tool_key:
self._tool_panel[key] = new_tool
@@ -1190,7 +1190,7 @@ class AbstractToolBox(Dictifiable, ManagesIntegratedToolPanelMixin):
if tool_cache:
tool_cache.expire_tool(tool_id)
if remove_from_panel:
tool_key = 'tool_' + tool_id
tool_key = f"tool_{tool_id}"
for key, val in self._tool_panel.items():
if key == tool_key:
del self._tool_panel[key]
+3 -3
View File
@@ -110,10 +110,10 @@ $INTEGRATED_TOOL_PANEL
with RenamedTemporaryFile(filename, mode='w') as f:
f.write(tp_string)
if tracking_directory:
with open(filename + ".stack", "w") as f:
with open(f"{filename}.stack", "w") as f:
f.write(''.join(traceback.format_stack()))
shutil.copy(filename, filename + ".copy")
shutil.move(filename + ".copy", destination)
shutil.copy(filename, f"{filename}.copy")
shutil.move(f"{filename}.copy", destination)
try:
os.chmod(destination, RW_R__R__)
except OSError:

Some files were not shown because too many files have changed in this diff Show More