chore: evals#20
Conversation
| ) | ||
|
|
||
| @classmethod | ||
| def from_dataframe(cls, df: "pandas.DataFrame", name: str) -> "Dataset": |
| import time | ||
| from unittest import mock | ||
|
|
||
| import pytest |
There was a problem hiding this comment.
[ruff-check] reported by reviewdog 🐶
| import pytest |
| import pytest | ||
|
|
| mock_batcher_class.return_value = mock_batcher | ||
|
|
||
| # Patch the imports within run module | ||
| with mock.patch.object(Run, "_init_remote_mode") as mock_init: |
| # Early training - lower quality | ||
| words = base.split() | ||
| np.random.shuffle(words) | ||
| return " ".join(words[:len(words)//2]) |
There was a problem hiding this comment.
[ruff-format] reported by reviewdog 🐶
| return " ".join(words[:len(words)//2]) | |
| return " ".join(words[: len(words) // 2]) |
| run.log_metrics({ | ||
| "train/loss": loss, | ||
| "train/perplexity": perplexity, | ||
| }, step=epoch) |
There was a problem hiding this comment.
[ruff-format] reported by reviewdog 🐶
| run.log_metrics({ | |
| "train/loss": loss, | |
| "train/perplexity": perplexity, | |
| }, step=epoch) | |
| run.log_metrics( | |
| { | |
| "train/loss": loss, | |
| "train/perplexity": perplexity, | |
| }, | |
| step=epoch, | |
| ) |
|
|
||
| # Log the evaluation annotation | ||
| run.log_eval( | ||
| message=f"Epoch {epoch}: {message}\nSample output: \"{output}\"", |
There was a problem hiding this comment.
[ruff-format] reported by reviewdog 🐶
| message=f"Epoch {epoch}: {message}\nSample output: \"{output}\"", | |
| message=f'Epoch {epoch}: {message}\nSample output: "{output}"', |
| "epoch": epoch, | ||
| "output_length": len(output), | ||
| "sample_output": output, | ||
| } |
There was a problem hiding this comment.
[ruff-format] reported by reviewdog 🐶
| } | |
| }, |
| metadata={ | ||
| "final_output": final_output, | ||
| "total_epochs": config["epochs"], | ||
| } |
There was a problem hiding this comment.
[ruff-format] reported by reviewdog 🐶
| } | |
| }, |
| ) | ||
| return response.get("scorers", []) | ||
|
|
||
| def list_evaluations(self, limit: int = 50, offset: int = 0, status: Optional[str] = None) -> List[Evaluation]: |
There was a problem hiding this comment.
[ruff-format] reported by reviewdog 🐶
| def list_evaluations(self, limit: int = 50, offset: int = 0, status: Optional[str] = None) -> List[Evaluation]: | |
| def list_evaluations( | |
| self, limit: int = 50, offset: int = 0, status: Optional[str] = None | |
| ) -> List[Evaluation]: |
| evaluations.append(Evaluation( | ||
| id=item["id"], | ||
| name=item["name"], | ||
| status=item["status"], | ||
| dataset_id=item["dataset_id"], | ||
| scorer_ids=item["scorer_ids"], | ||
| target=item["target"], | ||
| overall_scores=item.get("overall_scores"), | ||
| rows_processed=item.get("rows_processed", 0), | ||
| rows_failed=item.get("rows_failed", 0), | ||
| created_at=item.get("created_at"), | ||
| )) |
There was a problem hiding this comment.
[ruff-format] reported by reviewdog 🐶
| evaluations.append(Evaluation( | |
| id=item["id"], | |
| name=item["name"], | |
| status=item["status"], | |
| dataset_id=item["dataset_id"], | |
| scorer_ids=item["scorer_ids"], | |
| target=item["target"], | |
| overall_scores=item.get("overall_scores"), | |
| rows_processed=item.get("rows_processed", 0), | |
| rows_failed=item.get("rows_failed", 0), | |
| created_at=item.get("created_at"), | |
| )) | |
| evaluations.append( | |
| Evaluation( | |
| id=item["id"], | |
| name=item["name"], | |
| status=item["status"], | |
| dataset_id=item["dataset_id"], | |
| scorer_ids=item["scorer_ids"], | |
| target=item["target"], | |
| overall_scores=item.get("overall_scores"), | |
| rows_processed=item.get("rows_processed", 0), | |
| rows_failed=item.get("rows_failed", 0), | |
| created_at=item.get("created_at"), | |
| ) | |
| ) |
| assert "eval_logs" in meta | ||
| assert len(meta["eval_logs"]) == 1 | ||
| assert meta["eval_logs"][0]["message"] == "This output looks great" | ||
| assert meta["eval_logs"][0]["step"] == 11 # Step after log_metrics incremented it |
There was a problem hiding this comment.
[ruff-format] reported by reviewdog 🐶
| assert meta["eval_logs"][0]["step"] == 11 # Step after log_metrics incremented it | |
| assert ( | |
| meta["eval_logs"][0]["step"] == 11 | |
| ) # Step after log_metrics incremented it |
| with mock.patch("p95.client.P95Client") as mock_client_class, \ | ||
| mock.patch("p95.metrics.MetricsBatcher") as mock_batcher_class: | ||
|
|
There was a problem hiding this comment.
[ruff-format] reported by reviewdog 🐶
| with mock.patch("p95.client.P95Client") as mock_client_class, \ | |
| mock.patch("p95.metrics.MetricsBatcher") as mock_batcher_class: | |
| with ( | |
| mock.patch("p95.client.P95Client") as mock_client_class, | |
| mock.patch("p95.metrics.MetricsBatcher") as mock_batcher_class, | |
| ): |
| threading.Thread(target=log_evals, args=(10,)) | ||
| for _ in range(5) |
There was a problem hiding this comment.
[ruff-format] reported by reviewdog 🐶
| threading.Thread(target=log_evals, args=(10,)) | |
| for _ in range(5) | |
| threading.Thread(target=log_evals, args=(10,)) for _ in range(5) |
No description provided.