dandi_compute_code.dandiset#

class dandi_compute_code.dandiset.AssetMetadata(path, date_modified, content_size, content_id)[source]#

Bases: object

Minimal indexed metadata for one asset path.

Parameters:
  • path (str)

  • date_modified (str)

  • content_size (int)

  • content_id (str)

path: str#
date_modified: str#
content_size: int#
content_id: str#
class dandi_compute_code.dandiset.AssetsJsonldMetadata(content_id_to_asset, path_to_asset_metadata)[source]#

Bases: object

Indexed metadata loaded from DANDI assets.jsonld.

Parameters:
content_id_to_asset: dict[str, dict[str, object]]#
path_to_asset_metadata: dict[str, AssetMetadata]#
dandi_compute_code.dandiset.delete_dandiset_version(dandiset_directory, version)[source]#

Delete all version-{version} directories from the DANDI archive and the local filesystem.

Scans {dandiset_directory}/derivatives/dandiset-*/ for directories named version-{version} at any depth, runs dandi delete on each one (answering the interactive confirmation prompt automatically), and then removes the local directory tree.

Parameters:
  • dandiset_directory (Path) – Path to a local clone of the dandiset repository.

  • version (str) – The base version string to delete (e.g. "v1.0.0"). Matches the exact directory version-v1.0.0 as well as any hash-suffixed variant such as version-v1.0.0+fixes+20abeb6.

Returns:

A list of version directories that were deleted, in sorted order.

Return type:

list[Path]

Raises:

RuntimeError – If the DANDI_API_KEY environment variable is not set or is blank.

dandi_compute_code.dandiset.load_assets_jsonld_metadata()[source]#

Load content-id and path metadata from the DANDI 001697 draft assets.jsonld stream.

Returns:

Indexed assets metadata.

Return type:

AssetsJsonldMetadata

dandi_compute_code.dandiset.scan_version_directories(dandiset_directory, version)[source]#

Find all version-{version}* directories under dandiset_directory.

Scans {dandiset_directory}/derivatives/dandiset-*/ and returns every directory whose name equals version-{version} or starts with version-{version}+ (to capture hash-suffixed variants such as version-v1.0.0+fixes+20abeb6). Directories not inside a dandiset-* subtree are ignored.

Parameters:
  • dandiset_directory (Path) – Path to a local clone of the dandiset repository.

  • version (str) – The base version string to search for (e.g. "v1.0.0"). Matches the exact directory version-v1.0.0 as well as any hash-suffixed variant such as version-v1.0.0+fixes+20abeb6.

Returns:

Sorted list of matching version directory paths.

Return type:

list[Path]