The ns command

pip install neural-studio puts an ns executable on your PATH next to the Python SDK. It has three groups of subcommands: bucket commands that move files between your machine and buckets, two that make ssh, scp, rsync and your editor's remote mode reach a running runtime, and ns runs sync, which delivers metrics recorded while offline. The bucket commands need SDK 0.3.0 or later.

There is no ns login. The key is NEURAL_STUDIO_API_KEY if it is set, then, inside a runtime, the runtime's session key, then api_key in the SDK's config file. In a runtime's terminal the bucket commands and ns runs sync therefore work with no setup; SSH needs a full-access API key. On a laptop or a cluster, a data key (scope data:write, or data:read for reading only, chosen under Account settings → API keys) is enough for the bucket commands and reaches nothing else; see API keys.

Buckets

ns bucket create my-data
ns cp -r ./dataset ns://my-data/dataset/
ns ls ns://my-data/dataset/
ns sync ns://my-data/dataset/ /scratch/dataset

An address is ns://<bucket>/<path>. A trailing slash, or the bucket name alone, means a folder. Every bucket command works in one workspace: inside a runtime it is the runtime's own; elsewhere it is --workspace <id>, else NEURAL_STUDIO_WORKSPACE_ID, else workspace = "<id>" in the config file. Workspace settings shows the workspace's id with a copy button, and echo $NEURAL_STUDIO_WORKSPACE_ID prints it in a runtime's terminal. A bucket is reachable only from workspaces it is visible in.

Bytes go straight between your machine and storage, 16 parts or ranges at a time; the API only hands out signed links. Flag names follow aws s3 wherever there is an equivalent, so -r and --recursive, --exclude, --include, --delete, --dryrun and --quiet mean what they mean there. The exit code is 0 when everything succeeded, 1 when anything failed (each failure is one line on stderr), 2 for a usage error such as a malformed address, and 130 when you press Ctrl-C: transfers stop at the next part, nothing that could resume is cancelled, and running the same command again picks up where it stopped.

ns://workspace/<path> names the workspace's own files (the Files page) and works with ns ls, ns cp, ns mv, ns rm and ns sync; see The workspace's own files.

ns ls

ns ls                                   # the buckets visible in this workspace
ns ls ns://my-data/                     # one level: folders (PRE) first, then files
ns ls -r ns://my-data/runs/             # every file under a folder
ns ls ns://my-data/ --human-readable --summarize

Buckets are listed with their creation time and whether they are read-write or read-only here. Files show their modification time, size and name. --human-readable prints sizes as KiB, MiB and GiB, and --summarize adds the file count and total size.

ns cp

ns cp model.pt ns://my-data/checkpoints/        # keeps the name: checkpoints/model.pt
ns cp model.pt ns://my-data/best.pt             # renames
ns cp -r ./images ns://my-data/images/          # the folder's contents
ns cp ns://my-data/best.pt .                    # into the current folder
ns cp -r ns://my-data/images/ ./images
ns cp ns://my-data/best.pt ns://archive/best.pt # between buckets
  • -r / --recursive copies a folder's contents: ./images/a/b.png goes to ns://my-data/images/a/b.png, and back.
  • --exclude PATTERN and --include PATTERN filter by path relative to the source folder, in the order given, with later rules winning: --exclude "*" --include "*.csv" copies only CSV files. * also matches /.
  • --dryrun prints what would be copied and changes nothing; --quiet prints only errors.
  • --content-type TYPE sets the type of uploaded files; by default it is guessed from the extension.
  • Each file keeps its modification time: it is recorded on upload and set again on download.
  • An interrupted upload resumes when you run the same command again within 24 hours, provided the file's size and modification time have not changed: only the missing parts are sent. A download over 64 MiB is fetched in 16 MiB ranges into a hidden file beside it, .<name>.ns-<12 hex>.part, with its progress in the matching .part.json, and resumes the same way. A file that changes while it is being uploaded, or an object that is replaced while it is being downloaded, fails instead of being stored half old and half new; an upload that can no longer resume is cancelled so its space in the pool is freed at once.
  • Links are followed, to files and to folders, as aws s3 does. A link that leads back into a folder above it, a folder that cannot be read, and a pipe, socket or device each fail with a message rather than being skipped in silence.
  • Two files that would land on one local name are refused before anything is written. Whether README and readme (or two Unicode spellings of café) are one name depends on the disk, so ns checks the destination disk once per run by creating and removing a small hidden probe file there; on a disk that treats them as one name (macOS and Windows by default), download such a pair one at a time or into different folders. If the probe cannot be written, the download stops with that reason.
  • Between two buckets the copy happens in storage and nothing passes through your machine. A file over 1 GiB is copied by a background job that ns waits for.

ns mv

ns mv results.parquet ns://my-data/results/
ns mv -r ns://my-data/tmp/ ns://my-data/old/

The same as ns cp, flags included, then the source is removed, each file only after its copy is complete. Between buckets it is a move in storage.

ns rm

ns rm ns://my-data/old.csv
ns rm -r ns://my-data/tmp/
ns rm -r ns://my-data/logs/ --exclude "*" --include "*.tmp"

-r deletes everything under a folder: ns://my-data/tmp means the folder tmp/ and, if there is one, the file named tmp too, never tmp-old. Without filters the server deletes in large batches and ns prints one line with the count; with --exclude / --include it prints each file. Deleting a file that does not exist is an error.

In the workspace, ns rm -r ns://workspace/<folder>/ without filters moves the folder to the Trash in one request, so you can restore it from the Files page within 30 days. With --exclude / --include, and for a single file, ns rm deletes for good. Inside a runtime, ns rm deletes from the local folder and does not use the Trash.

ns sync

ns sync ./project ns://my-data/project/
ns sync ns://my-data/dataset/ /scratch/dataset --delete
ns sync ns://my-data/a/ ns://archive/a/

Copies what is new or changed so the destination matches the source: a local folder to a bucket folder, the reverse, or one bucket folder to another. A file is skipped when its size and modification time match.

  • --delete removes files in the destination that are not in the source (only among the files the filters select). It is skipped when any copy failed or any source file could not be read, and the reason is printed, so a file the scan never saw is never taken for a deleted one.
  • Modification times are kept to the microsecond. A disk that stores them more coarsely (exFAT and FAT to 2 seconds, HFS+ to 1 second) rounds the time a download sets, so ns sync from a bucket to such a disk copies those files again on every run. Syncing to it with --checksum avoids that for files uploaded with --checksum.
  • --checksum compares content (SHA-256) instead of size and time. Each local file is hashed; a bucket file's SHA-256 is the one its uploader declared, which --checksum uploads send with every file (the server stores it as declared and cannot verify it). A file the bucket holds no SHA-256 for is copied, so --checksum never skips a file it cannot show is identical. An upload interrupted under --checksum resumes only when run again with --checksum.
  • --exclude, --include, --dryrun, --quiet and --content-type work as for ns cp.

ns sync without an ns:// address still replays offline runs, with a one-line notice that this is deprecated; use ns runs sync. The old form will stop working in a future release.

The workspace's own files

ns cp train.py ns://workspace/code/
ns cp -r ns://workspace/results/ ./results
ns sync ./notebooks ns://workspace/notebooks/ --delete
ns ls ns://workspace/
ns mv ns://workspace/old.ipynb ns://workspace/archive/
ns rm -r ns://workspace/tmp/

Inside a runtime ns://workspace/<path> is <path> in the local ~/workspace folder: the commands are plain file operations there, and a bucket on the other side works both ways (ns cp -r ns://workspace/data/ ns://my-data/data/, or back). The platform's hidden .ns-cache and .ns-uploads folders are never copied, synced over or deleted, and ns rm -r removes a link without following it.

On a laptop or cluster the commands go through the Files API with your API key: data:read lists and downloads; data:write or a full-access key also uploads, moves and deletes; your role in the workspace decides as on the Files page. Every byte passes through the API (about 12 MB/s): fine for code and notebooks, while large data belongs in a bucket. Each file is one request, so a dropped connection starts that file again, and an interrupted upload leaves the old file in place. ns cp -r downloads a folder as one zip stream per 50 top-level entries and unpacks it with every entry checked: a path that would leave the destination, or a link, device or pipe in the archive, is refused, and nothing is written through a link already in the destination. A folder over the API's archive limits (10,000 entries or 20 GiB) fails with a message; ns sync fetches file by file instead. ns sync sends a file that is missing, differs in size or is newer on the source side (the workspace records when a file was written, and keeps no checksums, so --checksum sends every file). ns mv within the workspace is a rename on the server and never replaces an existing file.

ns mv and ns cp from ns://workspace/ into a bucket, from a laptop or cluster, run Move to bucket on the server (ns cp copies and checks the same way and deletes nothing): no byte passes through your machine. A move needs the workspace's runtime stopped. The job runs on the server: stopping the command with Ctrl-C leaves it running, and the Transfers tab of the Data page shows it and can cancel it. ns mv -r ns://workspace/runs/ ns://data/archive/ moves the folder's files to archive/ with their paths; ns mv ns://workspace/runs/a.bin ns://data/x/ moves one file into x/ with its name (a move cannot rename it). The command waits until the move ends: every file is copied and checked before the workspace copy is deleted, and if anything fails nothing is deleted and the command exits with the reason. It needs a full-access or data:write API key; --include and --exclude are not supported, and the top level of the workspace cannot be moved.

Refused from a laptop or cluster, with nothing transferred (exit code 2):

  • ns sync between a bucket and ns://workspace/, either way, and ns cp or ns mv from a bucket into ns://workspace/: syncing from the workspace into a bucket from outside a runtime is not available (ns cp and ns mv run on the server); inside a runtime use the local folder (~/workspace).
  • ns cp or ns sync from ns://workspace/ to ns://workspace/: it would pass every byte through your machine; use ns mv, or copy inside a runtime.

ns bucket

ns bucket create my-data
ns bucket delete my-data
ns bucket delete my-data --force     # also deletes everything in it

A bucket name is 3 to 63 lowercase letters, digits and hyphens, starting and ending with a letter or digit; workspace and checkpoints are reserved. A new bucket belongs to the account that owns the workspace, counts in that account's storage pool, and is visible, read-write, in this workspace only. Creating and deleting need an editor or the owner.

ns credentials

ns credentials my-data

Prints one-hour, read-only S3 credentials for one bucket as the JSON AWS's credential_process setting expects (Version, AccessKeyId, SecretAccessKey, SessionToken, Expiration). With a profile like this, boto3, s3fs, PyArrow and the AWS CLI fetch fresh credentials on their own:

[profile my-data]
credential_process = ns credentials my-data --workspace <workspace-id>
region = us-east-1

The credentials reach only that bucket's folder in storage, and only for reading; uploads go through ns cp and the SDK so listings and the storage pool stay exact. The folder's s3:// address is the uri of data.credentials("my-data") in the SDK.

Messages you may see

  • bucket 'x' was not found in this workspace: the name is wrong, or the bucket is not visible in this workspace (another workspace's buckets answer the same way).
  • This bucket is read-only in this workspace: it is visible here read-only; ask the account that owns it.
  • Your role in this workspace cannot change data: viewers can list and download, not upload, move or delete.
  • Not enough storage in the account's pool: this needs ... and ... is free: the upload or copy would not fit; delete files or buckets first.
  • Buckets are not enabled on this server: the API you are pointed at has buckets switched off.
  • no workspace: pass --workspace or set NEURAL_STUDIO_WORKSPACE_ID.
  • The workspace was not found: the workspace id is wrong, or the API key's account is not a member of it.
  • This API key's scope does not allow this: a data:read key lists and downloads only; use a data:write key to change files.
  • this runtime has no workspace folder: the runtime was launched without the workspace drive, so ns://workspace/ is not available in it.
  • the server did not confirm whether this upload finished: the answer to the final step was lost on the way back and the server kept saying it was still working on it for 10 minutes. Check with ns ls, and run the command again if the file is missing.

ns ssh-config

ns ssh-config <session-id>             # print the block
ns ssh-config --install <session-id>   # merge it into ~/.ssh/config
ns ssh-config --install --user user <session-id>

Prints, or installs, a Host ns-<session-id> block for one runtime. The <session-id> is the runtime's session id, shown under Connect → SSH Access in the notebook's runtime bar. The block is:

Host ns-<session-id>
    HostName <session-id>
    User user
    ProxyCommand ns ssh --stdio <session-id>
    StrictHostKeyChecking accept-new
    UserKnownHostsFile ~/.ssh/known_hosts.neural-studio
  • --install writes it into ~/.ssh/config (mode 0600) between # >>> neural-studio ns-<session-id> >>> and # <<< ... <<< markers, so running it again replaces the block instead of appending a second one.
  • The login user is the one the API reports for the runtime (user today); --user overrides it. Printing the block works without an API key; the user lookup then falls back to user.
  • ssh runs the ProxyCommand from your login shell, so ns must be on that shell's PATH and the API key visible to it, not only to a virtualenv.
  • Host keys are recorded in ~/.ssh/known_hosts.neural-studio on first connect. Every runtime is a fresh machine with its own session id and its own host key; if ssh ever complains about a changed key, delete the old line from that file.

With the block installed, ssh ns-<session-id>, scp, rsync, VS Code Remote-SSH, Cursor and JetBrains Gateway all work unmodified. The full walkthrough, including key registration, is on SSH into your runtime.

ns ssh

ns ssh <session-id>                    # same as: ssh ns-<session-id>
ns ssh <session-id> -L 6006:localhost:6006

A shortcut that runs ssh ns-<session-id> with any extra arguments passed through. It relies on the block from ns ssh-config --install. The hidden form ns ssh --stdio <session-id> is the ProxyCommand bridge itself: it fetches a single-use SSH ticket from the API, opens the session gateway's relay and pipes your SSH client's bytes through the runtime's outbound tunnel. Key authentication stays end to end between your ssh and the runtime's sshd; the platform only decides which runtime you may reach.

Messages you may see:

  • ns: gateway rejected the SSH relay upgrade: the runtime is not running with a connected tunnel, or the ticket was refused. Check its status in the app and retry.
  • ns: No API key found: set NEURAL_STUDIO_API_KEY or the config file.
  • ns: the session gateway host is not configured: the API you are pointed at has no gateway; check NEURAL_STUDIO_API_URL.
  • A 404 from the API: you are not an editor or owner of the runtime's workspace, or the session id is wrong.

ns runs sync

ns runs sync                       # every run-*.db under ./.neural-studio
ns runs sync /tmp/ns-spill         # another directory
ns runs sync run-<id>.db           # one file
ns runs sync --project resnet      # offline runs recorded without a project

Replays spill files left behind by mode="offline" runs, by a crash, or by a finish that gave up on a dead network: it creates offline runs on the server, delivers their metric batches, console lines and media, performs any owed finish and compacts the file. Delivery is exactly once, so a second ns runs sync is a no-op. It prints one summary line, lists files still pending, and exits 0 when nothing is pending and nothing was discarded, 1 otherwise. An offline run recorded by an SDK older than 0.4.0 names no project; --project NAME (else NEURAL_STUDIO_PROJECT) gives it one, and without either its file stays pending. The same thing from Python is ns.sync(path=None, project=None); the mechanics are on the SDK page. Until SDK 0.3.0 this command was ns sync, which still works for one more release.