| Crates.io | nsg-cli |
| lib.rs | nsg-cli |
| version | 0.1.3 |
| created_at | 2025-10-22 22:30:52.59109+00 |
| updated_at | 2025-10-28 19:41:53.903993+00 |
| description | CLI tool for the Neuroscience Gateway (NSG) BRAIN Initiative API |
| homepage | https://www.nsgportal.org/ |
| repository | https://github.com/sdraeger/nsg-cli |
| max_upload_size | |
| id | 1896349 |
| size | 132,549 |
A command-line interface for the Neuroscience Gateway (NSG) BRAIN Initiative API.
~/.nsg/credentials.jsoncrates.iocargo install nsg-cli
cd nsg-cli
cargo build --release
The binary will be at target/release/nsg.
cargo install --path .
This installs the nsg binary to ~/.cargo/bin/.
By default, nsg-cli uses parallel processing to fetch job details concurrently, significantly improving performance when listing many jobs.
Benchmark Results (43 jobs):
# Default build with parallel support (recommended)
cargo build --release
# Build without parallel support (sequential only)
cargo build --release --no-default-features
# Explicitly enable parallel support
cargo build --release --features parallel
Sequential processing may be preferable when:
For most users, the default parallel build provides the best performance.
See BENCHMARKING.md for detailed benchmarking instructions.
First, authenticate with your NSG credentials:
nsg login
You'll be prompted for:
Your credentials are stored in ~/.nsg/credentials.json with secure permissions (0600 on Unix).
Get NSG credentials at: https://www.nsgportal.org/
View all your NSG jobs with detailed information (tool, status, dates):
nsg list
The list command automatically fetches detailed information for each job, including:
For additional job messages:
nsg list --detailed
Monitor a specific job:
nsg status <JOB_ID>
Examples:
nsg status NGBW-JOB-PY_EXPANSE-xxxxx
nsg status https://nsgr.sdsc.edu:8443/cipresrest/v1/job/username/NGBW-JOB-PY_EXPANSE-xxxxx
Submit a new job to NSG:
nsg submit <ZIP_FILE> --tool <TOOL_NAME>
Example:
nsg submit my_analysis.zip --tool PY_EXPANSE
Available tools:
PY_EXPANSE - Python on EXPANSE (default)GPU_PY_EXPANSE - GPU-accelerated PythonDownload results from a completed job:
nsg download <JOB_ID>
Specify output directory:
nsg download <JOB_ID> --output ./my_results
nsg loginAuthenticate and save credentials.
Options:
-u, --username <USERNAME> - NSG username (or prompt)-p, --password <PASSWORD> - NSG password (or prompt securely)-a, --app-key <APP_KEY> - NSG application key (or prompt)--no-verify - Skip connection testExample:
nsg login --username myuser --app-key MY_APP_KEY
nsg listList all jobs for the authenticated user with detailed information (tool, status, dates).
Note: By default, this command fetches detailed status for each job using parallel processing for optimal performance.
Options:
--detailed - Show job messages for each job--recent <N> - Show only the N most recent jobs (default: 20)--limit <N> - Limit number of jobs to display--all - Show all jobs (override default 20-job limit)Job Information Displayed:
Examples:
nsg list # Show 20 most recent jobs with details
nsg list --all # Show all jobs with details
nsg list --recent 5 # Show 5 most recent jobs
nsg list --limit 10 # Show first 10 jobs
nsg list --detailed # Show job messages for recent jobs
nsg list --all --detailed # Show all jobs with messages
nsg status <JOB>Check status of a specific job.
Arguments:
<JOB> - Job URL or Job IDExample:
nsg status NGBW-JOB-PY_EXPANSE-xxxxx
nsg submit <ZIP_FILE>Submit a new job to NSG.
Arguments:
<ZIP_FILE> - Path to ZIP file containing job dataOptions:
-t, --tool <TOOL> - NSG tool to use (default: PY_EXPANSE)--no-wait - Don't wait for job submission confirmationExample:
nsg submit job_data.zip --tool PY_EXPANSE
nsg download <JOB>Download results from a completed job with real-time progress tracking.
Arguments:
<JOB> - Job URL or Job IDOptions:
-o, --output <DIR> - Output directory (default: ./nsg_results)Features:
Example:
nsg download NGBW-JOB-PY_EXPANSE-xxxxx --output ./results
When submitting jobs, NSG expects a specific ZIP structure. For Python jobs:
job.zip
└── modeldir/
├── input.py # Main Python script (required)
├── data.edf # Input data files
├── params.json # Configuration
└── ... # Other files
The main script should be named input.py for PY_EXPANSE tool.
Credentials are stored in: ~/.nsg/credentials.json
Format:
{
"username": "your_username",
"password": "your_password",
"app_key": "your_app_key"
}
Security:
0600 (read/write for owner only)This CLI interfaces with the NSG REST API:
https://nsgr.sdsc.edu:8443/cipresrest/v1cipres-appkey headernsg-cli/
├── Cargo.toml
├── src/
│ ├── main.rs # CLI entry point
│ ├── lib.rs # Library exports
│ ├── client.rs # NSG API client
│ ├── config.rs # Credential management
│ ├── models.rs # Data structures & XML parsing
│ └── commands/ # CLI commands
│ ├── mod.rs
│ ├── login.rs
│ ├── list.rs
│ ├── status.rs
│ ├── submit.rs
│ └── download.rs
└── README.md
cargo build # Debug build
cargo build --release # Release build with parallel support (optimized)
cargo build --release --no-default-features # Sequential build
cargo test # Run tests
cargo check # Type checking only (fast)
cargo bench # Run benchmarks
Compare parallel vs sequential performance:
# Benchmark with parallel support (default)
cargo bench --features parallel
# Benchmark without parallel support
cargo bench --no-default-features
# View benchmark reports
open target/criterion/report/index.html
For detailed benchmarking instructions, see BENCHMARKING.md.
If login fails:
--no-verify to skip connection test and save credentials anywayIf status or download can't find a job:
nsg list to see all your jobsIf results download fails:
nsg statusMIT License
This tool was created as part of the DDALAB project. For issues or contributions, please use the DDALAB repository.
For NSG-related issues: nsghelp@sdsc.edu For DDALAB issues: https://github.com/sdraeger/DDALAB/issues