-
Notifications
You must be signed in to change notification settings - Fork 0
feat: thread primary_task through bundle, validation, and pipelines #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,9 +8,37 @@ | |||||||||||||||||||||||||||||||||||||||||||
| from __future__ import annotations | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| from pathlib import Path | ||||||||||||||||||||||||||||||||||||||||||||
| from typing import Any | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| import pandas as pd | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| from leadforge.core.serialization import load_json | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| _LABEL_COLUMN = "converted_within_90_days" | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| def _find_task_train(bundle_path: Path) -> tuple[Path | None, str]: | ||||||||||||||||||||||||||||||||||||||||||||
| """Locate the primary task's train.parquet from the bundle manifest. | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| Returns ``(train_path_or_None, task_id)`` where *task_id* is included | ||||||||||||||||||||||||||||||||||||||||||||
| so callers can produce useful error messages. | ||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||
| manifest_path = bundle_path / "manifest.json" | ||||||||||||||||||||||||||||||||||||||||||||
| if manifest_path.exists(): | ||||||||||||||||||||||||||||||||||||||||||||
| manifest: dict[str, Any] = load_json(manifest_path) | ||||||||||||||||||||||||||||||||||||||||||||
| tasks = manifest.get("tasks", {}) | ||||||||||||||||||||||||||||||||||||||||||||
| if isinstance(tasks, dict) and tasks: | ||||||||||||||||||||||||||||||||||||||||||||
| primary = manifest.get("primary_task") | ||||||||||||||||||||||||||||||||||||||||||||
| task_id = ( | ||||||||||||||||||||||||||||||||||||||||||||
| primary if isinstance(primary, str) and primary in tasks else next(iter(tasks)) | ||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||
| train = bundle_path / f"tasks/{task_id}/train.parquet" | ||||||||||||||||||||||||||||||||||||||||||||
| return (train if train.exists() else None), task_id | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+28
to
+36
|
||||||||||||||||||||||||||||||||||||||||||||
| manifest: dict[str, Any] = load_json(manifest_path) | |
| tasks = manifest.get("tasks", {}) | |
| if isinstance(tasks, dict) and tasks: | |
| primary = manifest.get("primary_task") | |
| task_id = ( | |
| primary if isinstance(primary, str) and primary in tasks else next(iter(tasks)) | |
| ) | |
| train = bundle_path / f"tasks/{task_id}/train.parquet" | |
| return (train if train.exists() else None), task_id | |
| try: | |
| manifest: dict[str, Any] = load_json(manifest_path) | |
| tasks = manifest.get("tasks", {}) | |
| if isinstance(tasks, dict) and tasks: | |
| primary = manifest.get("primary_task") | |
| task_id = ( | |
| primary if isinstance(primary, str) and primary in tasks else next(iter(tasks)) | |
| ) | |
| train = bundle_path / f"tasks/{task_id}/train.parquet" | |
| return (train if train.exists() else None), task_id | |
| except Exception: | |
| pass |
Uh oh!
There was an error while loading. Please reload this page.