Skip to content

FIX: Load an updated data file only when it was published later - #282

Draft
jwrosewell wants to merge 1 commit into
rcfrom
feature/update-published-date
Draft

jwrosewell wants to merge 1 commit into
rcfrom
feature/update-published-date

Conversation

@jwrosewell

@jwrosewell jwrosewell commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Closes #280.

Why

The data updates specification says, under newFileAvailable, that a watched or downloaded file that is not newer is not loaded, and that the check is reported as not needed. The update service did not read the date in the file, so an older data file copied into place, with a newer modification time, was loaded over newer data.

What changes

  • datafile_update_service.py and datafile.py in fiftyone_pipeline_engines: when a watched file changes or a download finishes, the service asks the data file's engine for get_date_published_from_file. Where the engine has it, the new file is loaded only when the published date in its header is a later day than the date of the data in use. Otherwise the engine keeps its data, the check is reported as AUTO_UPDATE_NOT_NEEDED, and the next check is scheduled as usual.
  • A download is written to the temporary copy, or beside the data file when no temporary copy is set, and compared before it replaces the data file. One that is not newer is deleted. Before the engine has loaded any data, a download is compared with the header of the file already on disk.
  • A header that cannot be read is reported as AUTO_UPDATE_UNKNOWN_ERROR. An engine without the method, a cloud engine for example, has its files loaded as before, and If-Modified-Since is sent as before.
  • DeviceDetectionOnPremise and IpIntelligenceOnPremise gain get_date_published_from_file, which calls the native getPublishedTimeFromFile of EngineHashSwig and EngineIpiSwig.
  • The watcher tests of both on-premise packages and both update examples expected a copy of the same file to be loaded again, and now expect AUTO_UPDATE_NOT_NEEDED.

Tests

  • tests/test_datafile_published_date.py (new) uses a stand-in engine, so it needs no native library. It covers a later, the same and an earlier published date, for a watched file and for a download, and an earlier file with a newer modification time. Those cases fail against rc's update service and pass here.
  • All 171 tests of fiftyone_pipeline_engines pass on Python 3.14 with pytest 9.2 and -W error, leaving out the pytest collection warning for TestCache in tests/test_engines.py that rc already gives.
  • Not run: the watcher tests and the update examples, which need the native method, and Python 3.10.

Before this leaves draft

Not ready to merge until these are done.

  1. FIX: Read a data file's published date in the C++ engines 51degrees-cxx#228, which adds getPublishedTimeFromFile, is in cxx rc, the cxx submodule moves to it, and the SWIG wrappers are generated again here. Until then the two engine methods fail, and every watched or downloaded file for those engines is reported as an error. The free-threaded Python jobs show this at 1f4e47f (run 45488870092): both test_watcher_without_licence_key.py tests get AUTO_UPDATE_UNKNOWN_ERROR, as EngineHashSwig and EngineIpiSwig have no getPublishedTimeFromFile yet, and every other test passes.
  2. The watcher tests of both on-premise packages and both update examples pass with the native method.
  3. The specification's "Automatic update from File" section says a watched file is used whatever its date, which disagrees with newFileAvailable. That section needs changing.
  4. Until the specification settles it, this differs from FIX: Load a watched or downloaded data file only when its data is newer 51degrees-dotnet#336 and FIX: Read published dates as midnight and skip files that are not newer 51degrees-java#242 in three cases. For a header that cannot be read, .NET and Java load the file and let the refresh fail, where this reports AUTO_UPDATE_UNKNOWN_ERROR and loads nothing. With no data loaded yet, .NET and Java load the file, where this compares a download with the file already at the data file path. For a header with no date, .NET never loads the file and Java loads it, where the native engines here raise an error. The errors table may need a row for a header that cannot be read, and the method needs one name across the languages.
  5. Dates are compared by the day, in UTC, as the header holds only a date, so two files published on the same day never replace each other.

When a watched file changes or a download finishes, the data update
service reads the published date in the new file's header, where the
engine offers get_date_published_from_file, and loads the file only
when that date is a later day than the data in use. A file that is not
newer is left alone and the check is reported as
AUTO_UPDATE_NOT_NEEDED. A download is compared before it replaces the
data file, and is deleted when it is not newer.

The Device Detection and IP Intelligence on-premise engines read the
date through the native getPublishedTimeFromFile. Their watcher tests
and update examples now expect a copy of the same file to be reported
as not needed.

Closes #280
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant