Skip to content

Commit 7ef64f1

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 862eaa9 commit 7ef64f1

3 files changed

Lines changed: 15 additions & 29 deletions

File tree

hoss/adapter.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@
3535
from pystac import Asset, Item
3636

3737
from hoss.dimension_utilities import is_index_subset
38+
from hoss.exceptions import StagingFailed
3839
from hoss.harmony_log_context import set_logger
3940
from hoss.subset import subset_granule
4041
from hoss.utilities import (
4142
get_file_mimetype,
4243
raise_from_hoss_exception,
4344
unexecuted_url_requested,
4445
)
45-
from hoss.exceptions import StagingFailed
4646

4747

4848
class HossAdapter(BaseHarmonyAdapter):
@@ -189,11 +189,7 @@ def validate_message(self):
189189
if not hasattr(source, 'variables') or not source.variables:
190190
self.logger.info('All variables will be retrieved.')
191191

192-
def hoss_stage(
193-
self,
194-
url: str,
195-
asset_name: str,
196-
output_mimetype: str) -> str:
192+
def hoss_stage(self, url: str, asset_name: str, output_mimetype: str) -> str:
197193
"""Stages the file to and S3 location and returns the url.
198194
Throws a retriable exception when there is a failure.
199195
@@ -204,12 +200,10 @@ def hoss_stage(
204200
asset_name,
205201
output_mimetype,
206202
location=self.message.stagingLocation,
207-
logger=self.logger
203+
logger=self.logger,
208204
)
209205

210206
return output_url
211207

212208
except Exception as exception:
213-
raise StagingFailed(
214-
'Staging failed, ' + str(exception)
215-
) from exception
209+
raise StagingFailed('Staging failed, ' + str(exception)) from exception

tests/unit/test_adapter.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -563,12 +563,8 @@ def test_missing_variables(
563563
logger=hoss.logger,
564564
)
565565

566-
def test_hoss_stage(
567-
self, mock_stage, mock_subset_granule, mock_get_mimetype
568-
):
569-
"""Ensure hoss_stage successfully calls hoss_stage and returns the URL
570-
571-
"""
566+
def test_hoss_stage(self, mock_stage, mock_subset_granule, mock_get_mimetype):
567+
"""Ensure hoss_stage successfully calls hoss_stage and returns the URL"""
572568
mock_subset_granule.return_value = '/path/to/output.nc'
573569
expected_output_basename = '/path/to/output.nc'
574570
mock_get_mimetype.return_value = ('application/x-netcdf4', None)
@@ -601,16 +597,13 @@ def test_hoss_stage(
601597
'africa.nc4',
602598
'application/x-netcdf4',
603599
)
604-
600+
605601
assert result == expected_staged_url
606602

607603
def test_hoss_stage_raises_exception(
608-
self,
609-
mock_stage,
610-
mock_subset_granule,
611-
mock_get_mimetype
612-
):
613-
"""Ensure hoss_stage raises an StagingFailed exception when
604+
self, mock_stage, mock_subset_granule, mock_get_mimetype
605+
):
606+
"""Ensure hoss_stage raises an StagingFailed exception when
614607
the Harmony stage function throws an exception.
615608
616609
"""
@@ -631,12 +624,9 @@ def test_hoss_stage_raises_exception(
631624
'/path/to/output.nc',
632625
'africa.nc4',
633626
'application/x-netcdf4',
634-
)
627+
)
635628

636-
self.assertIsInstance(
637-
context_manager.exception,
638-
CustomError
639-
)
629+
self.assertIsInstance(context_manager.exception, CustomError)
640630
self.assertEqual(
641631
str(context_manager.exception),
642632
'Staging failed, Connection timeout',

tests/unit/test_utilities.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,9 @@ def test_raise_from_hoss_exception(self):
446446
raise_from_hoss_exception(failed_exception)
447447
self.assertNotIsInstance(context.exception, NoRetryException)
448448

449-
with self.subTest('UrlAccessFailedWithNoRetries (no-retry) raises NoRetryException.'):
449+
with self.subTest(
450+
'UrlAccessFailedWithNoRetries (no-retry) raises NoRetryException.'
451+
):
450452
failed_exception = UrlAccessFailedWithNoRetries(test_url, 400)
451453
with self.assertRaises(NoRetryException):
452454
raise_from_hoss_exception(failed_exception)

0 commit comments

Comments
 (0)