CLI Reference¶
The metalab CLI provides commands for managing PostgreSQL services and transferring data between stores.
Global Options¶
| Option | Description |
|---|---|
-v, --verbose |
Enable verbose logging |
PostgreSQL Commands¶
Manage PostgreSQL services for experiment storage.
metalab postgres start¶
Start a PostgreSQL service either locally or as a SLURM job.
Usage:
Options:
| Option | Default | Description |
|---|---|---|
--store, -s |
— | Store root directory (for SLURM service discovery). Defaults to --experiments-root |
--port, -p |
5432 |
PostgreSQL port |
--database, -d |
metalab |
Database name |
--slurm |
— | Submit as SLURM job instead of running locally |
--slurm-partition |
default |
SLURM partition |
--slurm-time |
24:00:00 |
SLURM walltime |
--slurm-memory |
4G |
SLURM memory allocation |
--data-dir |
— | PostgreSQL data directory (PGDATA) |
--auth-method |
trust |
Authentication method (trust or scram-sha-256) |
--password |
— | PostgreSQL password (used with scram-sha-256) |
--experiments-root |
— | Shared experiments root (also used for SLURM service discovery if --store is omitted) |
--schema |
public |
PostgreSQL schema for PostgresStore |
--print-store-locator |
— | Print PostgresStore locator for this service |
Examples:
Start PostgreSQL locally with default settings:
Start PostgreSQL on a custom port with a specific database:
Start PostgreSQL as a SLURM job with custom resources:
metalab postgres start \
--slurm \
--store /shared/experiments \
--slurm-partition gpu \
--slurm-time 48:00:00 \
--slurm-memory 8G
Start with password authentication and print the store locator:
metalab postgres start \
--auth-method scram-sha-256 \
--password mypassword \
--experiments-root /path/to/experiments \
--print-store-locator
metalab postgres status¶
Check the status of a running PostgreSQL service.
Usage:
Options:
| Option | Default | Description |
|---|---|---|
--store, -s |
— | Store root directory (defaults to --experiments-root) |
--json |
— | Output as JSON |
--experiments-root |
— | Shared experiments root (also used for SLURM service discovery if --store is omitted) |
--schema |
public |
PostgreSQL schema for PostgresStore |
--store-locator |
— | Include PostgresStore locator in output |
Examples:
Check status of local PostgreSQL service:
Check status with JSON output:
Check status for a SLURM-managed service and include the store locator:
Sample Output:
PostgreSQL service is running:
Connection: postgresql://localhost:5432/metalab
Host: localhost
Port: 5432
Database: metalab
SLURM Job: 12345
Started: 2024-01-15T10:30:00
metalab postgres stop¶
Stop a running PostgreSQL service.
Usage:
Options:
| Option | Default | Description |
|---|---|---|
--store, -s |
— | Store root directory (defaults to --experiments-root) |
--experiments-root |
— | Shared experiments root (also used for SLURM service discovery if --store is omitted) |
Examples:
Stop local PostgreSQL service:
Stop a SLURM-managed PostgreSQL service:
Store Commands¶
Transfer data between different storage backends.
metalab store export¶
Export data from a source store to a destination store.
Usage:
Options:
| Option | Required | Description |
|---|---|---|
--from, -f |
Yes | Source store locator (e.g., postgresql://localhost/db) |
--to, -t |
Yes | Destination store locator (e.g., file:///path/to/store) |
--experiment, -e |
No | Filter by experiment ID |
--include-artifacts |
No | Include artifact files (usually skipped for performance) |
Examples:
Export all data from PostgreSQL to a file store:
metalab store export \
--from postgresql://localhost:5432/metalab \
--to file:///home/user/experiments
Export a specific experiment:
metalab store export \
--from postgresql://localhost/metalab \
--to file:///backup/experiments \
--experiment my_experiment_id
Export including artifact files:
metalab store export \
--from postgresql://localhost/metalab \
--to file:///full-backup \
--include-artifacts
Sample Output:
metalab store import¶
Import data from a source store to a destination store.
Usage:
Options:
| Option | Required | Description |
|---|---|---|
--from, -f |
Yes | Source store locator (e.g., file:///path/to/store) |
--to, -t |
Yes | Destination store locator (e.g., postgresql://localhost/db) |
--experiment, -e |
No | Filter by experiment ID |
Examples:
Import all data from a file store to PostgreSQL:
metalab store import \
--from file:///home/user/experiments \
--to postgresql://localhost:5432/metalab
Import a specific experiment:
metalab store import \
--from file:///backup/experiments \
--to postgresql://localhost/metalab \
--experiment my_experiment_id
Sample Output:
Store Locators¶
Store locators are URIs that identify storage backends:
| Type | Format | Example |
|---|---|---|
| File Store | file://<path> |
file:///home/user/experiments |
| PostgreSQL | postgresql://<host>:<port>/<database> |
postgresql://localhost:5432/metalab |
For PostgreSQL stores with additional options, query parameters can be used: