Spaces:
Running on T4
Running on T4
Download tests/test_deployment_sync.py from modventures/baseball-engine: direct link, hf CLI and curl.
- Browser
- Download file 1.29 kB
-
https://huggingface.co/spaces/modventures/baseball-engine/resolve/3249fe49e382459cd4ccd5ca1883f14ffd8b5ab4/tests/test_deployment_sync.py
- Command line
-
hf download hf://spaces/modventures/baseball-engine@3249fe49e382459cd4ccd5ca1883f14ffd8b5ab4/tests/test_deployment_sync.py
-
curl -L -o test_deployment_sync.py https://huggingface.co/spaces/modventures/baseball-engine/resolve/3249fe49e382459cd4ccd5ca1883f14ffd8b5ab4/tests/test_deployment_sync.py
1.29 kB
| """Exercise the deployment overlay with real files, including clone timestamp collisions.""" | |
| import os | |
| from pathlib import Path | |
| import shlex | |
| import shutil | |
| import subprocess | |
| import pytest | |
| def test_deployment_copies_same_size_changes_with_identical_timestamps(tmp_path): | |
| rsync = shutil.which('rsync') | |
| if not rsync: | |
| pytest.skip('rsync is required by the deployment runner') | |
| source, space = tmp_path/'source', tmp_path/'space' | |
| source.mkdir(); space.mkdir() | |
| new, old = source/'api.py', space/'api.py' | |
| new.write_text('version="1.7.1"\n'); old.write_text('version="1.7.0"\n') | |
| for file in (new, old): | |
| os.utime(file, (1700000000, 1700000000)) | |
| assert new.stat().st_size == old.stat().st_size | |
| # Space-only files must survive the overlay. | |
| retained = space/'space-only.txt' | |
| retained.write_text('keep') | |
| workflow = Path(__file__).parents[1]/'.github/workflows/deploy-huggingface.yml' | |
| command = next(line.strip() for line in workflow.read_text().splitlines() | |
| if line.strip().startswith('rsync ')) | |
| arguments = shlex.split(command) | |
| subprocess.run([rsync, *arguments[1:-2], str(source)+'/', str(space)+'/'], check=True) | |
| assert old.read_bytes() == new.read_bytes() | |
| assert retained.read_text() == 'keep' | |