Skip to content

Commit 90234a4

Browse files
Refactor CLI output messages and update pre-commit configuration for flake8
1 parent 295fb5f commit 90234a4

6 files changed

Lines changed: 22 additions & 26 deletions

File tree

File renamed without changes.

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ repos:
2727
hooks:
2828
- id: flake8
2929
additional_dependencies: [flake8-docstrings]
30-
args: [--max-line-length=88, --extend-ignore=E203,W503]
30+
args: [--max-line-length=150, --extend-ignore=E203]
3131

3232
- repo: https://github.com/pre-commit/mirrors-mypy
3333
rev: v1.5.1

eopf_geozarr/cli.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import argparse
99
import sys
1010
from pathlib import Path
11-
from typing import List, Optional
1211

1312
import xarray as xr
1413

@@ -72,7 +71,7 @@ def convert_command(args: argparse.Namespace) -> None:
7271
max_retries=args.max_retries,
7372
)
7473

75-
print(f"✅ Successfully converted EOPF dataset to GeoZarr format")
74+
print("✅ Successfully converted EOPF dataset to GeoZarr format")
7675
print(f"Output saved to: {output_path}")
7776

7877
if args.verbose:
@@ -116,11 +115,11 @@ def info_command(args: argparse.Namespace) -> None:
116115
print(f"Loading dataset from: {input_path}")
117116
dt = xr.open_datatree(input_path, engine="zarr")
118117

119-
print(f"\nDataset Information:")
120-
print(f"==================")
118+
print("\nDataset Information:")
119+
print("==================")
121120
print(f"Total groups: {len(dt.children)}")
122121

123-
print(f"\nGroup structure:")
122+
print("\nGroup structure:")
124123
for group_name, group in dt.children.items():
125124
print(f" {group_name}:")
126125
if hasattr(group, "data_vars") and group.data_vars:
@@ -182,14 +181,14 @@ def validate_command(args: argparse.Namespace) -> None:
182181
total_variables = 0
183182
compliant_variables = 0
184183

185-
print(f"\nValidation Results:")
186-
print(f"==================")
184+
print("\nValidation Results:")
185+
print("==================")
187186

188187
for group_name, group in dt.children.items():
189188
print(f"\nGroup: {group_name}")
190189

191190
if not hasattr(group, "data_vars") or not group.data_vars:
192-
print(f" ⚠️ No data variables found")
191+
print(" ⚠️ No data variables found")
193192
continue
194193

195194
for var_name, var in group.data_vars.items():
@@ -215,8 +214,8 @@ def validate_command(args: argparse.Namespace) -> None:
215214
print(f" ✅ {var_name}: Compliant")
216215
compliant_variables += 1
217216

218-
print(f"\nSummary:")
219-
print(f"========")
217+
print("\nSummary:")
218+
print("========")
220219
print(f"Total variables checked: {total_variables}")
221220
print(f"Compliant variables: {compliant_variables}")
222221
print(f"Non-compliant variables: {total_variables - compliant_variables}")

eopf_geozarr/conversion/geozarr.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,9 @@
1818
import os
1919
import shutil
2020
import time
21-
import warnings
22-
from pathlib import Path
2321
from typing import Any, Dict, List, Optional, Tuple
2422

25-
import dask.array as da
2623
import numpy as np
27-
import rasterio
2824
import xarray as xr
2925
import zarr
3026
import zarr.api
@@ -502,7 +498,7 @@ def write_geozarr_group(
502498
# Create GeoZarr-spec compliant multiscales (overview levels as children groups)
503499
try:
504500
print(f"Creating GeoZarr-spec compliant multiscales for {group_name}")
505-
multiscales_result = create_geozarr_compliant_multiscales(
501+
create_geozarr_compliant_multiscales(
506502
ds=ds,
507503
output_path=output_path,
508504
group_name=group_name,
@@ -815,7 +811,6 @@ def create_native_crs_tile_matrix_set(
815811
level = overview["level"]
816812
width = overview["width"]
817813
height = overview["height"]
818-
scale_factor = overview["scale_factor"]
819814

820815
# Calculate cell size (pixel size in CRS units)
821816
cell_size_x = (right - left) / width

eopf_geozarr/conversion/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Utility functions for GeoZarr conversion."""
22

33
import numpy as np
4-
import rasterio
4+
import rasterio # noqa: F401 # Import to enable .rio accessor
55
import xarray as xr
66

77

eopf_geozarr/tests/test_cli_e2e.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
docs/analysis/eopf-geozarr/EOPF_Sentinel2_ZarrV3_geozarr_compliant.ipynb
77
"""
88

9-
import os
109
import shutil
1110
import subprocess
1211
import tempfile
@@ -20,15 +19,15 @@ class TestCLIEndToEnd:
2019
"""End-to-end CLI tests with real data."""
2120

2221
@pytest.fixture
23-
def temp_output_dir(self):
22+
def temp_output_dir(self) -> str:
2423
"""Create a temporary directory for test outputs."""
2524
temp_dir = tempfile.mkdtemp()
2625
yield temp_dir
2726
shutil.rmtree(temp_dir)
2827

2928
@pytest.mark.slow
3029
@pytest.mark.network
31-
def test_cli_convert_real_sentinel2_data(self, temp_output_dir):
30+
def test_cli_convert_real_sentinel2_data(self, temp_output_dir) -> None:
3231
"""
3332
Test CLI conversion using real Sentinel-2 data from the notebook.
3433
@@ -39,7 +38,10 @@ def test_cli_convert_real_sentinel2_data(self, temp_output_dir):
3938
4. Tests CLI info and validate commands
4039
"""
4140
# Dataset from the notebook
42-
input_url = "https://objectstore.eodc.eu:2222/e05ab01a9d56408d82ac32d69a5aae2a:sample-data/tutorial_data/cpm_v253/S2B_MSIL1C_20250113T103309_N0511_R108_T32TLQ_20250113T122458.zarr"
41+
input_url = (
42+
"https://objectstore.eodc.eu:2222/e05ab01a9d56408d82ac32d69a5aae2a:sample-data/"
43+
"tutorial_data/cpm_v253/S2B_MSIL1C_20250113T103309_N0511_R108_T32TLQ_20250113T122458.zarr"
44+
)
4345
output_path = Path(temp_output_dir) / "s2b_geozarr_cli_test.zarr"
4446

4547
# Groups to convert (from the notebook)
@@ -50,7 +52,7 @@ def test_cli_convert_real_sentinel2_data(self, temp_output_dir):
5052
"/quality/l1c_quicklook/r10m",
5153
]
5254

53-
print(f"Testing CLI conversion with real Sentinel-2 data...")
55+
print("Testing CLI conversion with real Sentinel-2 data...")
5456
print(f"Input URL: {input_url}")
5557
print(f"Output path: {output_path}")
5658

@@ -144,7 +146,7 @@ def test_cli_convert_real_sentinel2_data(self, temp_output_dir):
144146

145147
print("✅ All CLI end-to-end tests passed!")
146148

147-
def _verify_converted_data_structure(self, output_path, groups):
149+
def _verify_converted_data_structure(self, output_path, groups) -> None:
148150
"""Verify the structure and compliance of converted data."""
149151

150152
# Check each group was converted
@@ -204,7 +206,7 @@ def _verify_converted_data_structure(self, output_path, groups):
204206
if len(level_dirs) > 1:
205207
print(f" ✅ Multiscale structure created")
206208

207-
def test_cli_help_commands(self):
209+
def test_cli_help_commands(self) -> None:
208210
"""Test that all CLI help commands work."""
209211

210212
# Test main help
@@ -237,7 +239,7 @@ def test_cli_help_commands(self):
237239

238240
print("✅ All CLI help commands work correctly")
239241

240-
def test_cli_version(self):
242+
def test_cli_version(self) -> None:
241243
"""Test CLI version command."""
242244
result = subprocess.run(
243245
["python", "-m", "eopf_geozarr", "--version"], capture_output=True, text=True

0 commit comments

Comments
 (0)