@@ -126,6 +126,13 @@ def detect_postgres_config(
126126 'the PostgreSQL server can be configured with the relevant options. The command attempts to automatically create a '
127127 'user and database to use for the profile, but this can fail depending on the configuration of the server.' ,
128128)
129+ @click .option (
130+ '--use-zmq' ,
131+ is_flag = True ,
132+ help = 'When toggled on, the profile uses the ZMQ broker, which requires no external services and is started '
133+ 'automatically with the daemon. When not specified, the command automatically tries RabbitMQ first and falls back '
134+ 'to ZMQ if unavailable. To switch to RabbitMQ later, use `verdi profile configure-rabbitmq`.' ,
135+ )
129136@click .option ('--postgres-hostname' , type = str , default = 'localhost' , help = 'The hostname of the PostgreSQL server.' )
130137@click .option ('--postgres-port' , type = int , default = 5432 , help = 'The port of the PostgreSQL server.' )
131138@click .option (
@@ -147,6 +154,7 @@ def verdi_presto(
147154 profile_name ,
148155 email ,
149156 use_postgres ,
157+ use_zmq ,
150158 postgres_hostname ,
151159 postgres_port ,
152160 postgres_username ,
@@ -169,18 +177,21 @@ def verdi_presto(
169177 * Set up the localhost as a `Computer` and configure it
170178 * Set a number of configuration options with sensible defaults
171179
172- By default the command creates a profile that uses SQLite for the database. It automatically checks for RabbitMQ
173- running on the localhost, and, if it can connect, configures that as the broker for the profile. Otherwise, the
174- profile is created without a broker, in which case some functionality will be unavailable, most notably running the
175- daemon and submitting processes to said daemon.
180+ By default the command creates a profile that uses SQLite for the database. For the message broker, it automatically
181+ checks for RabbitMQ running on localhost. If found, it configures RabbitMQ as the broker. Otherwise, it falls back
182+ to the ZMQ broker, which requires no external services and is started automatically with the daemon.
176183
177184 When the `--use-postgres` flag is toggled, the command tries to connect to the PostgreSQL server with connection
178185 paramaters taken from the `--postgres-hostname`, `--postgres-port`, `--postgres-username` and `--postgres-password`
179186 options. It uses these credentials to try and automatically create a user and database. If successful, the newly
180187 created profile uses the new PostgreSQL database instead of SQLite.
188+
189+ When the `--use-zmq` flag is toggled, the command skips the RabbitMQ auto-detection and directly configures the ZMQ
190+ broker. To switch to RabbitMQ later, use `verdi profile configure-rabbitmq`.
181191 """
182192 from aiida .brokers .rabbitmq .defaults import detect_rabbitmq_config
183- from aiida .common import docs , exceptions
193+ from aiida .brokers .zmq .defaults import get_zmq_config
194+ from aiida .common import exceptions
184195 from aiida .manage .configuration import create_profile , load_profile
185196 from aiida .orm import Computer
186197
@@ -212,17 +223,20 @@ def verdi_presto(
212223 else :
213224 echo .echo_report ('Option `--use-postgres` not enabled: configuring the profile to use SQLite.' )
214225
215- broker_backend = None
216- broker_config = None
217-
218- try :
219- broker_config = detect_rabbitmq_config ()
220- except ConnectionError as exception :
221- echo .echo_report (f'RabbitMQ server not found ({ exception } ): configuring the profile without a broker.' )
222- echo .echo_report (f'See { docs .URL_NO_BROKER } for details on the limitations of running without a broker.' )
226+ if use_zmq :
227+ echo .echo_report ('`--use-zmq` enabled: configuring the profile with ZMQ broker.' )
228+ broker_backend = 'core.zmq'
229+ broker_config = get_zmq_config ()
223230 else :
224- echo .echo_report ('RabbitMQ server detected: configuring the profile with a broker.' )
225- broker_backend = 'core.rabbitmq'
231+ try :
232+ broker_config = detect_rabbitmq_config ()
233+ except ConnectionError :
234+ echo .echo_report ('RabbitMQ server not found: falling back to ZMQ broker.' )
235+ broker_backend = 'core.zmq'
236+ broker_config = get_zmq_config ()
237+ else :
238+ echo .echo_report ('RabbitMQ server detected: configuring the profile with RabbitMQ broker.' )
239+ broker_backend = 'core.rabbitmq'
226240
227241 try :
228242 profile = create_profile (
0 commit comments