Spaces:
Runtime error
Runtime error
Download tests/conftest.py from vishnu-coder/twitter-sentiment-app: direct link, hf CLI and curl.
- Browser
- Download file 828 Bytes
-
https://huggingface.co/spaces/vishnu-coder/twitter-sentiment-app/resolve/main/tests/conftest.py
- Command line
-
hf download hf://spaces/vishnu-coder/twitter-sentiment-app/tests/conftest.py
-
curl -L -o conftest.py https://huggingface.co/spaces/vishnu-coder/twitter-sentiment-app/resolve/main/tests/conftest.py
828 Bytes
| from __future__ import annotations | |
| import sys | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| SRC = ROOT / "src" | |
| if str(SRC) not in sys.path: | |
| sys.path.insert(0, str(SRC)) | |
| import pytest | |
| from twitter_sentiment.config import load_config | |
| from twitter_sentiment.modeling import persist_artifacts, train_and_evaluate | |
| def ensure_artifacts(): | |
| """Train and persist the pipeline if artifacts are absent.""" | |
| config = load_config() | |
| artifact_dir = Path(config.model.get("artifact_dir", "artifacts")) | |
| artifact_path = artifact_dir / config.model.get("pipeline_filename", "sentiment_pipeline.joblib") | |
| if artifact_path.exists(): | |
| return | |
| pipeline, metrics = train_and_evaluate(config) | |
| persist_artifacts(pipeline, config, metrics) | |