Snakemake storage plugin: acadfetch

https://img.shields.io/badge/repository-unknown-blue?color=%23022c22 PyPI - Version PyPI - License Snakemake

Warning

No repository URL found in Pypi metadata. The plugin should specify a repository URL in its pyproject.toml (key 'repository'). It is unclear whether the plugin is maintained and reviewed by the official Snakemake organization (https://github.com/snakemake).

Installation

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

pip install snakemake-storage-plugin-acadfetch

Or, if you are using pixi, add the plugin to your pixi.toml. Be careful to put it under the right dependency type based on the plugin’s availability, e.g.:

snakemake-storage-plugin-acadfetch = "*"

Usage

Queries

Queries to this storage should have the following format:

Query type

Query

Description

input

https://zenodo.org/records/123456/files/raw.tar.gz

A file URL, as printed by acadfetch fetch <target> -w -

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 acadfetch --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 acadfetch --default-storage-prefix ... \
    --storage-acadfetch-max-requests-per-second ... \
    --storage-acadfetch-rate ... \
    --storage-acadfetch-retries ... \
    --storage-acadfetch-timeout ... \
    --storage-acadfetch-header ...

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="acadfetch",
    # optionally add custom settings here if needed
    # alternatively they can be passed via command line arguments
    # starting with --storage-acadfetch-..., 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=...,
    # Requests per second, global (default: 2).
    rate=...,
    # Retries per transfer on 5xx/429/network errors (default: 4).
    retries=...,
    # Per-request timeout in seconds, connect and idle (default: 60).
    timeout=...,
    # Extra request header as 'Name: value', for a restricted record.
    header=...,

rule example:
    input:
        storage.acadfetch(
            # 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="acadfetch",
    # optionally add custom settings here if needed
    # alternatively they can be passed via command line arguments
    # starting with --storage-acadfetch-..., 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=...,
    # Requests per second, global (default: 2).
    rate=...,
    # Retries per transfer on 5xx/429/network errors (default: 4).
    retries=...,
    # Per-request timeout in seconds, connect and idle (default: 60).
    timeout=...,
    # Extra request header as 'Name: value', for a restricted record.
    header=...,

# register multiple tagged entities
storage foo:
    provider="acadfetch",
    # optionally add custom settings here if needed
    # alternatively they can be passed via command line arguments
    # starting with --storage-acadfetch-..., 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=...,
    # Requests per second, global (default: 2).
    rate=...,
    # Retries per transfer on 5xx/429/network errors (default: 4).
    retries=...,
    # Per-request timeout in seconds, connect and idle (default: 60).
    timeout=...,
    # Extra request header as 'Name: value', for a restricted record.
    header=...,

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-acadfetch-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-acadfetch-rate VALUE

Requests per second, global (default: 2).

None

✗

--storage-acadfetch-retries VALUE

Retries per transfer on 5xx/429/network errors (default: 4).

None

✗

--storage-acadfetch-timeout VALUE

Per-request timeout in seconds, connect and idle (default: 60).

None

✗

--storage-acadfetch-header VALUE

Extra request header as ‘Name: value’, for a restricted record.

None

✗