neurolang.utils.cli#

Command-line interface for NeuroLang query execution.

Provides a neurolang-query command that initializes a NeuroLang engine from the engine registry and executes Datalog queries from arguments, files, or standard input.

Usage#

# List available engines
neurolang-query --list-engines

# Print the SQUALL grammar and parser metadata as JSON
neurolang-query --grammar-json

# List predicates for an engine
neurolang-query --engine neurosynth --list-predicates

# List RA sets for an engine
neurolang-query --engine neurosynth --list-sets

# Inline query
neurolang-query "ans(t) :- term_in_study_tfidf(s, t, w)"

# Query from file
neurolang-query -f query.dl

# Query from stdin
echo "ans(t) :- term_in_study_tfidf(s, t, w)" | neurolang-query

# Destrieux atlas engine
neurolang-query --engine destrieux "ans(name) :- destrieux(name, region)"

# Squall (controlled English) query
neurolang-query --squall "obtain every peak_reported."
neurolang-query --squall -f query.squall

# Show the Datalog IR for a SQUALL query (no execution)
neurolang-query --squall --show-datalog "obtain every Voxel in 3D that a Study reported."

# Show the relational algebra plans of a query (no execution)
neurolang-query --show-ra "ans(x) :- P(x)"

# ... annotated with the number of rows each plan node produces
neurolang-query --show-ra --ra-analyze "ans(x) :- P(x)"

# Interactive REPL (needs ``pip install "neurolang[tui]"``)
neurolang-query -i --engine neurosynth

# ... or run REPL statements and dot-commands from a pipe
echo 'ans(x) :- study(x)' | neurolang-query -i

# Write a query with an LLM (needs ``pip install "neurolang[llm]"``)
neurolang-query --squall --ask "Which studies mention pain?" --run

Functions

main([argv])

CLI entry point: parse arguments, build engine, run query.

report_error(exc, program, *, squall, debug)

Print the query error exc as a formatted message.

result_to_dataframe(result[, column_names])

Return the rows of a query result as a DataFrame.

sort_dataframe(df, sort_by)

Return df sorted by the (column, ascending) pairs of sort_by.

squall_column_names(engine_name, program[, ...])

Return column names for the results of a SQUALL program's queries.

warning_note(message, known_symbols)

Return a one-line note for a warning message raised by a query.