Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace SSSP link to legacy MC Archive #110

Merged
merged 4 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions aiida_pseudo/cli/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
5 changes: 3 additions & 2 deletions setup.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@
"extras_require": {
"pre-commit": [
"pre-commit~=2.2",
"pylint~=2.6"
"pylint~=2.6.0"
],
"tests": [
"pgtest~=1.3",
"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",
Expand Down
6 changes: 4 additions & 2 deletions tests/cli/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down