Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command line option to find recently created ONT run collections #383

Merged
merged 4 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/npg_irods/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
#
# Copyright © 2022, 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 <[email protected]>


import importlib.metadata

__version__ = importlib.metadata.version("npg-irods-python")


def version() -> str:
"""Return the current version."""
return __version__
9 changes: 2 additions & 7 deletions src/npg_irods/cli/apply_ont_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@
from npg.log import configure_structlog
from sqlalchemy.orm import Session

from npg_irods import db
from npg_irods import db, version
from npg_irods.ont import apply_metadata
from npg_irods.version import version

description = """
Applies metadata and data access permissions on ONT run collections in iRODS, to reflect
Expand Down Expand Up @@ -66,7 +65,7 @@
type=str,
)
parser.add_argument(
"--version", help="Print the version and exit.", action="store_true"
"--version", help="Print the version and exit.", action="version", version=version()
)

args = parser.parse_args()
Expand All @@ -81,10 +80,6 @@


def main():
if args.version:
print(version())
sys.exit(0)

dbconfig = IniData(db.Config).from_file(args.db_config.name, "mlwh_ro")
engine = sqlalchemy.create_engine(
dbconfig.url, pool_pre_ping=True, pool_recycle=3600
Expand Down
8 changes: 2 additions & 6 deletions src/npg_irods/cli/check_checksums.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from npg.cli import add_io_arguments, add_logging_arguments
from npg.log import configure_structlog

from npg_irods import version
from npg_irods.utilities import check_checksums
from npg_irods.version import version

description = """
Reads iRODS data object paths from a file or STDIN, one per line and performs
Expand Down Expand Up @@ -77,7 +77,7 @@
default=4,
)
parser.add_argument(
"--version", help="Print the version and exit.", action="store_true"
"--version", help="Print the version and exit.", action="version", version=version()
)

args = parser.parse_args()
Expand All @@ -92,10 +92,6 @@


def main():
if args.version:
print(version())
sys.exit(0)

num_processed, num_passed, num_errors = check_checksums(
args.input,
args.output,
Expand Down
8 changes: 2 additions & 6 deletions src/npg_irods/cli/check_common_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from npg.cli import add_io_arguments, add_logging_arguments
from npg.log import configure_structlog

from npg_irods import version
from npg_irods.utilities import check_common_metadata
from npg_irods.version import version

description = """
Reads iRODS data object paths from a file or STDIN, one per line and performs
Expand Down Expand Up @@ -76,7 +76,7 @@
default=4,
)
parser.add_argument(
"--version", help="Print the version and exit.", action="store_true"
"--version", help="Print the version and exit.", action="version", version=version()
)

args = parser.parse_args()
Expand All @@ -91,10 +91,6 @@


def main():
if args.version:
print(version())
sys.exit(0)

num_processed, num_passed, num_errors = check_common_metadata(
args.input,
args.output,
Expand Down
9 changes: 3 additions & 6 deletions src/npg_irods/cli/check_consent_withdrawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
from npg.cli import add_io_arguments, add_logging_arguments
from npg.log import configure_structlog

from npg_irods import version
from npg_irods.utilities import (
check_consent_withdrawn,
)
from npg_irods.version import version


description = """
Reads iRODS data object paths from a file or STDIN, one per line and checks that each
Expand Down Expand Up @@ -71,7 +72,7 @@
action="store_true",
)
parser.add_argument(
"--version", help="Print the version and exit.", action="store_true"
"--version", help="Print the version and exit.", action="version", version=version()
)


Expand All @@ -87,10 +88,6 @@


def main():
if args.version:
print(version())
sys.exit(0)

num_processed, num_passed, num_errors = check_consent_withdrawn(
args.input,
args.output,
Expand Down
8 changes: 2 additions & 6 deletions src/npg_irods/cli/check_replicas.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from npg.cli import add_io_arguments, add_logging_arguments
from npg.log import configure_structlog

from npg_irods import version
from npg_irods.utilities import check_replicas
from npg_irods.version import version

description = """
Reads iRODS data object paths from a file or STDIN, one per line and performs
Expand Down Expand Up @@ -85,7 +85,7 @@
default=4,
)
parser.add_argument(
"--version", help="Print the version and exit.", action="store_true"
"--version", help="Print the version and exit.", action="version", version=version()
)

args = parser.parse_args()
Expand All @@ -100,10 +100,6 @@


def main():
if args.version:
print(version())
sys.exit(0)

num_processed, num_passed, num_errors = check_replicas(
args.input,
args.output,
Expand Down
8 changes: 2 additions & 6 deletions src/npg_irods/cli/copy_confirm.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
from npg.log import configure_structlog
from partisan.exception import RodsError

from npg_irods import version
from npg_irods.common import rods_path
from npg_irods.exception import ChecksumError
from npg_irods.utilities import copy
from npg_irods.version import version

description = """
Copies iRODS collections and data objects from one path to another, optionally
Expand Down Expand Up @@ -84,7 +84,7 @@
action="store_true",
)
parser.add_argument(
"--version", help="Print the version and exit.", action="store_true"
"--version", help="Print the version and exit.", action="version", version=version()
)

args = parser.parse_args()
Expand All @@ -99,10 +99,6 @@


def main():
if args.version:
print(version())
sys.exit(0)

try:
num_processed, num_copied = copy(
args.source,
Expand Down
25 changes: 19 additions & 6 deletions src/npg_irods/cli/locate_data_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from partisan.irods import AVU, DataObject, RodsItem, query_metadata
from sqlalchemy.orm import Session

from npg_irods import db, illumina, ont, pacbio, sequenom
from npg_irods import db, illumina, ont, pacbio, sequenom, version

from npg_irods.db.mlwh import (
find_consent_withdrawn_samples,
Expand All @@ -51,7 +51,6 @@
from npg_irods.metadata.illumina import Instrument
from npg_irods.metadata.lims import TrackedSample, TrackedStudy
from npg_irods.ont import barcode_collections
from npg_irods.version import version

description = """
A utility for locating sets of data objects in iRODS.
Expand Down Expand Up @@ -630,7 +629,10 @@ def main():
type=str,
)
parser.add_argument(
"--version", help="Print the version and exit.", action="store_true"
"--version",
help="Print the version and exit.",
action="version",
version=version(),
)

subparsers = parser.add_subparsers(title="Sub-commands", required=True)
Expand Down Expand Up @@ -673,6 +675,20 @@ def main():
)
ilup_parser.set_defaults(func=illumina_updates_cli)

ontcre_parser = subparsers.add_parser(
"ont-run-creation",
help="Find ONT runfolder collections created in iRODS within a specified time "
"range.",
)
add_date_range_arguments(ontcre_parser)
ontcre_parser.add_argument(
"--report-json",
"--report_json",
help="Print output in JSON format.",
action="store_true",
)
ontcre_parser.set_defaults(func=ont_run_collections_created_cli)

ontup_parser = subparsers.add_parser(
"ont-updates",
help="Find collections, containing data objects for ONT runs, whose tracking"
Expand Down Expand Up @@ -755,9 +771,6 @@ def main():
json=args.json,
)

if args.version:
print(version())
sys.exit(0)
args.func(args)


Expand Down
8 changes: 2 additions & 6 deletions src/npg_irods/cli/repair_checksums.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from npg.cli import add_io_arguments, add_logging_arguments
from npg.log import configure_structlog

from npg_irods import version
from npg_irods.utilities import repair_checksums
from npg_irods.version import version

description = """
Reads iRODS data object paths from a file or STDIN, one per line and repairs
Expand Down Expand Up @@ -82,7 +82,7 @@
default=4,
)
parser.add_argument(
"--version", help="Print the version and exit.", action="store_true"
"--version", help="Print the version and exit.", action="version", version=version()
)

args = parser.parse_args()
Expand All @@ -97,10 +97,6 @@


def main():
if args.version:
print(version())
sys.exit(0)

num_processed, num_repaired, num_errors = repair_checksums(
args.input,
args.output,
Expand Down
8 changes: 2 additions & 6 deletions src/npg_irods/cli/repair_common_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from npg.cli import add_io_arguments, add_logging_arguments
from npg.log import configure_structlog

from npg_irods import version
from npg_irods.utilities import repair_common_metadata
from npg_irods.version import version

description = """
Reads iRODS data object paths from a file or STDIN, one per line and repairs
Expand Down Expand Up @@ -79,7 +79,7 @@
default=4,
)
parser.add_argument(
"--version", help="Print the version and exit.", action="store_true"
"--version", help="Print the version and exit.", action="version", version=version()
)

args = parser.parse_args()
Expand All @@ -94,10 +94,6 @@


def main():
if args.version:
print(version())
sys.exit(0)

num_processed, num_repaired, num_errors = repair_common_metadata(
args.input,
args.output,
Expand Down
8 changes: 2 additions & 6 deletions src/npg_irods/cli/repair_replicas.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from npg.cli import add_io_arguments, add_logging_arguments
from npg.log import configure_structlog

from npg_irods import version
from npg_irods.utilities import repair_replicas
from npg_irods.version import version

description = """
Reads iRODS data object paths from a file or STDIN, one per line and repairs their
Expand Down Expand Up @@ -81,7 +81,7 @@
default=4,
)
parser.add_argument(
"--version", help="Print the version and exit.", action="store_true"
"--version", help="Print the version and exit.", action="version", version=version()
)

args = parser.parse_args()
Expand All @@ -96,10 +96,6 @@


def main():
if args.version:
print(version())
sys.exit(0)

num_processed, num_repaired, num_errors = repair_replicas(
args.input,
args.output,
Expand Down
8 changes: 2 additions & 6 deletions src/npg_irods/cli/safe_remove_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from npg.cli import add_logging_arguments
from npg.log import configure_structlog

from npg_irods import version
from npg_irods.utilities import write_safe_remove_script
from npg_irods.version import version

description = """
Writes a shell script to allow safe recursive deletion of collections and data objects
Expand Down Expand Up @@ -73,7 +73,7 @@
action="store_true",
)
parser.add_argument(
"--version", help="Print the version and exit.", action="store_true"
"--version", help="Print the version and exit.", action="version", version=version()
)

args = parser.parse_args()
Expand All @@ -88,10 +88,6 @@


def main():
if args.version:
print(version())
sys.exit(0)

try:
write_safe_remove_script(
args.output,
Expand Down
Loading