Skip to content

Commit

Permalink
Add metadata and permission management for Illumina ancillary files
Browse files Browse the repository at this point in the history
  • Loading branch information
kjsanger committed Jan 2, 2024
1 parent a14637e commit 92d3d93
Show file tree
Hide file tree
Showing 12 changed files with 476 additions and 159 deletions.
4 changes: 0 additions & 4 deletions src/npg_irods/cli/repair_common_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,3 @@ def main():
num_repaired=num_repaired,
num_errors=num_errors,
)


if __name__ == "__main__":
main()
146 changes: 74 additions & 72 deletions src/npg_irods/cli/update_secondary_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,82 +47,84 @@
error message summarising the results will be sent to STDERR.
"""

parser = argparse.ArgumentParser(
description=description, formatter_class=argparse.RawDescriptionHelpFormatter
)
add_logging_arguments(parser)

parser.add_argument(
"--database-config",
"--database_config",
"--db-config",
"--db_config",
help="Configuration file for database connection.",
type=argparse.FileType("r"),
required=True,
)
parser.add_argument(
"-i",
"--input",
help="Input filename.",
type=argparse.FileType("r"),
default=sys.stdin,
)
parser.add_argument(
"-o",
"--output",
help="Output filename.",
type=argparse.FileType("w"),
default=sys.stdout,
)
parser.add_argument(
"--print-update",
help="Print to output those paths that were updated. Defaults to True.",
action="store_true",
)
parser.add_argument(
"--print-fail",
help="Print to output those paths that require updating, where the update failed. "
"Defaults to False.",
action="store_true",
)
parser.add_argument(
"-c",
"--clients",
help="Number of baton clients to use. Defaults to 4.",
type=int,
default=4,
)
parser.add_argument(
"-t",
"--threads",
help="Number of threads to use. Defaults to 4.",
type=int,
default=4,
)
parser.add_argument(
"--version", help="Print the version and exit.", action="store_true"
)
parser.add_argument(
"--zone",
help="Specify a federated iRODS zone in which to find data objects and/or "
"collections to update. This is not required if the target paths "
"are on the local zone.",
type=str,
)

args = parser.parse_args()
configure_logging(
config_file=args.log_config,
debug=args.debug,
verbose=args.verbose,
colour=args.colour,
json=args.json,
)

log = structlog.get_logger("main")


def main():
parser = argparse.ArgumentParser(
description=description, formatter_class=argparse.RawDescriptionHelpFormatter
)
add_logging_arguments(parser)

parser.add_argument(
"--database-config",
"--database_config",
"--db-config",
"--db_config",
help="Configuration file for database connection.",
type=argparse.FileType("r"),
required=True,
)
parser.add_argument(
"-i",
"--input",
help="Input filename.",
type=argparse.FileType("r"),
default=sys.stdin,
)
parser.add_argument(
"-o",
"--output",
help="Output filename.",
type=argparse.FileType("w"),
default=sys.stdout,
)
parser.add_argument(
"--print-update",
help="Print to output those paths that were updated. Defaults to True.",
action="store_true",
)
parser.add_argument(
"--print-fail",
help="Print to output those paths that require updating, where the update failed. "
"Defaults to False.",
action="store_true",
)
parser.add_argument(
"-c",
"--clients",
help="Number of baton clients to use. Defaults to 4.",
type=int,
default=4,
)
parser.add_argument(
"-t",
"--threads",
help="Number of threads to use. Defaults to 4.",
type=int,
default=4,
)
parser.add_argument(
"--version", help="Print the version and exit.", action="store_true"
)
parser.add_argument(
"--zone",
help="Specify a federated iRODS zone in which to find data objects and/or "
"collections to update. This is not required if the target paths "
"are on the local zone.",
type=str,
)

args = parser.parse_args()
configure_logging(
config_file=args.log_config,
debug=args.debug,
verbose=args.verbose,
colour=args.colour,
json=args.json,
)

if args.version:
print(version())
exit(0)
Expand Down
33 changes: 32 additions & 1 deletion src/npg_irods/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,44 @@ def __init__(
self.observed = observed


class NonUniqueError(DataManagementError):
"""Exception raised when a unique constraint is violated.
Args:
args: Optional positional arguments, the first of which should be a message
string.
observed: The observed non-unique objects, if any.
"""

def __init__(self, *args, path: Any = None, observed: Any = None):
super().__init__(*args)
self.message = args[0] if len(args) > 0 else ""
self.observed = observed


class CollectionNotFound(DataManagementError):
"""Exception raised when an iRODS collection is expected to exist, but is not found.
Args:
args: Optional positional arguments, the first of which should be a message
string.
path: The path of the affected collection in iRODS.
path: The path of the missing collection in iRODS.
"""

def __init__(self, *args, path: Any = None):
super().__init__(*args)
self.message = args[0] if len(args) > 0 else ""
self.path = path


class DataObjectNotFound(DataManagementError):
"""Exception raised when an iRODS data object is expected to exist, but is not
found.
Args:
args: Optional positional arguments, the first of which should be a message
string.
path: The path of the missing data object in iRODS.
"""

def __init__(self, *args, path: Any = None):
Expand Down
Loading

0 comments on commit 92d3d93

Please sign in to comment.