Snakemake storage plugin: rucio

https://img.shields.io/badge/repository-github-blue?color=%23022c22 https://img.shields.io/badge/author-Bouwe%20Andela-purple?color=%23064e3b PyPI - Version PyPI - License

Warning

This plugin is not maintained and reviewed by the official Snakemake organization.

A Snakemake storage plugin that reads and writes using Rucio.

Installation

Install this plugin by installing it with pip or mamba, e.g.:

pip install snakemake-storage-plugin-rucio

Usage

Queries

Queries to this storage should have the following format:

Query type

Query

Description

any

rucio://myscope/myfile.txt

The file “myfile.txt” in Rucio scope “myscope”.

As default provider

If you want all your input and output (which is not explicitly marked to come from another storage) to be written to and read from this storage, you can use it as a default provider via:

snakemake --default-storage-provider rucio --default-storage-prefix ...

with ... being the prefix of a query under which you want to store all your results. You can also pass custom settings via command line arguments:

snakemake --default-storage-provider rucio --default-storage-prefix ... \
    --storage-rucio-max-requests-per-second ... \
    --storage-rucio-rucio-host ... \
    --storage-rucio-auth-host ... \
    --storage-rucio-account ... \
    --storage-rucio-ca-cert ... \
    --storage-rucio-auth-type ... \
    --storage-rucio-creds ... \
    --storage-rucio-timeout ... \
    --storage-rucio-user-agent ... \
    --storage-rucio-vo ... \
    --storage-rucio-ignore-checksum ... \
    --storage-rucio-download-rse ... \
    --storage-rucio-upload-rse ... \
    --storage-rucio-upload-dataset ... \
    --storage-rucio-cache-scope ...

Within the workflow

If you want to use this storage plugin only for specific items, you can register it inside of your workflow:

# register storage provider (not needed if no custom settings are to be defined here)
storage:
    provider="rucio",
    # optionally add custom settings here if needed
    # alternatively they can be passed via command line arguments
    # starting with --storage-rucio-..., see
    # snakemake --help
    # Maximum number of requests per second for this storage provider. If nothing is specified, the default implemented by the storage plugin is used.
    max_requests_per_second=...,
    #
    rucio_host=...,
    #
    auth_host=...,
    #
    account=...,
    #
    ca_cert=...,
    #
    auth_type=...,
    #
    creds=...,
    #
    timeout=...,
    #
    user_agent=...,
    #
    vo=...,
    # If true, skips the checksum validation between the downloaded file and the rucio catalogue.
    ignore_checksum=...,
    # Rucio Storage Element (RSE) expression to download files from.
    download_rse=...,
    # Rucio Storage Element (RSE) expression to upload files to.
    upload_rse=...,
    # Rucio dataset to attach files to on upload.
    upload_dataset=...,
    # If true, minimize the number of server calls by caching the size and creation time of all files in the same scope.
    cache_scope=...,

rule example:
    input:
        storage.rucio(
            # define query to the storage backend here
            ...
        ),
    output:
        "example.txt"
    shell:
        "..."

Using multiple entities of the same storage plugin

In case you have to use this storage plugin multiple times, but with different settings (e.g. to connect to different storage servers), you can register it multiple times, each time providing a different tag:

# register shared settings
storage:
    provider="rucio",
    # optionally add custom settings here if needed
    # alternatively they can be passed via command line arguments
    # starting with --storage-rucio-..., see below
    # Maximum number of requests per second for this storage provider. If nothing is specified, the default implemented by the storage plugin is used.
    max_requests_per_second=...,
    #
    rucio_host=...,
    #
    auth_host=...,
    #
    account=...,
    #
    ca_cert=...,
    #
    auth_type=...,
    #
    creds=...,
    #
    timeout=...,
    #
    user_agent=...,
    #
    vo=...,
    # If true, skips the checksum validation between the downloaded file and the rucio catalogue.
    ignore_checksum=...,
    # Rucio Storage Element (RSE) expression to download files from.
    download_rse=...,
    # Rucio Storage Element (RSE) expression to upload files to.
    upload_rse=...,
    # Rucio dataset to attach files to on upload.
    upload_dataset=...,
    # If true, minimize the number of server calls by caching the size and creation time of all files in the same scope.
    cache_scope=...,

# register multiple tagged entities
storage foo:
    provider="rucio",
    # optionally add custom settings here if needed
    # alternatively they can be passed via command line arguments
    # starting with --storage-rucio-..., see below.
    # To only pass a setting to this tagged entity, prefix the given value with
    # the tag name, i.e. foo:max_requests_per_second=...
    # Maximum number of requests per second for this storage provider. If nothing is specified, the default implemented by the storage plugin is used.
    max_requests_per_second=...,
    #
    rucio_host=...,
    #
    auth_host=...,
    #
    account=...,
    #
    ca_cert=...,
    #
    auth_type=...,
    #
    creds=...,
    #
    timeout=...,
    #
    user_agent=...,
    #
    vo=...,
    # If true, skips the checksum validation between the downloaded file and the rucio catalogue.
    ignore_checksum=...,
    # Rucio Storage Element (RSE) expression to download files from.
    download_rse=...,
    # Rucio Storage Element (RSE) expression to upload files to.
    upload_rse=...,
    # Rucio dataset to attach files to on upload.
    upload_dataset=...,
    # If true, minimize the number of server calls by caching the size and creation time of all files in the same scope.
    cache_scope=...,

rule example:
    input:
        storage.foo(
            # define query to the storage backend here
            ...
        ),
    output:
        "example.txt"
    shell:
        "..."

Settings

The storage plugin has the following settings (which can be passed via command line, the workflow or environment variables, if provided in the respective columns):

Settings

CLI argument

Description

Default

Choices

Required

Type

--storage-rucio-max-requests-per-second VALUE

Maximum number of requests per second for this storage provider. If nothing is specified, the default implemented by the storage plugin is used.

None

--storage-rucio-rucio-host VALUE

None

--storage-rucio-auth-host VALUE

None

--storage-rucio-account VALUE

None

--storage-rucio-ca-cert VALUE

None

--storage-rucio-auth-type VALUE

None

--storage-rucio-creds VALUE

None

--storage-rucio-timeout VALUE

600

--storage-rucio-user-agent VALUE

'rucio-clients'

--storage-rucio-vo VALUE

None

--storage-rucio-ignore-checksum VALUE

If true, skips the checksum validation between the downloaded file and the rucio catalogue.

False

--storage-rucio-download-rse VALUE

Rucio Storage Element (RSE) expression to download files from.

None

--storage-rucio-upload-rse VALUE

Rucio Storage Element (RSE) expression to upload files to.

None

--storage-rucio-upload-dataset VALUE

Rucio dataset to attach files to on upload.

None

--storage-rucio-cache-scope VALUE

If true, minimize the number of server calls by caching the size and creation time of all files in the same scope.

False

Further details

The example Snakefile below will write a URL from which the file test.txt from the testing scope can be accessed. This URL can be used to stream the data from the file if the protocol supports it, or download the file at a later stage.

rule get_url:
    input:
        storage("rucio://testing/test.txt", retrieve=False)
    output:
        "results/test_url.txt"
    shell:
        "echo {input} > {output}"