Metadata-Version: 2.4
Name: xrdsum
Version: 2025.2.1
Summary: Package for retrieving and calculating checksums for XRootD
Project-URL: homepage, https://github.com/BristolComputing/xrdsum
Author-email: Luke Kreczko <kreczko@cern.ch>
Maintainer-email: The GridPP Collaboration <kreczko@cern.ch>
License: BSD 3-Clause License
        
        Copyright (c) 2022, Luke Kreczko.
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        * Redistributions of source code must retain the above copyright notice, this
          list of conditions and the following disclaimer.
        
        * Redistributions in binary form must reproduce the above copyright notice,
          this list of conditions and the following disclaimer in the documentation
          and/or other materials provided with the distribution.
        
        * Neither the name of the vector package developers nor the names of its
          contributors may be used to endorse or promote products derived from
          this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.9
Requires-Dist: codetiming
Requires-Dist: crc32c
Requires-Dist: fasthep-logging>=0.1.1
Requires-Dist: requests
Requires-Dist: rich>=10.12.0
Requires-Dist: typer>=0.4.0
Requires-Dist: xattr>=0.10.1
Provides-Extra: dev
Requires-Dist: pytest>=6; extra == 'dev'
Provides-Extra: docs
Requires-Dist: myst-parser>=0.13; extra == 'docs'
Requires-Dist: sphinx-book-theme>=0.1.0; extra == 'docs'
Requires-Dist: sphinx-copybutton; extra == 'docs'
Requires-Dist: sphinx>=7.0; extra == 'docs'
Provides-Extra: hdfs
Requires-Dist: pyhdfs>=0.3.1; extra == 'hdfs'
Provides-Extra: test
Requires-Dist: pytest>=6; extra == 'test'
Description-Content-Type: text/markdown

# xrdsum

[XrootD](https://xrootd.org) plugin for calculating checksums and storing them
in extended attributes. Currently supports ADLER32 checksum and HDFS as backend.
Borrows heavily from [cephsum plugin](https://github.com/snafus/cephsum).

This plugin is designed to easily accommodate new checksum types and backends.
Additional dependencies for backends are defined as optional dependencies for
the package (see usage instructions).

[![Actions Status][actions-badge]][actions-link]
[![Documentation Status][rtd-badge]][rtd-link]
[![Code style: black][black-badge]][black-link]

[![PyPI version][pypi-version]][pypi-link]
[![PyPI platforms][pypi-platforms]][pypi-link]

[![GitHub Discussion][github-discussions-badge]][github-discussions-link]
[![Gitter][gitter-badge]][gitter-link]

<!-- prettier-ignore-start -->
[actions-badge]:            https://github.com/BristolComputing/xrdsum/workflows/CI/badge.svg
[actions-link]:             https://github.com/BristolComputing/xrdsum/actions
[black-badge]:              https://img.shields.io/badge/code%20style-black-000000.svg
[black-link]:               https://github.com/psf/black
[github-discussions-badge]: https://img.shields.io/static/v1?label=Discussions&message=Ask&color=blue&logo=github
[github-discussions-link]:  https://github.com/BristolComputing/xrdsum/discussions
[gitter-badge]:             https://badges.gitter.im/https://github.com/BristolComputing/xrdsum/community.svg
[gitter-link]:              https://gitter.im/https://github.com/BristolComputing/xrdsum/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
[pypi-link]:                https://pypi.org/project/xrdsum/
[pypi-platforms]:           https://img.shields.io/pypi/pyversions/xrdsum
[pypi-version]:             https://badge.fury.io/py/xrdsum.svg
[rtd-badge]:                https://readthedocs.org/projects/xrdsum/badge/?version=latest
[rtd-link]:                 https://xrdsum.readthedocs.io/en/latest/?badge=latest
[sk-badge]:                 https://scikit-hep.org/assets/images/Scikit--HEP-Project-blue.svg
<!-- prettier-ignore-end -->

## Usage

xrdsum requires Python version >=3.8. To install, run:

```bash
pip install xrdsum[hdfs]
```

```bash
xrdsum --help
Usage: xrdsum [OPTIONS] COMMAND [ARGS]...

  Callback to give the --verbose and --debug options to all commands

Options:
  -v, --verbose         Verbose output
  -d, --debug           Debug output
  -l, --log-file TEXT   Log file
  --install-completion  Install completion for the current shell.
  --show-completion     Show completion for the current shell, to copy it or
                        customize the installation.
  --help                Show this message and exit.

Commands:
  get     Get the checksum of a file.
  verify  Check if a file has the correct checksum.
```

Example:

```bash
/usr/bin/time -v xrdsum --verbose  --debug get  /xrootd/dteam/user/jwalder/file_1GB_020 --read-size 128
```

### xrootd config

```
# ensure cksum adler32 is included in the tpc directive, in order to calculate by default on transfer
ofs.tpc cksum adler32 fcreds ?gsi =X509_USER_PROXY autorm xfr 40 pgm /etc/xrootd/xrdcp-tpc.sh

# add this line to trigger external checksum calculation. Would be overwritten by other xrootd.chksum lines
xrootd.chksum max 50 adler32 /etc/xrootd/xrdsum.sh
```

with `/etc/xrootd/xrdcp-tpc.sh` containing:

```bash
#!/bin/sh

# from https://github.com/snafus/cephsum/blob/master/scripts/xrdcp-tpc.sh
#Original code
#/usr/bin/xrdcp --server -f $1 root://$XRDXROOTD_PROXY/$2

# Get the last two variables as SRC and DST, all others are assumed as additional arguments
OTHERARGS="${@:1:$#-2}"
DSTFILE="${@:$#:1}"
SRCFILE="${@:$#-1:1}"


/usr/bin/xrdcp $OTHERARGS --server -f $SRCFILE root://$XRDXROOTD_PROXY/$DSTFILE
```

and with `/etc/xrootd/xrdsum.sh` containing:

```bash
#!/usr/bin/env bash

RESULT=$(xrdsum get --store-result --chunk-size 64 --verbose --storage-catalog /etc/xrootd/storage.xml "$1")
ECODE=$?

# XRootD expects return on stdout - checksum followed by a new line
printf "%s\n" "$RESULT"
exit "$ECODE"
```

### Conda installation example

```bash
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -b -p /miniconda
rm -f Miniconda3-latest-Linux-x86_64.sh
export PATH="/miniconda/bin:$PATH"
conda init
conda update -y conda
conda install python=3.10
pip install xrdsum[hdfs]
```
