Skip to content

Commit 49d305f

Browse files
committed
log fix
1 parent 323e160 commit 49d305f

3 files changed

Lines changed: 28 additions & 289 deletions

File tree

BATCH_PROCESSING.md

Lines changed: 0 additions & 227 deletions
This file was deleted.

src/cell2sentence4longevity/preprocess.py

Lines changed: 14 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,6 @@ def _process_single_file(
271271
with start_action(action_type="process_single_file", dataset_name=dataset_name, h5ad_path=str(h5ad_path)) as action:
272272
try:
273273
# One-step conversion: h5ad -> cell sentences + age extraction -> train/test split -> output
274-
typer.echo("="*80)
275-
typer.echo(f"Processing: {dataset_name}")
276-
typer.echo("Converting h5ad, extracting age, and creating train/test split in one pass")
277-
typer.echo("="*80)
278274
action.log(
279275
message_type="file_processing_started",
280276
dataset_name=dataset_name,
@@ -300,7 +296,6 @@ def _process_single_file(
300296
join_collection=join_collection
301297
)
302298

303-
typer.secho(f"✓ Conversion complete for {dataset_name}\n", fg=typer.colors.GREEN)
304299
action.log(message_type="conversion_completed", dataset_name=dataset_name)
305300

306301
# Force garbage collection to free memory
@@ -314,9 +309,6 @@ def _process_single_file(
314309

315310
# Upload to HuggingFace (optional)
316311
if repo_id and token:
317-
typer.echo("="*80)
318-
typer.echo(f"Uploading: {dataset_name} to HuggingFace")
319-
typer.echo("="*80)
320312
# Upload to same repository as subfolder (dataset_name creates subfolder in repo)
321313
action.log(message_type="upload_started", dataset_name=dataset_name, repo_id=repo_id, upload_dir=str(upload_dir))
322314
files_uploaded = upload_to_huggingface(
@@ -326,11 +318,6 @@ def _process_single_file(
326318
dataset_name=dataset_name
327319
)
328320
dataset_url = f"https://huggingface.co/datasets/{repo_id}"
329-
if files_uploaded:
330-
typer.secho(f"✓ Upload complete for {dataset_name}\n", fg=typer.colors.GREEN)
331-
typer.echo(f"Dataset: {dataset_url} (subfolder: {dataset_name})")
332-
else:
333-
typer.echo(f"Dataset: {dataset_url} (subfolder: {dataset_name})")
334321
action.log(message_type="upload_completed", dataset_name=dataset_name, repo_id=repo_id, dataset_url=dataset_url, files_uploaded=files_uploaded)
335322

336323
# Final garbage collection
@@ -344,7 +331,6 @@ def _process_single_file(
344331
processing_time = time.time() - start_time
345332
error_msg = f"Failed to process {dataset_name}: {str(e)}"
346333
action.log(message_type="file_processing_error", dataset_name=dataset_name, error=str(e), processing_time_seconds=round(processing_time, 2))
347-
typer.secho(f"✗ Error processing {dataset_name}: {e}", fg=typer.colors.RED)
348334

349335
# Force garbage collection even on error
350336
gc.collect()
@@ -530,19 +516,11 @@ def run(
530516
dataset_output_path = output_dir / dataset_name
531517

532518
if process_multiple:
533-
# Visual separator for batch mode
534-
typer.echo("\n" + "="*80)
535-
typer.echo(f" DATASET {idx}/{len(h5ad_files)}: {dataset_name}")
536-
typer.echo("="*80 + "\n")
537-
else:
538-
typer.echo("\n" + "="*80)
539-
typer.echo(f"Processing: {dataset_name}")
540-
typer.echo("="*80)
519+
# Progress indicator for batch mode
520+
typer.echo(f"\n[{idx}/{len(h5ad_files)}] Processing: {dataset_name}")
541521

542522
# Check if output already exists and skip if flag is enabled
543523
if skip_existing and check_output_exists(output_dir, dataset_name, skip_train_test_split):
544-
typer.secho(f"⏭ Skipping {dataset_name}: output files already exist", fg=typer.colors.YELLOW)
545-
typer.echo(f" Output directory: {dataset_output_path}")
546524
action.log(message_type="dataset_skipped", dataset_name=dataset_name, reason="output_already_exists", output_path=str(dataset_output_path))
547525
skipped_datasets.append((dataset_name, dataset_output_path))
548526
continue
@@ -574,20 +552,15 @@ def run(
574552
results.append((dataset_name, success, message, processing_time, dataset_output_path))
575553

576554
# Summary
577-
typer.echo("\n" + "="*80)
578-
typer.secho("Pipeline Complete - Summary", fg=typer.colors.GREEN, bold=True)
579-
typer.echo("="*80)
580-
581555
successful = sum(1 for _, success, _, _, _ in results if success)
582556
failed = len(results) - successful
583557
total_processed = len(results) + len(skipped_datasets)
584558

585-
typer.echo(f"Total files: {total_processed}")
586-
typer.echo(f"Successful: {successful}")
559+
typer.echo(f"\nProcessing complete: {successful}/{total_processed} successful")
587560
if failed > 0:
588-
typer.echo(f"Failed: {failed}")
561+
typer.echo(f" Failed: {failed}")
589562
if skipped_datasets:
590-
typer.echo(f"Skipped: {len(skipped_datasets)}")
563+
typer.echo(f" Skipped: {len(skipped_datasets)}")
591564

592565
action.log(
593566
message_type="pipeline_summary",
@@ -601,23 +574,16 @@ def run(
601574
log_dir=str(log_dir) if log_dir else None
602575
)
603576

604-
typer.echo("\nDetails:")
605-
# Show skipped datasets first
606-
for dataset_name, dataset_output_path in skipped_datasets:
607-
typer.secho(f" ⏭ {dataset_name}: Skipped (output already exists)", fg=typer.colors.YELLOW)
608-
typer.echo(f" Output: {dataset_output_path}")
609-
# Show processed datasets
610-
for dataset_name, success, message, processing_time, _ in results:
611-
status = "✓" if success else "✗"
612-
color = typer.colors.GREEN if success else typer.colors.RED
613-
typer.secho(f" {status} {dataset_name}: {message}", fg=color)
577+
# Show failed datasets if any
578+
if failed > 0:
579+
typer.echo("\nFailed datasets:")
580+
for dataset_name, success, message, _, _ in results:
581+
if not success:
582+
typer.echo(f" ✗ {dataset_name}: {message}")
614583

615-
typer.echo(f"\nOutput directories:")
616-
typer.echo(f" Input: {input_dir}")
617-
typer.echo(f" Interim: {interim_dir}")
618-
typer.echo(f" Output: {output_dir}")
584+
typer.echo(f"\nOutput: {output_dir}")
619585
if log_dir:
620-
typer.echo(f" Logs: {log_dir}")
586+
typer.echo(f"Logs: {log_dir}")
621587

622588
# Write summary TSV file if processing multiple files
623589
if process_multiple:
@@ -676,8 +642,7 @@ def run(
676642
skipped=len(skipped_datasets)
677643
)
678644

679-
typer.echo(f"\n✓ Batch processing summary written to: {summary_file}")
680-
typer.echo(f" Summary contains timing and output paths for all processed datasets")
645+
typer.echo(f"Summary: {summary_file}")
681646

682647

683648
def main() -> None:

0 commit comments

Comments
 (0)