Skip to content

Commit 64003b3

Browse files
committed
refactor: remove legacy backward-compatibility code from CLI and geotrack
- Remove duplicate platform_id/platform_name/platform_type fields from campaign create (only the platforms array is now written) - Remove legacy platform_id fallback display in campaign show/list/delete/inspect - Remove deprecated --upload CLI option from geotrack convert, multibeam, and adcp - Remove upload parameter from geotrack processor convert() function - Update test mock metadata to use platforms array format
1 parent fa865f8 commit 64003b3

3 files changed

Lines changed: 8 additions & 44 deletions

File tree

oceanstream/cli.py

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,6 @@ def create_campaign_command(
379379
if platforms_list:
380380
# From --platform CLI option(s)
381381
metadata['platforms'] = platforms_list
382-
# Also set legacy fields for backward compatibility (first platform)
383-
metadata['platform_id'] = platforms_list[0]['id']
384-
if 'name' in platforms_list[0]:
385-
metadata['platform_name'] = platforms_list[0]['name']
386-
if 'type' in platforms_list[0]:
387-
metadata['platform_type'] = platforms_list[0]['type']
388382
elif platform_id:
389383
# From interactive mode - convert to platforms array
390384
platform_dict = {"id": platform_id}
@@ -393,12 +387,6 @@ def create_campaign_command(
393387
if platform_type:
394388
platform_dict["type"] = platform_type
395389
metadata['platforms'] = [platform_dict]
396-
# Also set legacy fields
397-
metadata['platform_id'] = platform_id
398-
if platform_name:
399-
metadata['platform_name'] = platform_name
400-
if platform_type:
401-
metadata['platform_type'] = platform_type
402390

403391
# Remove None values
404392
metadata = {k: v for k, v in metadata.items() if v is not None}
@@ -475,13 +463,6 @@ def show_campaign_command(
475463
typer.echo(f" Type: {p['type']}")
476464
if 'row_count' in p:
477465
typer.echo(f" Rows: {p['row_count']:,}")
478-
# Legacy single-platform fields (backward compatibility)
479-
elif "platform_id" in metadata:
480-
typer.echo(f"Platform ID: {metadata['platform_id']}")
481-
if "platform_name" in metadata:
482-
typer.echo(f"Platform Name: {metadata['platform_name']}")
483-
if "platform_type" in metadata:
484-
typer.echo(f"Platform Type: {metadata['platform_type']}")
485466

486467
typer.echo()
487468

@@ -585,15 +566,12 @@ def list_campaigns_command(
585566
campaign_id = campaign.get("campaign_id", "unknown")
586567
typer.echo(f"{i}. {campaign_id}")
587568

588-
# Show platforms (new format) or legacy platform_id
589569
if "platforms" in campaign and campaign["platforms"]:
590570
platforms = campaign["platforms"]
591571
if len(platforms) == 1:
592572
typer.echo(f" Platform: {platforms[0].get('id', 'N/A')}")
593573
else:
594574
typer.echo(f" Platforms: {len(platforms)} ({', '.join(p.get('id', '?') for p in platforms)})")
595-
elif "platform_id" in campaign:
596-
typer.echo(f" Platform: {campaign['platform_id']}")
597575

598576
if "description" in campaign:
599577
desc = campaign['description']
@@ -623,7 +601,7 @@ def list_campaigns_command(
623601
else:
624602
platform_str = f"{len(platforms)} platforms"
625603
else:
626-
platform_str = campaign.get("platform_id", "N/A")
604+
platform_str = "N/A"
627605

628606
description = campaign.get("description", "")
629607

@@ -670,15 +648,12 @@ def delete_campaign_command(
670648
if not yes:
671649
typer.echo(f"[campaign delete] About to delete campaign: {campaign_id}")
672650

673-
# Show platforms (new format) or legacy platform_id
674651
if "platforms" in metadata and metadata["platforms"]:
675652
platforms = metadata["platforms"]
676653
if len(platforms) == 1:
677654
typer.echo(f"[campaign delete] Platform: {platforms[0].get('id', 'N/A')}")
678655
else:
679656
typer.echo(f"[campaign delete] Platforms: {len(platforms)} ({', '.join(p.get('id', '?') for p in platforms)})")
680-
elif "platform_id" in metadata:
681-
typer.echo(f"[campaign delete] Platform: {metadata['platform_id']}")
682657

683658
if "description" in metadata:
684659
typer.echo(f"[campaign delete] Description: {metadata['description']}")
@@ -742,7 +717,6 @@ def inspect_campaign_command(
742717
typer.echo(f"{'=' * 70}")
743718

744719
if metadata:
745-
# Show platforms (new format) or legacy platform_id
746720
if "platforms" in metadata and metadata["platforms"]:
747721
platforms = metadata["platforms"]
748722
if len(platforms) == 1:
@@ -752,8 +726,6 @@ def inspect_campaign_command(
752726
for p in platforms:
753727
row_info = f" ({p['row_count']:,} rows)" if 'row_count' in p else ""
754728
typer.echo(f" - {p.get('id', 'unknown')}{row_info}")
755-
elif "platform_id" in metadata:
756-
typer.echo(f"Platform: {metadata['platform_id']}")
757729
if "description" in metadata:
758730
desc = metadata['description']
759731
if len(desc) > 60:
@@ -885,7 +857,6 @@ def convert_command(
885857
help="Output path for GeoParquet. Local path or cloud URI (az://container/path, s3://bucket/path). Campaign subdirectories are auto-created.",
886858
),
887859
provider: str = typer.Option(None, "--provider", help="Data provider type (overrides global --provider setting). Available: saildrone, r2r."),
888-
upload: bool = typer.Option(False, "--upload", help="(Deprecated) Use --use-cloud-storage instead."),
889860
use_cloud_storage: bool = typer.Option(False, "--use-cloud-storage", help="Write output to configured cloud storage (requires 'oceanstream storage add' first)."),
890861
verbose: bool = typer.Option(False, "-v", help="Emit detailed progress information."),
891862
list_columns: bool = typer.Option(False, help="List available columns from the input CSVs and exit."),
@@ -965,7 +936,6 @@ def convert_command(
965936
print_schema=print_schema,
966937
provider_metadata=provider_metadata,
967938
dry_run=dry_run,
968-
upload=upload,
969939
yes=yes,
970940
generate_pmtiles=generate_pmtiles,
971941
pmtiles_minzoom=pmtiles_minzoom,
@@ -2037,7 +2007,6 @@ def multibeam_command(
20372007
input_dir: Path = typer.Option(Path("raw_multibeam"), exists=True, file_okay=False, help="Directory with raw multibeam backscatter data."),
20382008
output_dir: Path = typer.Option(Path("out/multibeam"), help="Output directory for processed multibeam products."),
20392009
verbose: bool = typer.Option(False, "-v", help="Emit progress information."),
2040-
upload: bool = typer.Option(False, help="Upload processed data to cloud storage after conversion (future)."),
20412010
dry_run: bool = typer.Option(False, "--dry-run", help="Show planned actions without executing."),
20422011
) -> None:
20432012
global _provider_obj
@@ -2063,7 +2032,6 @@ def adcp_command(
20632032
input_dir: Path = typer.Option(Path("raw_adcp"), exists=True, file_okay=False, help="Directory with raw ADCP data."),
20642033
output_dir: Path = typer.Option(Path("out/adcp"), help="Output directory for processed ADCP products."),
20652034
verbose: bool = typer.Option(False, "-v", help="Emit progress information."),
2066-
upload: bool = typer.Option(False, help="Upload processed data to cloud storage after conversion (future)."),
20672035
dry_run: bool = typer.Option(False, "--dry-run", help="Show planned actions without executing."),
20682036
) -> None:
20692037
global _provider_obj

oceanstream/geotrack/processor.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,6 @@ def convert(
15561556
print_schema: bool = False,
15571557
provider_metadata: bool = False,
15581558
dry_run: bool = False,
1559-
upload: bool = False,
15601559
yes: bool = False,
15611560
generate_pmtiles: bool = False,
15621561
pmtiles_minzoom: int = 0,
@@ -1601,7 +1600,6 @@ def convert(
16011600
print_schema: Print GeoParquet schema and exit
16021601
provider_metadata: Print provider metadata and exit
16031602
dry_run: Analyze inputs without writing files
1604-
upload: (Deprecated) Use use_cloud_storage instead
16051603
yes: Skip confirmation prompts
16061604
generate_pmtiles: Generate PMTiles vector tiles with segments, day markers, and arrows
16071605
pmtiles_minzoom: Minimum zoom level for PMTiles (0-15)
@@ -1648,11 +1646,11 @@ def convert(
16481646
output_str = str(output_dir)
16491647
is_cloud_uri = output_str.startswith(("az://", "abfs://", "s3://", "gs://"))
16501648

1651-
if is_cloud_uri or use_cloud_storage or upload:
1649+
if is_cloud_uri or use_cloud_storage:
16521650
try:
16531651
storage_path = resolve_output_path(
16541652
output_dir,
1655-
use_active_storage=(use_cloud_storage or upload) and not is_cloud_uri,
1653+
use_active_storage=use_cloud_storage and not is_cloud_uri,
16561654
)
16571655
filesystem = storage_path.filesystem
16581656
resolved_output_dir = storage_path.path
@@ -1778,7 +1776,6 @@ def convert(
17781776
print_schema=print_schema,
17791777
provider_metadata=provider_metadata,
17801778
dry_run=dry_run,
1781-
upload=upload,
17821779
yes=True, # Skip confirmation prompts in recursive calls
17831780
generate_pmtiles=generate_pmtiles,
17841781
pmtiles_minzoom=pmtiles_minzoom,

oceanstream/tests/unit/test_cli_commands.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@ def test_show_campaign_success(self):
178178
"""Test showing campaign details."""
179179
mock_metadata = {
180180
'campaign_id': 'FK161229',
181-
'platform_id': 'R/V_Falkor',
182-
'platform_name': 'Research Vessel Falkor',
181+
'platforms': [{'id': 'R/V_Falkor', 'name': 'Research Vessel Falkor'}],
183182
'description': 'Test campaign',
184183
'start_date': '2016-12-29',
185184
'end_date': '2017-01-20',
@@ -211,12 +210,12 @@ def test_list_campaigns_with_results(self):
211210
mock_campaigns = [
212211
{
213212
'campaign_id': 'FK161229',
214-
'platform_id': 'R/V_Falkor',
213+
'platforms': [{'id': 'R/V_Falkor'}],
215214
'start_date': '2016-12-29',
216215
},
217216
{
218217
'campaign_id': 'SD1030_2023',
219-
'platform_id': 'sd1030',
218+
'platforms': [{'id': 'sd1030'}],
220219
'start_date': '2023-06-01',
221220
},
222221
]
@@ -242,7 +241,7 @@ def test_list_campaigns_verbose(self):
242241
mock_campaigns = [
243242
{
244243
'campaign_id': 'FK161229',
245-
'platform_id': 'R/V_Falkor',
244+
'platforms': [{'id': 'R/V_Falkor'}],
246245
'description': 'Test campaign',
247246
'start_date': '2016-12-29',
248247
'end_date': '2017-01-20',
@@ -262,7 +261,7 @@ class TestDeleteCampaignCommand:
262261

263262
def test_delete_campaign_success_with_yes_flag(self):
264263
"""Test deleting campaign with --yes flag."""
265-
mock_metadata = {'campaign_id': 'FK161229', 'platform_id': 'R/V_Falkor'}
264+
mock_metadata = {'campaign_id': 'FK161229', 'platforms': [{'id': 'R/V_Falkor'}]}
266265

267266
with patch('oceanstream.geotrack.campaign.load_campaign_metadata', return_value=mock_metadata):
268267
with patch('oceanstream.geotrack.campaign.delete_campaign') as mock_delete:

0 commit comments

Comments
 (0)