@@ -285,6 +285,7 @@ def set_template_vars_in_context(ctx, param, value):
285285 return value
286286
287287
288+
288289# Modified computer setup command
289290@verdi_computer .command ('setup' )
290291@options_computer .LABEL ()
@@ -300,17 +301,19 @@ def set_template_vars_in_context(ctx, param, value):
300301@options_computer .USE_DOUBLE_QUOTES ()
301302@options_computer .PREPEND_TEXT ()
302303@options_computer .APPEND_TEXT ()
303- # @options.NON_INTERACTIVE()
304- # @options.CONFIG_FILE() # Keep the original config option for backward compatibility
305- @options .TEMPLATE_FILE () # Add our new template option
304+ @options .NON_INTERACTIVE () # Uncomment this line
305+ @options .TEMPLATE_FILE ()
306306@options .TEMPLATE_VARS ()
307307@click .pass_context
308308@with_dbenv ()
309309def computer_setup (ctx , non_interactive , template , template_vars , ** kwargs ):
310310 """Create a new computer."""
311311 from aiida .orm .utils .builders .computer import ComputerBuilder
312312
313- print ('HELLO' )
313+ # Debug output
314+ print (f"Debug: non_interactive = { non_interactive } " )
315+ print (f"Debug: kwargs keys = { list (kwargs .keys ())} " )
316+ print (f"Debug: ctx.default_map = { ctx .default_map } " )
314317
315318 # Handle template variables
316319 template_var_dict = None
@@ -369,6 +372,90 @@ def computer_setup(ctx, non_interactive, template, template_vars, **kwargs):
369372 profile = ctx .obj ['profile' ]
370373 echo .echo_report (f' verdi -p { profile .name } computer configure { computer .transport_type } { computer .label } ' )
371374
375+ # Modified computer setup command
376+ # @verdi_computer.command('setup')
377+ # @options_computer.LABEL()
378+ # @options_computer.HOSTNAME()
379+ # @options_computer.DESCRIPTION()
380+ # @options_computer.TRANSPORT()
381+ # @options_computer.SCHEDULER()
382+ # @options_computer.SHEBANG()
383+ # @options_computer.WORKDIR()
384+ # @options_computer.MPI_RUN_COMMAND()
385+ # @options_computer.MPI_PROCS_PER_MACHINE()
386+ # @options_computer.DEFAULT_MEMORY_PER_MACHINE()
387+ # @options_computer.USE_DOUBLE_QUOTES()
388+ # @options_computer.PREPEND_TEXT()
389+ # @options_computer.APPEND_TEXT()
390+ # # @options.NON_INTERACTIVE()
391+ # # @options.CONFIG_FILE() # Keep the original config option for backward compatibility
392+ # @options.TEMPLATE_FILE() # Add our new template option
393+ # @options.TEMPLATE_VARS()
394+ # @click.pass_context
395+ # @with_dbenv()
396+ # def computer_setup(ctx, non_interactive, template, template_vars, **kwargs):
397+ # """Create a new computer."""
398+ # from aiida.orm.utils.builders.computer import ComputerBuilder
399+
400+ # print('HELLO')
401+
402+ # # Handle template variables
403+ # template_var_dict = None
404+ # if template_vars:
405+ # try:
406+ # template_var_dict = json.loads(template_vars)
407+ # except json.JSONDecodeError as e:
408+ # echo.echo_critical(f'Invalid JSON in template-vars: {e}')
409+
410+ # # Process template if provided
411+ # if template:
412+ # try:
413+ # # Load and process the template
414+ # config_data = load_and_process_template(
415+ # template, interactive=not non_interactive, template_vars=template_var_dict
416+ # )
417+
418+ # # Update kwargs with config file data
419+ # # Only update if the value wasn't explicitly provided on command line
420+ # for key, value in config_data.items():
421+ # if key not in kwargs or kwargs[key] is None:
422+ # kwargs[key] = value
423+
424+ # except Exception as e:
425+ # echo.echo_critical(f'Error processing template: {e}')
426+
427+ # # Check for existing computer
428+ # if kwargs.get('label') and kwargs['label'] in get_computer_names():
429+ # echo.echo_critical(
430+ # 'A computer called {c} already exists. '
431+ # 'Use "verdi computer duplicate {c}" to set up a new '
432+ # 'computer starting from the settings of {c}.'.format(c=kwargs['label'])
433+ # )
434+
435+ # # Convert entry points to their names
436+ # if kwargs.get('transport'):
437+ # kwargs['transport'] = kwargs['transport'].name
438+ # if kwargs.get('scheduler'):
439+ # kwargs['scheduler'] = kwargs['scheduler'].name
440+
441+ # computer_builder = ComputerBuilder(**kwargs)
442+ # try:
443+ # computer = computer_builder.new()
444+ # except (ComputerBuilder.ComputerValidationError, ValidationError) as e:
445+ # echo.echo_critical(f'{type(e).__name__}: {e}')
446+
447+ # try:
448+ # computer.store()
449+ # except ValidationError as err:
450+ # echo.echo_critical(f'unable to store the computer: {err}. Exiting...')
451+ # else:
452+ # echo.echo_success(f'Computer<{computer.pk}> {computer.label} created')
453+
454+ # echo.echo_report('Note: before the computer can be used, it has to be configured with the command:')
455+
456+ # profile = ctx.obj['profile']
457+ # echo.echo_report(f' verdi -p {profile.name} computer configure {computer.transport_type} {computer.label}')
458+
372459
373460@verdi_computer .command ('duplicate' )
374461@arguments .COMPUTER (callback = set_computer_builder )
0 commit comments