diff --git a/aiida_pseudo/cli/install.py b/aiida_pseudo/cli/install.py index 6a44421..d6c3735 100644 --- a/aiida_pseudo/cli/install.py +++ b/aiida_pseudo/cli/install.py @@ -167,9 +167,10 @@ def download_pseudo_dojo( @options.FUNCTIONAL(type=click.Choice(['PBE', 'PBEsol']), default='PBE', show_default=True) @options.PROTOCOL(type=click.Choice(['efficiency', 'precision']), default='efficiency', show_default=True) @options.DOWNLOAD_ONLY() +@options.FROM_DIR() @options.TRACEBACK() @decorators.with_dbenv() -def cmd_install_sssp(version, functional, protocol, download_only, traceback): +def cmd_install_sssp(version, functional, protocol, download_only, from_dir, traceback): """Install an SSSP configuration. The SSSP configuration will be automatically downloaded from the Materials Cloud Archive entry to create a new @@ -183,6 +184,11 @@ def cmd_install_sssp(version, functional, protocol, download_only, traceback): from aiida_pseudo.groups.family import SsspFamily from .utils import attempt, create_family_from_archive + if download_only and from_dir is not None: + raise click.BadParameter( + 'cannot specify both `--download-only` and `--from-dir`.', param_hint="'--download-only' / '--from-dir'" + ) + configuration = SsspConfiguration(version, functional, protocol) label = SsspFamily.format_configuration_label(configuration) description = f'SSSP v{version} {functional} {protocol} installed with aiida-pseudo v{__version__}' @@ -195,11 +201,16 @@ def cmd_install_sssp(version, functional, protocol, download_only, traceback): with tempfile.TemporaryDirectory() as dirpath: - dirpath = pathlib.Path(dirpath) + if from_dir is not None: + dirpath = pathlib.Path(from_dir) + else: + dirpath = pathlib.Path(dirpath) + filepath_archive = dirpath / 'archive.tar.gz' filepath_metadata = dirpath / 'metadata.json' - download_sssp(configuration, filepath_archive, filepath_metadata, traceback) + if from_dir is None: + download_sssp(configuration, filepath_archive, filepath_metadata, traceback) description += f'\nArchive pseudos md5: {md5_file(filepath_archive)}' description += f'\nPseudo metadata md5: {md5_file(filepath_metadata)}' @@ -246,10 +257,11 @@ def cmd_install_sssp(version, functional, protocol, download_only, traceback): @options.PSEUDO_FORMAT(type=click.Choice(['psp8', 'upf', 'psml', 'jthxml']), default='psp8', show_default=True) @options.DEFAULT_STRINGENCY(type=click.Choice(['low', 'normal', 'high']), default='normal', show_default=True) @options.DOWNLOAD_ONLY() +@options.FROM_DIR() @options.TRACEBACK() @decorators.with_dbenv() def cmd_install_pseudo_dojo( - version, functional, relativistic, protocol, pseudo_format, default_stringency, download_only, traceback + version, functional, relativistic, protocol, pseudo_format, default_stringency, download_only, from_dir, traceback ): """Install a PseudoDojo configuration. @@ -281,6 +293,11 @@ def cmd_install_pseudo_dojo( ) # yapf: enable + if download_only and from_dir is not None: + raise click.BadParameter( + 'cannot specify both `--download-only` and `--from-dir`.', param_hint="'--download-only' / '--from-dir'" + ) + try: pseudo_type = pseudo_type_mapping[pseudo_format] except KeyError: @@ -298,11 +315,16 @@ def cmd_install_pseudo_dojo( with tempfile.TemporaryDirectory() as dirpath: - dirpath = pathlib.Path(dirpath) + if from_dir is not None: + dirpath = pathlib.Path(from_dir) + else: + dirpath = pathlib.Path(dirpath) + filepath_archive = dirpath / 'archive.tgz' filepath_metadata = dirpath / 'metadata.tgz' - download_pseudo_dojo(configuration, filepath_archive, filepath_metadata, traceback) + if from_dir is None: + download_pseudo_dojo(configuration, filepath_archive, filepath_metadata, traceback) description += f'\nArchive pseudos md5: {md5_file(filepath_archive)}' description += f'\nPseudo metadata md5: {md5_file(filepath_metadata)}' diff --git a/aiida_pseudo/cli/params/options.py b/aiida_pseudo/cli/params/options.py index a7285bc..26372fe 100644 --- a/aiida_pseudo/cli/params/options.py +++ b/aiida_pseudo/cli/params/options.py @@ -103,3 +103,12 @@ 'pseudopotential family.' ) ) + +FROM_DIR = OverridableOption( + '--from-dir', + type=click.STRING, + required=False, + default=None, + show_default=False, + help='Install the pseudpotential family from the archive and metadata downloaded with the `--download-only` option.' +) diff --git a/docs/source/_static/aiida-pseudo-custom.css b/docs/source/_static/aiida-pseudo-custom.css new file mode 100644 index 0000000..e784faa --- /dev/null +++ b/docs/source/_static/aiida-pseudo-custom.css @@ -0,0 +1,3 @@ +.bigfont { + font-size: 140%; +} diff --git a/docs/source/conf.py b/docs/source/conf.py index 0e38128..562d9b4 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -62,16 +62,21 @@ # html_theme = 'sphinx_book_theme' html_static_path = ['_static'] -html_css_files = ['aiida-custom.css'] +html_css_files = [ + 'aiida-custom.css', + 'aiida-pseudo-custom.css' +] html_theme_options = { 'home_page_in_toc': True, 'repository_url': 'https://github.com/aiidateam/aiida-pseudo', 'repository_branch': 'master', 'use_repository_button': True, 'use_issues_button': True, + 'use_fullscreen_button': False, 'path_to_docs': 'docs', 'use_edit_page_button': True, - 'extra_navbar': '' + 'extra_navbar': '', + 'extra_navbar': '
Made possible by the support of NCCR MARVEL, MaX CoE and the swissuniversities P-5 project.
' } html_domain_indices = True html_logo = '_static/logo.png' diff --git a/docs/source/howto.rst b/docs/source/howto.rst index fa16e7d..ba7b0fb 100644 --- a/docs/source/howto.rst +++ b/docs/source/howto.rst @@ -28,12 +28,16 @@ Similar to the `SSSP`_ pseudopotential family, the options can be used to set ve Moreover, the format of the pseudopotentials can be specified, as well as the default stringency. Use ``aiida-pseudo install pseudo-dojo --help`` for more information. +.. note:: + + In case you are unable to use this command because of connection issues, please consult the :ref:`troubleshooting section