Skip to content

Commit

Permalink
wip troubleshoot change to stdout, configurable log
Browse files Browse the repository at this point in the history
  • Loading branch information
claravox committed Sep 4, 2024
1 parent e2377ea commit b0aca90
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 68 deletions.
2 changes: 1 addition & 1 deletion groups_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def parse_csv_file(ctx):
# Start processing the actual group data rows
for line in lines:
row_number += 1
rowdata, error = process_csv_line(line)
rowdata, error = process_csv_line(ctx, line)

if error is None:
extracted_data.append(rowdata)
Expand Down
10 changes: 5 additions & 5 deletions tools/arb-update-resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def parse_args():

def parse_cs_values(input):
"""Parses a comma-separated list of key:value pairs as a dict."""
result = dict()
result = {}
for kv_pair in input.split(","):
if kv_pair == "":
continue
Expand Down Expand Up @@ -96,7 +96,7 @@ def setup_session(irods_environment_config, ca_file="/etc/pki/tls/certs/chain.cr
'encryption_num_hash_rounds': 16,
'encryption_salt_size': 8,
'ssl_context': ssl_context}
settings = dict()
settings = {}
settings.update(irods_environment_config)
settings.update(ssl_settings)
settings["password"] = password
Expand Down Expand Up @@ -160,8 +160,8 @@ def call_rule(session, rulename, params, number_outputs, rule_engine='irods_rule
output=output_params,
**re_config)

outArray = myrule.execute()
buf = outArray.MsParam_PI[0].inOutStruct.stdoutBuf.buf.decode(
out_array = myrule.execute()
buf = out_array.MsParam_PI[0].inOutStruct.stdoutBuf.buf.decode(
'utf-8').splitlines()

return buf[:number_outputs]
Expand Down Expand Up @@ -208,7 +208,7 @@ def main():
print("Updating misc resources ...")
call_rule_update_misc(session)
except NetworkException:
print("Could not connect to iRODS sever ...")
print("Could not connect to iRODS server ...")


if __name__ == '__main__':
Expand Down
42 changes: 42 additions & 0 deletions tools/troubleshoot-published-data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python3
"""This script collects all published packages and checks that they have all the required info.
Example:
To check all published packages:
python3 troubleshoot-published-data.py
To check one specific package by name:
python3 troubleshoot-published-data.py -p research-initial[1725262507]
To put results into a json lines log file:
python3 troubleshoot-published-data.py -l /etc/irods/yoda-ruleset/troubleshoot-pub-log.jsonl
"""
import argparse
import subprocess


def parse_args():
parser = argparse.ArgumentParser(
prog="troubleshoot-published-data.py",
description=__doc__,
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument("-l", "--log-file", type=str, required=False,
help="If write to json lines log file, location to write to")
parser.add_argument("-p", "--package", type=str, required=False,
help="Troubleshoot a specific data package by name (default: troubleshoot all packages)")
return parser.parse_args()


def main():
args = parse_args()
rule_name = "/etc/irods/yoda-ruleset/tools/troubleshoot_data.r"
# rule_name = "rule_batch_troubleshoot_published_data_packages"
# TODO handle packages with spaces in the name
data_package = f"*data_package={args.package}"
log_loc = f"*log_loc={args.log_file if args.log_file else ''}"
subprocess.call(['irule', '-r', 'irods_rule_engine_plugin-python-instance', '-F',
rule_name, data_package, log_loc])


if __name__ == '__main__':
main()
5 changes: 3 additions & 2 deletions tools/troubleshoot_data.r
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

def main(rule_args, callback, rei):
data_package = global_vars["*data_package"].strip('"')
callback.rule_batch_troubleshoot_published_data_packages(data_package)
log_loc = global_vars["*log_loc"].strip('"')
callback.rule_batch_troubleshoot_published_data_packages(data_package, log_loc)

INPUT *data_package=all_published_packages
INPUT *data_package="", *log_loc=""
OUTPUT ruleExecOut
Loading

0 comments on commit b0aca90

Please sign in to comment.