ProcessFileService¶
Handles image processing workflow.
backend.services.process_file_service.ProcessFileService ¶
Service responsible for: - Identifying files that are ready to be processed - processing files - updating lifecycle states - managing processing retries
get_files_by_observation_and_status ¶
get_files_by_observation_and_status(instrument, status, observation_start_utc, observation_end_utc, limit, offset)
Returns list of file domain entities of a particular state, for a given observation time period and instrument
:param instrument: Instrument used for observation :param state: State of the file :param observation_start_utc: observation start time :param observation_end_utc: observation end time :return: list of processedfile domain entities
mark_ready_files_for_processing ¶
mark_ready_files_for_processing(instrument, observation_start_utc, observation_end_utc, cancel_event)
Goes through all the files for a given observation time period and instrument,
updates relevant files' status as READY.
:param instrument: Instrument used for observation
:param observation_start_utc: starting utc timestamp of observation
:param observation_end_utc: ending utc timestamp of observation
:return: Number of files which are updated to READY
process_pending_files ¶
process_pending_files(instrument, observation_start_utc, observation_end_utc, cancel_event)
Entry workflow for processing eligible files.
:param instrument: Instrument used for observation :param observation_start_utc: starting utc timestamp of observation :param observation_end_utc: ending utc timestamp of observation :return: returns number of files processed
recover_stale_files ¶
recover_stale_files(now_utc, instrument)
Recovers files stuck in intermediate states PROCESSING
by marking them as failed if they exceed allowed timeout.
:param now_utc: current UTC timestamp :return: number of files recovered.
recover_unmarked_ready_files ¶
recover_unmarked_ready_files(instrument, observation_start_utc, observation_end_utc)
Recovers files that are in DOWNLOADED state but were not marked as READY due to missed or skipped execution of the pairing logic.
This method re-applies the READY-marking algorithm over the given observation window (with internal lookback buffer), ensuring that any eligible files are transitioned to READY.
It is idempotent: - Files already in READY/PROCESSED are not modified - Only valid transitions are applied
Intended usage: - After crashes - After logic changes - As a periodic consistency check in the pipeline
:param instrument: Instrument used for observation :param observation_start_utc: Start of observation window (UTC) :param observation_end_utc: End of observation window (UTC) :return: Number of files transitioned to READY