From 1dcd39e51cca543d8f2b097124e456c5d9229847 Mon Sep 17 00:00:00 2001 From: Sebastiaan Huber Date: Wed, 8 Dec 2021 15:34:10 +0100 Subject: [PATCH 1/4] Dependencies: fix `pylint` to minor version This will prevent the CI failing when locally things pass because on the remote a newer version of `pylint` installs which may come with new rules. --- setup.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.json b/setup.json index 304d50f..aff5e1b 100644 --- a/setup.json +++ b/setup.json @@ -46,7 +46,7 @@ "extras_require": { "pre-commit": [ "pre-commit~=2.2", - "pylint~=2.6" + "pylint~=2.6.0" ], "tests": [ "pgtest~=1.3", From e56b0c91ffe12c1f3249afac168932e9b4e73713 Mon Sep 17 00:00:00 2001 From: Sebastiaan Huber Date: Wed, 8 Dec 2021 15:35:10 +0100 Subject: [PATCH 2/4] CLI: fix bug in `install family` when downloading from URL When the command was passed an URL it writes the retrieved content to a temporary file on the local file system. Since the underlying unarchiving code attempts to determine the format from the filename, it was attempting to name the temporary file based on the the URL. This worked for the old URL, since there (as luck would have it) the URL ended with the filename containing the correct archive format extension. However, this is clearly not always the case and it is in general impossible to deduce the filename from the URL. It might not even contain an actual filename. There is no other solution then have the user specify the archive format with the `-f` option. It is not made required because for the local files it might not be necessary. --- aiida_pseudo/cli/install.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/aiida_pseudo/cli/install.py b/aiida_pseudo/cli/install.py index 199a0c2..f1179d2 100644 --- a/aiida_pseudo/cli/install.py +++ b/aiida_pseudo/cli/install.py @@ -72,15 +72,10 @@ def cmd_install_family(archive, label, description, archive_format, family_type, else: # At this point, we can assume that it is not a valid filepath on disk, but rather a URL and the ``archive`` # variable will contain the result objects from the ``requests`` library. The validation of the URL will already - # have been done by the ``PathOrUrl`` parameter type, so the URL is reachable. The content of the URL must be - # copied to a local temporary file because `create_family_from_archive` does currently not accept filelike - # objects, because in turn the underlying `shutil.unpack_archive` does not. In addition, `unpack_archive` will - # attempt to deduce the archive format from the filename extension, so it is important we maintain the original - # filename. Of course if this fails, users can specify the archive format explicitly with the corresponding - # option. We get the filename by converting the URL to a ``Path`` object and taking the filename, using that as - # a suffix for the temporary file that is generated on disk to copy the content to. - suffix = pathlib.Path(archive.url).name - with tempfile.NamedTemporaryFile(mode='w+b', suffix=suffix) as handle: + # have been done by the ``PathOrUrl`` parameter type and will already have retrieved the content. The content of + # the URL must be copied to a local temporary file because `create_family_from_archive` does currently not + # accept filelike objects, because in turn the underlying `shutil.unpack_archive` does not. + with tempfile.NamedTemporaryFile(mode='w+b') as handle: handle.write(archive.content) handle.flush() From 2428165cf91f55aa893fea9271582b8a9991eb1f Mon Sep 17 00:00:00 2001 From: Sebastiaan Huber Date: Wed, 8 Dec 2021 17:23:21 +0100 Subject: [PATCH 3/4] Dependencies: update `sphinx` and add `docutils` The `docutils` requirement is necessary to quell the warning message that was being raised causing the docs build to fail. --- setup.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.json b/setup.json index aff5e1b..4f1c015 100644 --- a/setup.json +++ b/setup.json @@ -53,7 +53,8 @@ "pytest~=5.4" ], "docs": [ - "sphinx~=3.2.1", + "docutils~=0.17.0", + "sphinx~=3.2", "sphinx-copybutton~=0.3.0", "sphinx-book-theme~=0.0.39", "sphinx-autoapi~=1.8.1", From f09873920d24138549c0c81d140b926621f7f333 Mon Sep 17 00:00:00 2001 From: Sebastiaan Huber Date: Wed, 8 Dec 2021 15:37:47 +0100 Subject: [PATCH 4/4] Replace SSSP link to legacy MC Archive The `cli.test_install:test_install_family_url` test was using a link to the legacy version of the Materials Cloud Archive which has now been taken offline, causing the test to fail. The link is updated to point to the new server. --- tests/cli/test_install.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/cli/test_install.py b/tests/cli/test_install.py index b3e9630..600bbbb 100644 --- a/tests/cli/test_install.py +++ b/tests/cli/test_install.py @@ -157,8 +157,10 @@ def test_install_family_url(run_cli_command): """ label = 'SSSP/1.0/PBE/efficiency' description = 'description' - filepath_archive = 'https://legacy-archive.materialscloud.org/file/2018.0001/v4/SSSP_1.0_PBE_efficiency.tar.gz' - options = ['-D', description, filepath_archive, label, '-P', 'pseudo.upf'] + configuration = SsspConfiguration('1.0', 'PBE', 'efficiency') + filename = SsspFamily.format_configuration_filename(configuration, 'tar.gz', '1.0') + filepath_archive = f'https://archive.materialscloud.org/record/file?filename={filename}&record_id=23' + options = ['-D', description, '-P', 'pseudo.upf', '-f', 'gztar', filepath_archive, label] result = run_cli_command(cmd_install_family, options) assert f'installed `{label}`' in result.output