Skip to content

Commit 61a006c

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 195367a commit 61a006c

File tree

3 files changed

+9
-27
lines changed

3 files changed

+9
-27
lines changed

batcher/harmony/service_adapter.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ def invoke(self):
7070
# Message-only support is being depreciated in Harmony, so we should expect to
7171
# only see requests with catalogs when invoked with a newer Harmony instance
7272
# https://github.com/nasa/harmony-service-lib-py/blob/21bcfbda17caf626fb14d2ac4f8673be9726b549/harmony/adapter.py#L71
73-
raise RuntimeError(
74-
"Invoking Batchee without a STAC catalog is not supported"
75-
)
73+
raise RuntimeError("Invoking Batchee without a STAC catalog is not supported")
7674

7775
return self.message, self.process_catalog(self.catalog)
7876

@@ -110,9 +108,7 @@ def process_catalog(self, catalog: pystac.Catalog) -> list[pystac.Catalog]:
110108
# and each Catalog holds multiple Items (which represent each granule).
111109
catalogs = []
112110
for batch_id, batch_items in grouped.items():
113-
self.logger.info(
114-
f"constructing new pystac.Catalog for batch_id==={batch_id}."
115-
)
111+
self.logger.info(f"constructing new pystac.Catalog for batch_id==={batch_id}.")
116112
# Initialize a new, empty Catalog
117113
batch_catalog = catalog.clone()
118114
batch_catalog.id = str(uuid4())
@@ -139,9 +135,7 @@ def process_catalog(self, catalog: pystac.Catalog) -> list[pystac.Catalog]:
139135
)
140136
batch_catalog.add_item(output_item)
141137

142-
self.logger.info(
143-
"STAC catalog creation for batch_id==={batch_id} complete."
144-
)
138+
self.logger.info("STAC catalog creation for batch_id==={batch_id} complete.")
145139
catalogs.append(batch_catalog)
146140

147141
self.logger.info("All STAC catalogs are complete.")

batcher/tempo_filename_parser.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@
4545
)
4646

4747

48-
def get_batch_indices(
49-
filenames: list, logger: logging.Logger = default_logger
50-
) -> list[int]:
48+
def get_batch_indices(filenames: list, logger: logging.Logger = default_logger) -> list[int]:
5149
"""
5250
Returns
5351
-------
@@ -62,14 +60,10 @@ def get_batch_indices(
6260
matches = tempo_granule_filename_pattern.match(name)
6361
if matches:
6462
match_dict = matches.groupdict()
65-
day_and_scans.append(
66-
(match_dict["day_in_granule"], match_dict["daily_scan_id"])
67-
)
63+
day_and_scans.append((match_dict["day_in_granule"], match_dict["daily_scan_id"]))
6864

6965
# Unique day-scans are determined (while keeping the same order). Each will be its own batch.
70-
unique_day_scans: list[tuple[str, str]] = sorted(
71-
set(day_and_scans), key=day_and_scans.index
72-
)
66+
unique_day_scans: list[tuple[str, str]] = sorted(set(day_and_scans), key=day_and_scans.index)
7367

7468
logger.info(f"unique_day_scans==={unique_day_scans}.")
7569

@@ -109,9 +103,7 @@ def main() -> list[list[str]]:
109103
input_filenames = args.file_names
110104

111105
batch_indices = get_batch_indices(input_filenames)
112-
unique_category_indices: list[int] = sorted(
113-
set(batch_indices), key=batch_indices.index
114-
)
106+
unique_category_indices: list[int] = sorted(set(batch_indices), key=batch_indices.index)
115107
logging.info(f"batch_indices = {batch_indices}")
116108

117109
# --- Construct a STAC object based on the batch indices ---

tests/test_harmony_adapter.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ def test_service_invoke(self, temp_output_dir):
6363

6464
for item_meta in out_catalog["links"]:
6565
if item_meta["rel"] == "item":
66-
item_path = temp_output_dir.joinpath(
67-
item_meta["href"]
68-
).resolve()
66+
item_path = temp_output_dir.joinpath(item_meta["href"]).resolve()
6967

7068
# -- Item Verification --
7169
item = json.loads(item_path.read_text())
@@ -81,9 +79,7 @@ def test_service_invoke(self, temp_output_dir):
8179
assert data["type"] == "application/x-netcdf4"
8280
assert data["roles"] == ["data"]
8381

84-
batched_files[batch_index].append(
85-
Path(urlsplit(data["href"]).path).stem
86-
)
82+
batched_files[batch_index].append(Path(urlsplit(data["href"]).path).stem)
8783

8884
# -- batch file list verification --
8985
files_dict = {

0 commit comments

Comments
 (0)