|
26 | 26 | from aiida.plugins.entry_point import get_entry_point_names |
27 | 27 |
|
28 | 28 | from .registry_helpers import ( |
29 | | - apply_computer_config, |
| 29 | + get_computers_table, |
| 30 | + handle_computer_configuration, |
30 | 31 | fetch_resource_registry_data, |
31 | 32 | fetch_code_registry_data, |
32 | | - get_computer_configure_config, |
33 | | - get_computer_setup_config, |
| 33 | + interactive_config_handling, |
34 | 34 | interactive_computer_selector, |
35 | | - interactive_system_selector, |
36 | | - save_config_to_file, |
37 | | - search_computers_in_aiida, |
38 | | - _get_computers_table, |
39 | | - _handle_computer_configuration, |
40 | | - _process_template_variables, |
41 | | - _replace_template_var, |
42 | 35 | ) |
43 | 36 |
|
44 | 37 |
|
@@ -854,83 +847,74 @@ def computer_export_config(computer, output_file, user, overwrite, sort): |
854 | 847 |
|
855 | 848 |
|
856 | 849 | @verdi_computer.command('search') |
857 | | -@click.argument('pattern', required=False) |
858 | | -@click.option('--save-only', is_flag=True, help='Only save configuration to files, do not apply to AiiDA') |
| 850 | +@click.argument('pattern', type=str, required=False) |
| 851 | +@click.option( |
| 852 | + '--source', |
| 853 | + type=click.Choice(['code-registry', 'resource-registry', 'both']), |
| 854 | + default='both', |
| 855 | + help='Specify the registry source (default: both)', |
| 856 | +) |
859 | 857 | @with_dbenv() |
860 | | -def computer_search(pattern, save_only): |
861 | | - """Search for computers in the AiiDA code registry and setup/configure them. |
| 858 | +def computer_search(pattern, source): |
| 859 | + """Search for computers in the AiiDA registries and setup them up in your profile. |
862 | 860 |
|
863 | 861 | If PATTERN is provided, search for computers matching that pattern. |
864 | | - If no pattern is provided, show all available computers in the registry. |
| 862 | + If no pattern is provided, show all available computers. |
865 | 863 |
|
866 | 864 | This command allows you to discover and setup computers from the community |
867 | | - AiiDA code registry at https://aiidateam.github.io/aiida-code-registry/ |
| 865 | + AiiDA code registry at https://github.com/aiidateam/aiida-code-registry/ |
| 866 | + and the AiiDA resource registry athttps://github.com/aiidateam/aiida-resource-registry/ |
868 | 867 | """ |
869 | 868 | from aiida.cmdline.utils.common import tabulate |
870 | 869 |
|
871 | | - try: |
872 | | - echo.echo_info('Fetching AiiDA code registry...') |
873 | | - # NOTE: There is quite some overlap between code registry and resource registry |
874 | | - # code registry: 'daint.cscs.ch', 'imxgesrv1.epfl.ch', 'lsmosrv6', 'fidis.epfl.ch', 'tigu.empa.ch', 'paratera', |
875 | | - # 'merlin.psi.ch', 'eiger.cscs.ch' |
876 | | - # resource registry: 'eiger.cscs.ch', 'daint.cscs.ch', 'merlin.psi.ch', 'merlin7.psi.ch' |
| 870 | + echo.echo_report('Fetching AiiDA registries...') |
| 871 | + # NOTE: There is quite some overlap between code registry and resource registry |
| 872 | + # code registry: 'daint.cscs.ch', 'imxgesrv1.epfl.ch', 'lsmosrv6', 'fidis.epfl.ch', 'tigu.empa.ch', 'paratera', |
| 873 | + # 'merlin.psi.ch', 'eiger.cscs.ch' |
| 874 | + # resource registry: 'eiger.cscs.ch', 'daint.cscs.ch', 'merlin.psi.ch', 'merlin7.psi.ch' |
| 875 | + if source == 'both': |
877 | 876 | registry_data = fetch_code_registry_data() | fetch_resource_registry_data() |
878 | | - echo.echo_success(f'Successfully fetched AiiDA registry data. Found {len(registry_data)} computers.') |
879 | | - |
880 | | - if pattern: |
881 | | - matching_systems = [system for system in registry_data.keys() if pattern in system] |
882 | | - table = _get_computers_table({match: registry_data[match] for match in matching_systems}) |
883 | | - if not matching_systems: |
884 | | - echo.echo_warning(f"No computers found matching pattern '{pattern}'") |
885 | | - if click.confirm('\nWould you like to show all available systems in the registry?'): |
886 | | - table = _get_computers_table(registry_data) |
887 | | - else: |
888 | | - registry_data = {match: registry_data[match] for match in matching_systems} |
889 | | - echo.echo_report(f"Systems in the registry matching the pattern '{pattern}'") |
890 | | - table = _get_computers_table(registry_data) |
891 | | - |
| 877 | + elif source == 'resource-registry': |
| 878 | + registry_data = fetch_resource_registry_data() |
| 879 | + elif source == 'code-registry': |
| 880 | + registry_data = fetch_code_registry_data() |
| 881 | + |
| 882 | + echo.echo_success(f'Successfully fetched AiiDA registry data. Found {len(registry_data)} computers.') |
| 883 | + |
| 884 | + if pattern: |
| 885 | + matching_systems = [system for system in registry_data.keys() if pattern in system] |
| 886 | + if not matching_systems: |
| 887 | + echo.echo_warning(f"No computers found matching pattern '{pattern}'") |
| 888 | + if click.confirm('\nWould you like to show all available systems in the registry?'): |
| 889 | + table = get_computers_table(registry_data) |
892 | 890 | else: |
893 | | - echo.echo_report('All available systems in the registries:') |
894 | | - table = _get_computers_table(registry_data) |
| 891 | + registry_data = {match: registry_data[match] for match in matching_systems} |
| 892 | + echo.echo_report(f"Systems in the registry matching the pattern '{pattern}'") |
| 893 | + table = get_computers_table(registry_data) |
895 | 894 |
|
896 | | - echo.echo( |
897 | | - tabulate(table, headers=['System', 'Variants', 'Hostname', 'Codes (default variant)'], tablefmt='grid') |
898 | | - ) |
| 895 | + else: |
| 896 | + echo.echo_report('All available systems in the registries:') |
| 897 | + table = get_computers_table(registry_data) |
899 | 898 |
|
900 | | - # Offer to setup a computer |
901 | | - if click.confirm('\nWould you like to setup a computer from the registry?'): |
902 | | - |
903 | | - if len(table) == 1: |
904 | | - import ipdb; ipdb.set_trace() |
905 | | - # Only one match, use it directly |
906 | | - computer_name = matching_systems[0] |
907 | | - # NOTE: Add here interactive variant selection |
908 | | - # computer_data = registry_data[computer_name] |
909 | | - # variant = computer_name['variant'] |
910 | | - # echo.echo_info(f'Setting up {computer_name} / {variant}') |
911 | | - # _handle_computer_configuration(registry_data, computer_name, variant, save_only) |
912 | | - else: |
913 | | - # Multiple matches, let user choose |
914 | | - selection = interactive_system_selector(registry_data) |
915 | | - if not selection: |
916 | | - return |
917 | | - system_name, variant = selection |
918 | | - _handle_computer_configuration(registry_data, system_name, variant, save_only) |
919 | | - |
920 | | - # if click.confirm("Would you like to browse all available registry computers?"): |
921 | | - # # Show all systems in table format |
922 | | - # all_systems = find_matching_registry_systems(registry_data, "") |
923 | | - # if all_systems: |
924 | | - # echo.echo_info(f"\n🌐 All available computers in AiiDA registry ({len(all_systems)} total):") |
925 | | - # _print_computers_table(all_systems) |
926 | | - |
927 | | - # if click.confirm("\nWould you like to setup a computer?"): |
928 | | - # selection = interactive_system_selector(registry_data) |
929 | | - # if selection: |
930 | | - # system_name, variant = selection |
931 | | - # _handle_computer_configuration(registry_data, system_name, variant, save_only) |
932 | | - # else: |
933 | | - # echo.echo_warning("No computers found in registry") |
| 899 | + echo.echo(tabulate(table, headers=['System', 'Variants', 'Hostname', 'Codes (default variant)'], tablefmt='grid')) |
934 | 900 |
|
935 | | - except Exception as e: |
936 | | - echo.echo_error(f'Failed to search registry: {e}') |
| 901 | + # Offer to setup a computer |
| 902 | + if not click.confirm('\nWould you like to setup a computer from the registry?'): |
| 903 | + return |
| 904 | + |
| 905 | + if len(table) == 1: |
| 906 | + import ipdb |
| 907 | + |
| 908 | + ipdb.set_trace() |
| 909 | + # Only one match, use it directly |
| 910 | + # NOTE: Use here only interactive variant selection |
| 911 | + selection = interactive_computer_selector(registry_data) |
| 912 | + if not selection: |
| 913 | + return |
| 914 | + else: |
| 915 | + # Multiple matches, let user choose |
| 916 | + selection = interactive_computer_selector(registry_data) |
| 917 | + if not selection: |
| 918 | + return |
| 919 | + system_name, variant = selection |
| 920 | + handle_computer_configuration(registry_data, system_name, variant) |
0 commit comments