Skip to content

Commit

Permalink
Add ONT year runs meta-report
Browse files Browse the repository at this point in the history
  • Loading branch information
kjsanger committed May 13, 2024
1 parent 90f5b7a commit e5e01bb
Show file tree
Hide file tree
Showing 8 changed files with 642 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
shell: bash -l -e -o pipefail {0}

env:
PYTHON_VERSION: "3.10"
PYTHON_VERSION: "3.11"
SINGULARITY_VERSION: "3.11.1"

strategy:
Expand Down
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ classifiers = [
"Programming Language :: Python"
]
keywords = ["irods", "npg"]
requires-python = ">=3.10"
requires-python = ">=3.11"

dynamic = ["version"]

Expand All @@ -35,20 +35,21 @@ homepage = "https://github.com/wtsi-npg/npg-irods-python"
repository = "https://github.com/wtsi-npg/npg-irods-python.git"

[project.scripts]
"enhance-secondary-metadata" = "npg_irods.cli.enhance_secondary_metadata:main"
"apply-ont-metadata" = "npg_irods.cli.apply_ont_metadata:main"
"check-checksums" = "npg_irods.cli.check_checksums:main"
"check-common-metadata" = "npg_irods.cli.check_common_metadata:main"
"check-consent-withdrawn" = "npg_irods.cli.check_consent_withdrawn:main"
"check-replicas" = "npg_irods.cli.check_replicas:main"
"copy-confirm" = "npg_irods.cli.copy_confirm:main"
"enhance-secondary-metadata" = "npg_irods.cli.enhance_secondary_metadata:main"
"locate-data-objects" = "npg_irods.cli.locate_data_objects:main"
"repair-common-metadata" = "npg_irods.cli.repair_common_metadata:main"
"repair-checksums" = "npg_irods.cli.repair_checksums:main"
"repair-common-metadata" = "npg_irods.cli.repair_common_metadata:main"
"repair-replicas" = "npg_irods.cli.repair_replicas:main"
"safe-remove-script" = "npg_irods.cli.safe_remove_script:main"
"update-secondary-metadata" = "npg_irods.cli.update_secondary_metadata:main"
"withdraw-consent" = "npg_irods.cli.withdraw_consent:main"
"write-html-report" = "npg_irods.cli.write_html_report:main"

[build-system]
requires = ["setuptools>=41", "wheel", "setuptools-git-versioning<2"]
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ setuptools-git-versioning==2.0.0
setuptools==69.5.1
sqlalchemy==2.0.29
structlog==24.1.0
yattag==1.14.0
105 changes: 105 additions & 0 deletions src/npg_irods/cli/write_html_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# -*- coding: utf-8 -*-
#
# Copyright © 2024 Genome Research Ltd. All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# @author Keith James <kdj@sanger.ac.uk>

import argparse
import sys

import structlog
from partisan.exception import RodsError
from yattag import indent

from npg_irods.cli.util import add_logging_arguments, configure_logging
from npg_irods.html_reports import ont_runs_html_report_this_year
from npg_irods.version import version

description = """Writes an HTML report summarising data in iRODS.
The reports include HTTP links to data objects and collections in iRODS. The links
are only accessible if the report is rendered by a web server that can access the
relevant iRODS zone.
Available reports are:
- ont: Oxford Nanopore sequencing data objects and collections.
A summary of ONT runs for the calendar year to date.
"""

parser = argparse.ArgumentParser(
description=description,
formatter_class=argparse.RawDescriptionHelpFormatter,
)
add_logging_arguments(parser)
parser.add_argument(
"-o",
"--output",
help="Output filename.",
type=argparse.FileType("w", encoding="UTF-8"),
default=sys.stdout,
)
parser.add_argument(
"report",
help="Report type.",
type=str,
choices=["ont"],
nargs=1,
)
parser.add_argument(
"--zone",
help="Specify a federated iRODS zone in which to find data objects and/or "
"collections. This is not required if the target paths are on the local zone.",
type=str,
)
parser.add_argument(
"--version", help="Print the version and exit.", action="store_true"
)

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():
if args.version:
print(version())
sys.exit(0)

report = args.report[0]

try:
match report:
case "ont":
doc = ont_runs_html_report_this_year(zone=args.zone)
case _:
raise ValueError(f"Invalid HTML report type '{report}'")

print(indent(doc.getvalue()), file=args.output)
except RodsError as re:
log.error(re.message, code=re.code)
sys.exit(1)
except Exception as e:
log.error(e)
sys.exit(1)
Loading

0 comments on commit e5e01bb

Please sign in to comment.