Skip to content

Commit 091ce2e

Browse files
committed
deploy: 74beca7
1 parent e387bf9 commit 091ce2e

File tree

3 files changed

+117
-43
lines changed

3 files changed

+117
-43
lines changed

_sources/packages/openneuro-cli.md.txt

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,58 +9,97 @@ This tool allows you to upload and download [OpenNeuro.org](https://openneuro.or
99

1010
## Install
1111

12-
1. Install [Node.js](https://nodejs.org) (version 18 or higher)
13-
2. In a terminal type: `npm install -g @openneuro/cli`
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`
1414

15-
If you are using [yarn](https://yarnpkg.com/) you can also perform the installation with `yarn global add @openneuro/cli`
16-
(make sure the installation folder is part of your `PATH` by adding `export PATH="$(yarn global bin):$PATH"` to `~/.bashrc`)
15+
To download annexed files, you will need the git-annex special remote for OpenNeuro.
16+
17+
```shell
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
22+
```
1723

1824
## Setup
1925

2026
The setup step is needed for both uploading _and_ downloading data from OpenNeuro.
2127

22-
Run `openneuro login` to configure credentials.
23-
This prompts you for the required configuration fields and saves this to `.openneuro` in your home directory or profile.
24-
`openneuro login` will require you to enter an API key.
25-
You can obtain an API key via a browser at https://openneuro.org/keygen after logging to the OpenNeuro platform via one of the provided authentication services (for example ORCID).
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.
32+
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.
2636

27-
After successfully running `openneuro login`, you can manually configure custom servers by editing the `.openneuro` file.
37+
```shell
38+
# For scripts
39+
export OPENNEURO_API_KEY=<api_key>
40+
deno run -A jsr:@openneuro/cli login --error-reporting true
41+
```
2842

2943
## Usage
3044

3145
### Uploading datasets
3246

3347
To upload a new dataset:
3448

35-
`openneuro upload <dataset directory>`
49+
```shell
50+
# Path to the dataset root (directory containing dataset_description.json)
51+
deno run -A jsr:@openneuro/cli upload --affirmDefaced path/to/dataset
52+
```
3653

37-
Your dataset must pass validation to upload but warnings can be skipped with `openneuro upload -i <dataset directory>`. A default label is set using the directory name.
54+
Your dataset must pass validation to upload but warnings can be skipped with `deno run -A jsr:@openneuro/cli upload --ignoreWarnings path/to/dataset`.
3855

3956
To resume an interrupted upload or add files to an existing dataset:
4057

41-
`openneuro upload --dataset <accession number> <dataset directory>`
58+
```shell
59+
# Add files to an existing dataset
60+
deno run -A jsr:@openneuro/cli upload --dataset ds000001 path/to/dataset
61+
```
4262

4363
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`.
4464

4565
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.
4666

4767
### Downloading datasets
4868

69+
Downloads using the CLI will create a DataLad dataset and configure a special remote to retrieve the larger annexed files from OpenNeuro.
70+
4971
To download a snapshot:
5072

51-
`openneuro download <accession number> <destination directory>`
73+
```shell
74+
deno run -A jsr:@openneuro/cli download <accession number> <destination directory>
75+
```
5276

5377
To download the current draft files:
5478

55-
`openneuro download --draft <accession number> <destination directory>`
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).
5686

57-
If the destination directory does not exist, it will be created. Any files from the dataset that are already present in the directory will be skipped, allowing you to resume an interrupted download.
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+
```
5894

59-
## Errors
95+
### Debugging issues
6096

61-
Package: OpenNeuro CLI download option
97+
```shell
98+
# To debug issues - enable logging and provide this log to support or open a GitHub issue
99+
export OPENNEURO_LOG=INFO
100+
deno run -A jsr:@openneuro/cli upload --affirmDefaced path/to/dataset
101+
```
62102

63-
Issue: `TypeError: path must be a string or Buffer`
103+
### Implementation Notes
64104

65-
Solution: This error is due to a failure to read the `~/.openneuro` configuration file.
66-
This file can be created with the command `openneuro login`, see the "Setup" step above.
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.

packages/openneuro-cli.html

Lines changed: 57 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -269,48 +269,82 @@ <h1>OpenNeuro command line interface<a class="headerlink" href="#openneuro-comma
269269
<section id="install">
270270
<h2>Install<a class="headerlink" href="#install" title="Link to this heading"></a></h2>
271271
<ol class="arabic simple">
272-
<li><p>Install <a class="reference external" href="https://nodejs.org">Node.js</a> (version 18 or higher)</p></li>
273-
<li><p>In a terminal type: <code class="docutils literal notranslate"><span class="pre">npm</span> <span class="pre">install</span> <span class="pre">-g</span> <span class="pre">&#64;openneuro/cli</span></code></p></li>
272+
<li><p>Install [Deno] (https://deno.land/) via <a class="reference external" href="https://docs.deno.com/runtime/manual/getting_started/installation">any supported installation method</a>.</p></li>
273+
<li><p>In a terminal type: <code class="docutils literal notranslate"><span class="pre">deno</span> <span class="pre">run</span> <span class="pre">-A</span> <span class="pre">jsr:&#64;openneuro/cli</span> <span class="pre">--help</span></code></p></li>
274274
</ol>
275-
<p>If you are using <a class="reference external" href="https://yarnpkg.com/">yarn</a> you can also perform the installation with <code class="docutils literal notranslate"><span class="pre">yarn</span> <span class="pre">global</span> <span class="pre">add</span> <span class="pre">&#64;openneuro/cli</span></code>
276-
(make sure the installation folder is part of your <code class="docutils literal notranslate"><span class="pre">PATH</span></code> by adding <code class="docutils literal notranslate"><span class="pre">export</span> <span class="pre">PATH=&quot;$(yarn</span> <span class="pre">global</span> <span class="pre">bin):$PATH&quot;</span></code> to <code class="docutils literal notranslate"><span class="pre">~/.bashrc</span></code>)</p>
275+
<p>To download annexed files, you will need the git-annex special remote for OpenNeuro.</p>
276+
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span><span class="c1"># A script is provided to wrap the CLI as a special remote</span>
277+
curl<span class="w"> </span>https://raw.githubusercontent.com/OpenNeuroOrg/openneuro/refs/heads/master/bin/git-annex-remote-openneuro<span class="w"> </span>-o<span class="w"> </span>git-annex-remote-openneuro
278+
<span class="c1"># Make this executable and move this script to your path</span>
279+
chmod<span class="w"> </span>+x<span class="w"> </span>git-annex-remote-openneuro
280+
</pre></div>
281+
</div>
277282
</section>
278283
<section id="setup">
279284
<h2>Setup<a class="headerlink" href="#setup" title="Link to this heading"></a></h2>
280285
<p>The setup step is needed for both uploading <em>and</em> downloading data from OpenNeuro.</p>
281-
<p>Run <code class="docutils literal notranslate"><span class="pre">openneuro</span> <span class="pre">login</span></code> to configure credentials.
282-
This prompts you for the required configuration fields and saves this to <code class="docutils literal notranslate"><span class="pre">.openneuro</span></code> in your home directory or profile.
283-
<code class="docutils literal notranslate"><span class="pre">openneuro</span> <span class="pre">login</span></code> will require you to enter an API key.
284-
You can obtain an API key via a browser at https://openneuro.org/keygen after logging to the OpenNeuro platform via one of the provided authentication services (for example ORCID).</p>
285-
<p>After successfully running <code class="docutils literal notranslate"><span class="pre">openneuro</span> <span class="pre">login</span></code>, you can manually configure custom servers by editing the <code class="docutils literal notranslate"><span class="pre">.openneuro</span></code> file.</p>
286+
<p>Run <code class="docutils literal notranslate"><span class="pre">deno</span> <span class="pre">run</span> <span class="pre">-A</span> <span class="pre">jsr:&#64;openneuro/cli</span> <span class="pre">login</span></code> to configure credentials.
287+
This prompts you for the required configuration fields and these are saved in Deno’s local storage.</p>
288+
<p><code class="docutils literal notranslate"><span class="pre">deno</span> <span class="pre">run</span> <span class="pre">-A</span> <span class="pre">jsr:&#64;openneuro/cli</span> <span class="pre">login</span></code> will require you to enter an API key.</p>
289+
<p>You can obtain an API key via a browser on <a class="reference external" href="https://openneuro.org/keygen">OpenNeuro</a> after logging to the OpenNeuro platform via one of the provided authentication services (for example ORCID).</p>
290+
<p>You can also specify this as an option or environment variable.</p>
291+
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span><span class="c1"># For scripts</span>
292+
<span class="nb">export</span><span class="w"> </span><span class="nv">OPENNEURO_API_KEY</span><span class="o">=</span>&lt;api_key&gt;
293+
deno<span class="w"> </span>run<span class="w"> </span>-A<span class="w"> </span>jsr:@openneuro/cli<span class="w"> </span>login<span class="w"> </span>--error-reporting<span class="w"> </span><span class="nb">true</span>
294+
</pre></div>
295+
</div>
286296
</section>
287297
<section id="usage">
288298
<h2>Usage<a class="headerlink" href="#usage" title="Link to this heading"></a></h2>
289299
<section id="uploading-datasets">
290300
<h3>Uploading datasets<a class="headerlink" href="#uploading-datasets" title="Link to this heading"></a></h3>
291301
<p>To upload a new dataset:</p>
292-
<p><code class="docutils literal notranslate"><span class="pre">openneuro</span> <span class="pre">upload</span> <span class="pre">&lt;dataset</span> <span class="pre">directory&gt;</span></code></p>
293-
<p>Your dataset must pass validation to upload but warnings can be skipped with <code class="docutils literal notranslate"><span class="pre">openneuro</span> <span class="pre">upload</span> <span class="pre">-i</span> <span class="pre">&lt;dataset</span> <span class="pre">directory&gt;</span></code>. A default label is set using the directory name.</p>
302+
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span><span class="c1"># Path to the dataset root (directory containing dataset_description.json)</span>
303+
deno<span class="w"> </span>run<span class="w"> </span>-A<span class="w"> </span>jsr:@openneuro/cli<span class="w"> </span>upload<span class="w"> </span>--affirmDefaced<span class="w"> </span>path/to/dataset
304+
</pre></div>
305+
</div>
306+
<p>Your dataset must pass validation to upload but warnings can be skipped with <code class="docutils literal notranslate"><span class="pre">deno</span> <span class="pre">run</span> <span class="pre">-A</span> <span class="pre">jsr:&#64;openneuro/cli</span> <span class="pre">upload</span> <span class="pre">--ignoreWarnings</span> <span class="pre">path/to/dataset</span></code>.</p>
294307
<p>To resume an interrupted upload or add files to an existing dataset:</p>
295-
<p><code class="docutils literal notranslate"><span class="pre">openneuro</span> <span class="pre">upload</span> <span class="pre">--dataset</span> <span class="pre">&lt;accession</span> <span class="pre">number&gt;</span> <span class="pre">&lt;dataset</span> <span class="pre">directory&gt;</span></code></p>
308+
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span><span class="c1"># Add files to an existing dataset</span>
309+
deno<span class="w"> </span>run<span class="w"> </span>-A<span class="w"> </span>jsr:@openneuro/cli<span class="w"> </span>upload<span class="w"> </span>--dataset<span class="w"> </span>ds000001<span class="w"> </span>path/to/dataset
310+
</pre></div>
311+
</div>
296312
<p>where &lt;accession_number&gt; is a unique dataset identifier that can be found in the URL. For example accession number for <code class="docutils literal notranslate"><span class="pre">https://openneuro.org/datasets/ds001555</span></code> is <code class="docutils literal notranslate"><span class="pre">ds001555</span></code>.</p>
297313
<p>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.</p>
298314
</section>
299315
<section id="downloading-datasets">
300316
<h3>Downloading datasets<a class="headerlink" href="#downloading-datasets" title="Link to this heading"></a></h3>
317+
<p>Downloads using the CLI will create a DataLad dataset and configure a special remote to retrieve the larger annexed files from OpenNeuro.</p>
301318
<p>To download a snapshot:</p>
302-
<p><code class="docutils literal notranslate"><span class="pre">openneuro</span> <span class="pre">download</span> <span class="pre">&lt;accession</span> <span class="pre">number&gt;</span> <span class="pre">&lt;destination</span> <span class="pre">directory&gt;</span></code></p>
319+
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>deno<span class="w"> </span>run<span class="w"> </span>-A<span class="w"> </span>jsr:@openneuro/cli<span class="w"> </span>download<span class="w"> </span>&lt;accession<span class="w"> </span>number&gt;<span class="w"> </span>&lt;destination<span class="w"> </span>directory&gt;
320+
</pre></div>
321+
</div>
303322
<p>To download the current draft files:</p>
304-
<p><code class="docutils literal notranslate"><span class="pre">openneuro</span> <span class="pre">download</span> <span class="pre">--draft</span> <span class="pre">&lt;accession</span> <span class="pre">number&gt;</span> <span class="pre">&lt;destination</span> <span class="pre">directory&gt;</span></code></p>
305-
<p>If the destination directory does not exist, it will be created. Any files from the dataset that are already present in the directory will be skipped, allowing you to resume an interrupted download.</p>
323+
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>deno<span class="w"> </span>run<span class="w"> </span>-A<span class="w"> </span>jsr:@openneuro/cli<span class="w"> </span>download<span class="w"> </span>--draft<span class="w"> </span>&lt;accession<span class="w"> </span>number&gt;<span class="w"> </span>&lt;destination<span class="w"> </span>directory&gt;
324+
</pre></div>
325+
</div>
326+
<p>If the destination directory does not exist, it will be created.</p>
327+
<p>To download the annexed objects, use <a class="reference external" href="https://datalad.org/">DataLad</a> or <a class="reference external" href="https://git-annex.branchable.com">git-annex</a>.</p>
328+
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span><span class="nb">cd</span><span class="w"> </span>ds000001
329+
<span class="c1"># Make sure you have the `git-annex-remote-openneuro` script available in your path</span>
330+
git-annex<span class="w"> </span>get<span class="w"> </span>&lt;path<span class="w"> </span>or<span class="w"> </span>paths<span class="w"> </span>to<span class="w"> </span>download&gt;
331+
<span class="c1"># DataLad is supported as well</span>
332+
datalad<span class="w"> </span>get<span class="w"> </span>&lt;path<span class="w"> </span>or<span class="w"> </span>paths<span class="w"> </span>to<span class="w"> </span>download&gt;
333+
</pre></div>
334+
</div>
335+
</section>
336+
<section id="debugging-issues">
337+
<h3>Debugging issues<a class="headerlink" href="#debugging-issues" title="Link to this heading"></a></h3>
338+
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span><span class="c1"># To debug issues - enable logging and provide this log to support or open a GitHub issue</span>
339+
<span class="nb">export</span><span class="w"> </span><span class="nv">OPENNEURO_LOG</span><span class="o">=</span>INFO
340+
deno<span class="w"> </span>run<span class="w"> </span>-A<span class="w"> </span>jsr:@openneuro/cli<span class="w"> </span>upload<span class="w"> </span>--affirmDefaced<span class="w"> </span>path/to/dataset
341+
</pre></div>
342+
</div>
306343
</section>
344+
<section id="implementation-notes">
345+
<h3>Implementation Notes<a class="headerlink" href="#implementation-notes" title="Link to this heading"></a></h3>
346+
<p>This tool uses isomorphic git to download, modify, and push datasets using OpenNeuro’s <a class="reference external" href="https://docs.openneuro.org/git.html">git interface</a>. Other tools that support git and git-annex repositories such as <a class="reference external" href="https://www.datalad.org/">DataLad</a> can also be used with the local copy.</p>
307347
</section>
308-
<section id="errors">
309-
<h2>Errors<a class="headerlink" href="#errors" title="Link to this heading"></a></h2>
310-
<p>Package: OpenNeuro CLI download option</p>
311-
<p>Issue: <code class="docutils literal notranslate"><span class="pre">TypeError:</span> <span class="pre">path</span> <span class="pre">must</span> <span class="pre">be</span> <span class="pre">a</span> <span class="pre">string</span> <span class="pre">or</span> <span class="pre">Buffer</span></code></p>
312-
<p>Solution: This error is due to a failure to read the <code class="docutils literal notranslate"><span class="pre">~/.openneuro</span></code> configuration file.
313-
This file can be created with the command <code class="docutils literal notranslate"><span class="pre">openneuro</span> <span class="pre">login</span></code>, see the “Setup” step above.</p>
314348
</section>
315349
</section>
316350

@@ -375,9 +409,10 @@ <h2>Errors<a class="headerlink" href="#errors" title="Link to this heading">¶</
375409
<li><a class="reference internal" href="#usage">Usage</a><ul>
376410
<li><a class="reference internal" href="#uploading-datasets">Uploading datasets</a></li>
377411
<li><a class="reference internal" href="#downloading-datasets">Downloading datasets</a></li>
412+
<li><a class="reference internal" href="#debugging-issues">Debugging issues</a></li>
413+
<li><a class="reference internal" href="#implementation-notes">Implementation Notes</a></li>
378414
</ul>
379415
</li>
380-
<li><a class="reference internal" href="#errors">Errors</a></li>
381416
</ul>
382417
</li>
383418
</ul>

0 commit comments

Comments
 (0)