Beispiel #1
0
def main(
    ctx: click.Context,
    asset_filter: Optional[re.Pattern[str]],
    dandi_instance: str,
    force: Optional[str],
    jobs: int,
    log_level: int,
    pdb: bool,
    quiet_debug: bool,
    target: Path,
    s3bucket: str,
) -> None:
    ctx.obj = DandiDatasetter(
        dandi_client=ctx.with_resource(
            DandiAPIClient.for_dandi_instance(dandi_instance)),
        target_path=target,
        config=Config(
            asset_filter=asset_filter,
            jobs=jobs,
            force=force,
            s3bucket=s3bucket,
        ),
    )
    if pdb:
        sys.excepthook = pdb_excepthook
    if quiet_debug:
        log.setLevel(logging.DEBUG)
        log_level = logging.INFO
    logging.basicConfig(
        format="%(asctime)s [%(levelname)-8s] %(name)s %(message)s",
        datefmt="%Y-%m-%dT%H:%M:%S%z",
        level=log_level,
        force=True,  # Override dandi's settings
    )
    ctx.obj.debug_logfile()
Beispiel #2
0
def dandi_client() -> DandiAPIClient:
    api_token = os.environ["DANDI_API_KEY"]
    with DandiAPIClient.for_dandi_instance("dandi-staging",
                                           token=api_token) as client:
        yield client
Beispiel #3
0
import json

from dandi.dandiapi import DandiAPIClient

with DandiAPIClient.for_dandi_instance("dandi") as client:
    for dandiset in client.get_dandisets():
        if dandiset.most_recent_published_version is None:
            continue
        latest_dandiset = dandiset.for_version(
            dandiset.most_recent_published_version)
        for asset in latest_dandiset.get_assets():
            metadata = asset.get_metadata()
            if any(mtt is not None and "two-photon" in mtt.name
                   for mtt in (metadata.measurementTechnique or [])):
                print(json.dumps(metadata.json_dict(), indent=4))
                # Can be used to also download the asset:
                # asset.download(pathlib.Path(dandiset.identifier, asset.path))