Spaces:
Sleeping
Sleeping
Download tests/test_deployment.py from xstard/decision-model: direct link, hf CLI and curl.
- Browser
- Download file 2.05 kB
-
https://huggingface.co/spaces/xstard/decision-model/resolve/main/tests/test_deployment.py
- Command line
-
hf download hf://spaces/xstard/decision-model/tests/test_deployment.py
-
curl -L -o test_deployment.py https://huggingface.co/spaces/xstard/decision-model/resolve/main/tests/test_deployment.py
2.05 kB
| import zipfile | |
| import pytest | |
| from decision_model.deployment import source_files, package_source, validate_target | |
| def test_source_archive_never_includes_secrets_caches_or_private_data(tmp_path): | |
| for name in ['README.md', 'LICENSE', 'app.py', 'Dockerfile', '.env.example', 'requirements.txt', 'requirements-dev.txt', 'pyproject.toml', '.gitignore', '.dockerignore']: | |
| (tmp_path / name).write_text('public', encoding='utf-8') | |
| for directory in ['src/decision_model', 'data/generated', 'artifacts', '.venv', 'docs', 'data/examples']: | |
| (tmp_path / directory).mkdir(parents=True, exist_ok=True) | |
| for name in ['.env', 'data/generated/tickets.jsonl', 'artifacts/key.txt', '.venv/private.py']: | |
| (tmp_path / name).write_text('SENSITIVE_TEST_VALUE') | |
| (tmp_path / 'docs/PROGRESS.md').write_text('SENSITIVE_TEST_VALUE') | |
| (tmp_path / 'src/decision_model/__init__.py').write_text('') | |
| (tmp_path / 'data/examples/tickets.jsonl').write_text('public') | |
| archive = package_source(tmp_path) | |
| with zipfile.ZipFile(archive) as z: | |
| assert '.env' not in z.namelist() | |
| assert 'data/examples/tickets.jsonl' in z.namelist() | |
| assert not any(b'SENSITIVE_TEST_VALUE' in z.read(name) for name in z.namelist()) | |
| def test_deployment_target_is_the_authorized_account_and_project(): | |
| validate_target('xstard/decision-model', 'xstard') | |
| with pytest.raises(ValueError): | |
| validate_target('someone/decision-model', 'someone') | |
| def test_v11_update_requires_measured_improvement_over_v1(): | |
| from decision_model.deployment import check_publishable | |
| checks=dict.fromkeys(['calibration_min_groups','test_min_groups','calibration_review','test_review', | |
| 'train_stratified_review','split_disjointness','demo_class_coverage'],True) | |
| result={'stage':'evaluated','evidence_complete':True,'release_checks':checks,'experimental':True} | |
| with pytest.raises(ValueError,match='покращ|comparison'): | |
| check_publishable({'stage':'evaluated','model_version':'decision-1.1.0'},result,True) | |