Skip to content

Commit 6f6212d

Browse files
committed
logging fix
1 parent 49d305f commit 6f6212d

2 files changed

Lines changed: 24 additions & 7 deletions

File tree

src/cell2sentence4longevity/preprocess.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ def _process_single_file(
296296
join_collection=join_collection
297297
)
298298

299+
print(f" ✓ Conversion completed")
299300
action.log(message_type="conversion_completed", dataset_name=dataset_name)
300301

301302
# Force garbage collection to free memory
@@ -311,13 +312,18 @@ def _process_single_file(
311312
if repo_id and token:
312313
# Upload to same repository as subfolder (dataset_name creates subfolder in repo)
313314
action.log(message_type="upload_started", dataset_name=dataset_name, repo_id=repo_id, upload_dir=str(upload_dir))
315+
print(f" Uploading {dataset_name} to HuggingFace...")
314316
files_uploaded = upload_to_huggingface(
315317
data_splits_dir=upload_dir,
316318
token=token,
317319
repo_id=repo_id,
318320
dataset_name=dataset_name
319321
)
320322
dataset_url = f"https://huggingface.co/datasets/{repo_id}"
323+
if files_uploaded:
324+
print(f" ✓ Upload completed: {dataset_url}")
325+
else:
326+
print(f" ⚠ Upload returned False")
321327
action.log(message_type="upload_completed", dataset_name=dataset_name, repo_id=repo_id, dataset_url=dataset_url, files_uploaded=files_uploaded)
322328

323329
# Final garbage collection
@@ -455,6 +461,19 @@ def run(
455461
If --skip-train-test-split is used, the data will remain in a single parquet directory,
456462
allowing users on HuggingFace to decide on their own splitting strategy.
457463
"""
464+
# Setup logging once at the start (not per-file)
465+
if log_dir:
466+
log_dir.mkdir(parents=True, exist_ok=True)
467+
if batch_mode:
468+
# In batch mode, use a global log file
469+
global_log = log_dir / "batch_pipeline.log"
470+
else:
471+
# In single file mode, use a simple pipeline log
472+
global_log = log_dir / "pipeline.log"
473+
json_path = global_log.with_suffix('.json')
474+
to_nice_file(output_file=json_path, rendered_file=global_log)
475+
print(f"Logging to: {global_log}")
476+
458477
with start_action(action_type="cli_run", batch_mode=batch_mode) as action:
459478
# Validate output directory - prevent writing to data/test (reserved for code tests)
460479
output_dir_resolved = output_dir.resolve()
@@ -522,16 +541,10 @@ def run(
522541
# Check if output already exists and skip if flag is enabled
523542
if skip_existing and check_output_exists(output_dir, dataset_name, skip_train_test_split):
524543
action.log(message_type="dataset_skipped", dataset_name=dataset_name, reason="output_already_exists", output_path=str(dataset_output_path))
544+
print(f" Skipping (output already exists)")
525545
skipped_datasets.append((dataset_name, dataset_output_path))
526546
continue
527547

528-
# Setup per-file logging
529-
if log_dir:
530-
file_log = log_dir / dataset_name / "pipeline.log"
531-
file_log.parent.mkdir(parents=True, exist_ok=True)
532-
json_path = file_log.with_suffix('.json')
533-
to_nice_file(output_file=json_path, rendered_file=file_log)
534-
535548
# Process the file
536549
success, message, processing_time, dataset_output_path = _process_single_file(
537550
h5ad_path=h5ad_file,

src/cell2sentence4longevity/preprocessing/upload.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ def upload_to_huggingface(
276276
repo_paths=repo_paths[:10] # Log first 10 paths as sample
277277
)
278278

279+
print(f" Preparing to upload {total_files} files to {repo_id}...")
280+
279281
# Create a single commit with all operations (will overwrite existing files)
280282
with tqdm(total=1, desc=f'Uploading {dataset_name}') as pbar:
281283
commit_info = api.create_commit(
@@ -286,6 +288,8 @@ def upload_to_huggingface(
286288
)
287289
pbar.update(1)
288290

291+
print(f" Commit URL: {commit_info.commit_url}")
292+
289293
action.log(
290294
message_type="upload_complete",
291295
commit_url=commit_info.commit_url,

0 commit comments

Comments
 (0)