Skip to content

Commit

Permalink
YDA-6035: add revision data to GLC report
Browse files Browse the repository at this point in the history
Optionally add data about the size of revisions for the research group,
as well as last modification date of revisions to the group lifecycle
report.

Size of research group no longer includes revisions.
  • Loading branch information
stsnel committed Dec 2, 2024
1 parent 49e39a7 commit 8161e14
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
26 changes: 21 additions & 5 deletions yclienttools/reportgrouplifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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):
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

0 comments on commit 8161e14

Please sign in to comment.