|
1 | | -# OpenNeuro CLI for Deno |
| 1 | +--- |
| 2 | +name: Command Line Interface |
| 3 | +route: /cli |
| 4 | +--- |
2 | 5 |
|
3 | | -Command line tools for OpenNeuro. Upload and download support for working with OpenNeuro datasets from the command line. |
| 6 | +# OpenNeuro command line interface |
4 | 7 |
|
5 | | -## Install |
| 8 | +This tool allows you to upload and download [OpenNeuro.org](https://openneuro.org) datasets without a browser. |
6 | 9 |
|
7 | | -Download deno via [any supported installation method](https://docs.deno.com/runtime/manual/getting_started/installation). |
| 10 | +## Install |
8 | 11 |
|
9 | | -## Usage |
| 12 | +1. Install [Deno] (https://deno.land/) via [any supported installation method](https://docs.deno.com/runtime/manual/getting_started/installation). |
| 13 | +2. In a terminal type: `deno run -A jsr:@openneuro/cli --help` |
10 | 14 |
|
11 | | -OpenNeuro CLI will validate your dataset with the [bids-validator](https://github.com/bids-standard/bids-validator/) and then allow you to upload to OpenNeuro. If you wish to make changes to a dataset, the CLI can download, allow you to make local changes, and reupload only the changes to OpenNeuro. |
| 15 | +To download annexed files, you will need the git-annex special remote for OpenNeuro. |
12 | 16 |
|
13 | 17 | ```shell |
14 | | -# Interactive help |
15 | | -deno run -A jsr:@openneuro/cli --help |
16 | | -# Available for each subcommand |
17 | | -deno run -A jsr:@openneuro/cli upload --help |
| 18 | +# A script is provided to wrap the CLI as a special remote |
| 19 | +curl https://raw.githubusercontent.com/OpenNeuroOrg/openneuro/refs/heads/master/bin/git-annex-remote-openneuro -o git-annex-remote-openneuro |
| 20 | +# Make this executable and move this script to your path |
| 21 | +chmod +x git-annex-remote-openneuro |
18 | 22 | ``` |
19 | 23 |
|
20 | | -### Login |
| 24 | +## Setup |
21 | 25 |
|
22 | | -To upload or download data from OpenNeuro, login with your account. |
| 26 | +The setup step is needed for both uploading _and_ downloading data from OpenNeuro. |
23 | 27 |
|
24 | | -```shell |
25 | | -# Run login and follow the prompts |
26 | | -deno run -A jsr:@openneuro/cli login |
27 | | -``` |
| 28 | +Run `deno run -A jsr:@openneuro/cli login` to configure credentials. |
| 29 | +This prompts you for the required configuration fields and these are saved in Deno's local storage. |
| 30 | + |
| 31 | +`deno run -A jsr:@openneuro/cli login` will require you to enter an API key. |
28 | 32 |
|
29 | | -You can also create an API key on [OpenNeuro](https://openneuro.org/keygen) and specify this as an option or environment variable. |
| 33 | +You can obtain an API key via a browser on [OpenNeuro](https://openneuro.org/keygen) after logging to the OpenNeuro platform via one of the provided authentication services (for example ORCID). |
| 34 | + |
| 35 | +You can also specify this as an option or environment variable. |
30 | 36 |
|
31 | 37 | ```shell |
32 | 38 | # For scripts |
33 | 39 | export OPENNEURO_API_KEY=<api_key> |
34 | 40 | deno run -A jsr:@openneuro/cli login --error-reporting true |
35 | 41 | ``` |
36 | 42 |
|
37 | | -### Uploading |
| 43 | +## Usage |
| 44 | + |
| 45 | +### Uploading datasets |
| 46 | + |
| 47 | +To upload a new dataset: |
38 | 48 |
|
39 | 49 | ```shell |
40 | 50 | # Path to the dataset root (directory containing dataset_description.json) |
41 | 51 | deno run -A jsr:@openneuro/cli upload --affirmDefaced path/to/dataset |
42 | 52 | ``` |
43 | 53 |
|
| 54 | +Your dataset must pass validation to upload but warnings can be skipped with `deno run -A jsr:@openneuro/cli upload -i path/to/dataset`. A default label is set using the directory name. |
| 55 | + |
| 56 | +To resume an interrupted upload or add files to an existing dataset: |
| 57 | + |
44 | 58 | ```shell |
45 | 59 | # Add files to an existing dataset |
46 | 60 | deno run -A jsr:@openneuro/cli upload --dataset ds000001 path/to/dataset |
47 | 61 | ``` |
48 | 62 |
|
| 63 | +where <accession_number> is a unique dataset identifier that can be found in the URL. For example accession number for `https://openneuro.org/datasets/ds001555` is `ds001555`. |
| 64 | + |
| 65 | +This command will add or replace any files in the dataset but does not delete any files that are only present in the server copy of the dataset. |
| 66 | + |
| 67 | +### Downloading datasets |
| 68 | + |
| 69 | +Downloads using the CLI will create a DataLad dataset and configure a special remote to retrieve the larger annexed files from OpenNeuro. |
| 70 | + |
| 71 | +To download a snapshot: |
| 72 | + |
| 73 | +```shell |
| 74 | +deno run -A jsr:@openneuro/cli download <accession number> <destination directory> |
| 75 | +``` |
| 76 | + |
| 77 | +To download the current draft files: |
| 78 | + |
| 79 | +```shell |
| 80 | +deno run -A jsr:@openneuro/cli download --draft <accession number> <destination directory> |
| 81 | +``` |
| 82 | + |
| 83 | +If the destination directory does not exist, it will be created. |
| 84 | + |
| 85 | +To download the annexed objects, use [DataLad](https://datalad.org/) or [git-annex](https://git-annex.branchable.com). |
| 86 | + |
| 87 | +```shell |
| 88 | +cd ds000001 |
| 89 | +# Make sure you have the `git-annex-remote-openneuro` script available in your path |
| 90 | +git-annex get <path or paths to download> |
| 91 | +# DataLad is supported as well |
| 92 | +datalad get <path or paths to download> |
| 93 | +``` |
| 94 | + |
| 95 | +### Debugging issues |
| 96 | + |
49 | 97 | ```shell |
50 | 98 | # To debug issues - enable logging and provide this log to support or open a GitHub issue |
51 | 99 | export OPENNEURO_LOG=INFO |
52 | 100 | deno run -A jsr:@openneuro/cli upload --affirmDefaced path/to/dataset |
53 | 101 | ``` |
54 | 102 |
|
55 | | -## Implementation Notes |
| 103 | +### Implementation Notes |
56 | 104 |
|
57 | | -This tool uses isomorphic git to download, modify, and push datasets using OpenNeuro's [git interface](https://docs.openneuro.org/git.html). Other tools that support git and git-annex repositories such as [DataLad](https://www.datalad.org/) can also be used with the local copy. |
| 105 | +This tool uses isomorphic git to download, modify, and push datasets using OpenNeuro's [git interface](https://docs.openneuro.org/git.html). Other tools that support git and git-annex repositories such as [DataLad](https://www.datalad.org/) can also be used with the local copy. |
0 commit comments