Skip to content

Commit

Permalink
update auxiliary download condition
Browse files Browse the repository at this point in the history
  • Loading branch information
aperrin66 committed Jan 20, 2025
1 parent c5e5484 commit 01495cd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions geospaas_processing/converters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@ def make_symlink(source, destination):
os.symlink(source, destination)

@classmethod
def download_auxiliary_files(cls):
def download_auxiliary_files(cls, force_download=False):
"""Download the auxiliary files necessary for IDF conversion.
They are too big to be included in the package.
"""
url = cls.auxiliary_url.format(cls.auxiliary_version)
auxiliary_archive_path = cls.auxiliary_path / 'auxiliary.tar.gz'
if not (cls.downloaded_aux or cls.auxiliary_path.is_dir()):
if (force_download or
not (cls.downloaded_aux or
(cls.auxiliary_path.is_dir() and list(cls.auxiliary_path.iterdir())))):
logger.info(
"Downloading auxiliary files for conversions, this may take a while. "
"Download path: %s", str(cls.auxiliary_path))
Expand Down
3 changes: 2 additions & 1 deletion tests/converters/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,12 @@ def test_convert(self):
class AuxiliaryDownloadTestCase(unittest.TestCase):
"""Test the download of auxiliary files"""

def test_do_not_download_auxiliary_files_if_folder_present(self):
def test_do_not_download_auxiliary_files_if_folder_not_empty(self):
"""Test that auxiliary files are not downloaded if the folder
is present
"""
with mock.patch('pathlib.Path.is_dir', return_value=True), \
mock.patch('pathlib.Path.iterdir', return_value=iter(['baz'])), \
mock.patch('geospaas_processing.utils.http_request') as mock_http_request, \
mock.patch.object(TestConversionManager, 'make_symlink') as mock_make_symlink:
TestConversionManager.download_auxiliary_files()
Expand Down

0 comments on commit 01495cd

Please sign in to comment.