dandi_compute_code.dandiset#
- class dandi_compute_code.dandiset.AssetMetadata(path, date_modified, content_size, content_id)[source]#
Bases:
objectMinimal indexed metadata for one asset path.
- class dandi_compute_code.dandiset.AssetsJsonldMetadata(content_id_to_asset, path_to_asset_metadata)[source]#
Bases:
objectIndexed metadata loaded from DANDI
assets.jsonld.- Parameters:
- 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 namedversion-{version}at any depth, runsdandi deleteon each one (answering the interactive confirmation prompt automatically), and then removes the local directory tree.- Parameters:
- Returns:
A list of version directories that were deleted, in sorted order.
- Return type:
- Raises:
RuntimeError – If the
DANDI_API_KEYenvironment variable is not set or is blank.
- dandi_compute_code.dandiset.load_assets_jsonld_metadata(dandiset_id='001697')[source]#
Load content-id and path metadata from a DANDI draft
assets.jsonldstream.- Parameters:
dandiset_id (
str) – The Dandiset whose draftassets.jsonldis loaded. Defaults to the job capsules Dandiset (001697), where jobs run; pass the failed runs archive Dandiset (001873) to describe the archived state instead.- Returns:
Indexed assets metadata.
- Return type:
- dandi_compute_code.dandiset.move_job_capsule(
- *,
- capsule_path,
- source_dandiset_id='001697',
- target_dandiset_id='001873',
- processing_directory=None,
- test=False,
Move a single job capsule folder from one Dandiset to another.
The capsule subtree is downloaded from source_dandiset_id into a fresh temporary working tree via
dandi download --preserve-tree, copied under a locally materialized copy of the target_dandiset_id tree, uploaded viadandi upload --allow-any-path, and only then removed from source_dandiset_id viadandi delete. The temporary working tree is removed on success. Each step is restricted to the single capsule subtree so the operation touches the minimum number of assets.The path of the capsule inside the Dandiset is preserved exactly. Only the enclosing Dandiset changes. Deletion from the source happens only after the upload to the target succeeds, so a failed upload never destroys the original.
- Parameters:
capsule_path (
str) – Path of the job capsule folder relative to the Dandiset root (for examplederivatives/dandiset-000409/sub-mouse01/pipeline-aind+ephys/ version-v1.0_params-default_config-abc123_attempt-1).source_dandiset_id (
str) – Dandiset the capsule is moved from. Defaults to the job capsules Dandiset (001697).target_dandiset_id (
str) – Dandiset the capsule is moved to. Defaults to the failed runs archive Dandiset (001873).processing_directory (
Path|None) – Directory in which the temporary per-capsule working tree is created. WhenNone, the system default temporary location is used.test (
bool) – WhenTrue, leave the temporary working tree on disk after a successful move for debugging.
- Raises:
RuntimeError – If
DANDI_API_KEYis unset or blank, or if anydandisubprocess returns a non-zero exit code. The temporary working tree is intentionally left in place when any step fails so that it can be inspected.- Return type:
- 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 equalsversion-{version}or starts withversion-{version}+(to capture hash-suffixed variants such asversion-v1.0.0+fixes+20abeb6). Directories not inside adandiset-*subtree are ignored.- Parameters:
- Returns:
Sorted list of matching version directory paths.
- Return type: