dandi.consts

Constants and configuration for DANDI CLI.

This module defines constants used throughout the DANDI CLI including: - Metadata field definitions for NWB files - Known DANDI Archive instances and their configurations - File organization patterns and BIDS-related constants - Request timeouts and retry settings

dandi.consts.DANDISET_ID_REGEX = '[0-9]{6}'

Regular expression for a valid Dandiset identifier. This regex is not anchored.

dandi.consts.DOWNLOAD_SUFFIX = '.dandidownload'

Suffix used for temporary download directories

dandi.consts.DRAFT = 'draft'

The identifier for draft Dandiset versions

class dandi.consts.DandiInstance(name: 'str', gui: 'str | None', api: 'str')[source]
api: str
gui: str | None
name: str
property redirector: None
urls() → Iterator[str][source]
class dandi.consts.EmbargoStatus(value)[source]
EMBARGOED = 'EMBARGOED'
OPEN = 'OPEN'
UNEMBARGOING = 'UNEMBARGOING'
dandi.consts.IMAGE_FILE_EXTENSIONS = ['.png', '.jpg', '.jpeg', '.gif']

Extensions of the images an ExternalImage may point at. NWB restricts image_format to PNG, JPEG and GIF, so nothing else can be referenced by an NWB file in the first place.

dandi.consts.MAX_CHUNK_SIZE = 8388608

Chunk size when iterating a download (and upload) body. Taken from girder-cli TODO: should we make them smaller for download than for upload? ATM used only in download

dandi.consts.MAX_ZARR_DEPTH = 7

Maximum allowed depth of a Zarr directory tree

dandi.consts.MTIME_TOLERANCE = 2.0

Tolerance (in seconds) when comparing an asset’s recorded mtime against the mtime read back from the downloaded file under -e refresh. That local mtime is one we set ourselves with os.utime(), so the comparison is really a filesystem round trip, and not every filesystem stores mtimes at the resolution os.stat() reports them at: mounted Windows volumes, exFAT and some network filesystems truncate, and FAT rounds to a multiple of two seconds. See https://github.com/dandi/dandi-cli/issues/1907

dandi.consts.PUBLISHED_VERSION_REGEX = '[0-9]+\\.[0-9]+\\.[0-9]+'

Regular expression for a valid published (i.e., non-draft) Dandiset version identifier. This regex is not anchored.

dandi.consts.REDIRECT_HEAD_TIMEOUT = 30

Per-request timeout (seconds) for HEAD requests issued by follow_redirect while resolving a redirect chain. Without it, requests hangs indefinitely on a stalled hop (observed on Windows CI).

dandi.consts.RETRY_STATUSES = (429, 500, 502, 503, 504)

HTTP response status codes that should always be retried (until we run out of retries)

dandi.consts.S3_MAX_SINGLE_PART_UPLOAD = 5368709120

Maximum file size for a single S3 PUT upload (5 GiB). S3 rejects single-part PUTs larger than this; such files would need multipart upload which is not yet supported for zarr chunks.

class dandi.consts.SyncMode(value)[source]
ASK = 'ask'
DO = 'do'
dandi.consts.VERSION_REGEX = '(?:[0-9]+\\.[0-9]+\\.[0-9]+|draft)'

Regular expression for a valid Dandiset version identifier. This regex is not anchored.

dandi.consts.ZARR_DELETE_BATCH_SIZE = 100

Maximum number of Zarr directory entries to delete at once

dandi.consts.ZARR_MIME_TYPE = 'application/x-zarr'

MIME type assigned to & used to identify Zarr assets

dandi.consts.ZARR_UPLOAD_BATCH_SIZE = 255

Maximum number of Zarr directory entries to upload at once

dandi.consts.metadata_nwb_file_fields = ('experiment_description', 'experimenter', 'identifier', 'institution', 'keywords', 'lab', 'related_publications', 'session_description', 'session_id', 'session_start_time')

A list of metadata fields which dandi extracts from .nwb files. Additional fields (such as number_of_*) might be added by get_metadata()