quantlab.utils.watermark.write_watermark#
- quantlab.utils.watermark.write_watermark(path, through, labels=None)[source]#
Write a dated watermark reaching
throughtopathatomically.The file holds
labelsandthrough,indent=2with sorted keys. It is written to a temporary file and renamed into place, so an interrupted write leaves the previous watermark.- Parameters:
- pathstr or Path
The watermark file.
- throughdate
The day the data is complete through.
- labelsMapping[str, str] or None, default None
What the watermark is of (for example
{"name": "prices"}).
- Raises:
- ValueError
If
labelsholdsthrough.
Examples
>>> import tempfile >>> from pathlib import Path >>> path = Path(tempfile.mkdtemp()) / WATERMARK_FILE >>> write_watermark(path, date(2024, 3, 14), {"name": "events", "field": "updated"}) >>> json.loads(path.read_text()) {'field': 'updated', 'name': 'events', 'through': '2024-03-14'}