From e675143a654853cce0916f9f3abad855977f029c Mon Sep 17 00:00:00 2001 From: Sietse Snel Date: Mon, 2 Dec 2024 16:11:55 +0100 Subject: [PATCH] YDA-6035: add revision data to GLC report Optionally add data about the size of revisions of the research group, as well as last modification date of revisions, to the group lifecycle report. Size of research group no longer includes revisions. --- CHANGELOG.md | 5 +++++ README.md | 10 +++++----- yclienttools/reportgrouplifecycle.py | 26 +++++++++++++++++++++----- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d790e4..e85b781 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change log +## UNRELEASED + +- Add revision statistics to the group lifecycle report. Size of research group in this report + no longer includes revisions. + ## 2024-11-21 v1.5.0 - Add some default values for the CA file location that also work in non-Yoda-server environments. diff --git a/README.md b/README.md index 1af08b2..57f11ab 100644 --- a/README.md +++ b/README.md @@ -374,18 +374,18 @@ expiration date (if available), lists of group managers, regular members, and readonly members. The report also shows whether each research compartment contains data, as well as whether its vault compartment contains data. The report can optionally include size and last modified date of both the research -and vault collection. +and vault collection, as well as revisions. optional arguments: -h, --help show this help message and exit -q, --quasi-xml Enable Quasi-XML parser in order to be able to parse characters not supported by regular XML parser - -s, --size Include size of research collection and vault - collection in output + -s, --size Include size of research collection, vault collection + and revisions in output -H, --human-readable Report sizes in human-readable figures (only relevant in combination with --size parameter) - -m, --modified Include last modified date research collection and - vault collection in output + -m, --modified Include last modified date research collection, + revisions and vault collection in output -y {1.7,1.8,1.9,1.10}, --yoda-version {1.7,1.8,1.9,1.10} Override Yoda version on the server ``` diff --git a/yclienttools/reportgrouplifecycle.py b/yclienttools/reportgrouplifecycle.py index b6d9a77..dc13dba 100644 --- a/yclienttools/reportgrouplifecycle.py +++ b/yclienttools/reportgrouplifecycle.py @@ -3,7 +3,7 @@ research compartment contains data, as well as whether its vault compartment contains data. The report can optionally include size and last modified date of both the research and - vault collection. + vault collection, as well as revisions. ''' import argparse @@ -44,11 +44,11 @@ def _get_args() -> argparse.Namespace: parser.add_argument("-q", "--quasi-xml", default=False, action='store_true', help='Enable Quasi-XML parser in order to be able to parse characters not supported by regular XML parser') parser.add_argument("-s", "--size", default=False, action='store_true', - help='Include size of research collection and vault collection in output') + help='Include size of research collection, vault collection and revisions in output') parser.add_argument("-H", "--human-readable", default=False, action='store_true', help='Report sizes in human-readable figures (only relevant in combination with --size parameter)') parser.add_argument("-m", "--modified", default=False, action='store_true', - help='Include last modified date research collection and vault collection in output') + help='Include last modified date research collection, revisions and vault collection in output') common_args.add_default_args(parser) return parser.parse_args() @@ -120,6 +120,10 @@ def _get_research_group_collection(session: iRODSSession, group_name: str) -> st return f"/{session.zone}/home/{group_name}" +def _get_revision_group_collection(session: iRODSSession, group_name: str) -> str: + return f"/{session.zone}/yoda/revisions/{group_name}" + + def _get_research_size(session: iRODSSession, group_name: str) -> Union[int, None]: collection = _get_research_group_collection(session, group_name) if collection_exists(session, collection): @@ -136,8 +140,16 @@ def _get_vault_size(session: iRODSSession, group_name: str) -> Union[int, None]: return None +def _get_revisions_size(session: iRODSSession, group_name: str) -> Union[int, None]: + collection = _get_revision_group_collection(session, group_name) + if collection_exists(session, collection): + return _get_collection_size_for_glr(session, collection) + else: + return None + + def _get_collection_size_for_glr(session: iRODSSession, collection_name: str) -> int: - return get_collection_size(session, collection_name, True, GroupByOption.none, True)['all'] + return get_collection_size(session, collection_name, True, GroupByOption.none, False)['all'] def _collection_has_data(session: iRODSSession, coll_name: str) -> int: @@ -186,13 +198,14 @@ def _get_columns(args: argparse.Namespace) -> List[str]: "Creation date", "Expiration date", "Has research data", "Has vault data"] if args.size: - extra_cols = ["Research collection size", "Vault collection size"] + extra_cols = ["Research collection size", "Vault collection size", "Revisions size"] else: extra_cols = [] if args.modified: extra_cols.append("Research last modified") extra_cols.append("Vault last modified") + extra_cols.append("Revisions last modified") result = base_cols result.extend(extra_cols) @@ -251,11 +264,14 @@ def _has_data_to_string(value): if args.size: rowdata.append(_size_to_str(_get_research_size(session, group), args.human_readable)) rowdata.append(_size_to_str(_get_vault_size(session, group), args.human_readable)) + rowdata.append(_size_to_str(_get_revisions_size(session, group), args.human_readable)) if args.modified: rowdata.append(_timestamp_to_date_str( get_collection_contents_last_modified(session, _get_research_group_collection(session, group)))) rowdata.append(_timestamp_to_date_str( get_collection_contents_last_modified(session, _get_vault_group_collection(session, group)))) + rowdata.append(_timestamp_to_date_str( + get_collection_contents_last_modified(session, _get_revision_group_collection(session, group)))) output.writerow(rowdata)