Zum Inhalt

frontiers_delete_stop_folders

Overview

The frontiers_delete_stop_folders module is a manually-invoked companion utility for the frontiers module. It exists because frontiers marks an article's previous module (validate_metadata) as processed unconditionally. As a result, stopped articles are not automatically retried on the next frontiers run. This module restores the article to a retryable state by reverting that marker.

Because frontiers doesn't leave stopped articles retryable, this module restores them by:

  1. Locating each article's stop-processing-frontiers_<date> folder.
  2. Finding the pristine copy of the original validate_metadata_<date> folder that frontiers preserved as a nested subfolder inside the stop folder (via copy_content_from_previous_module_into_subfolder) before renaming to stop-processing-....
  3. Deleting the article's current validate_metadata_<date> folder — the one frontiers emptied and marked "processed", and replacing it with the pristine nested copy, which carries no such marker.
  4. Deleting the now-fully-reconciled stop folder.

Once this runs, is_previous_module_updated will report True again for the affected articles on the next frontiers run, since the "processed" indicator has been removed along with the folder it was written into.

This module must be run explicitly, with an ISSN list supplied by the caller — it does not use the standard config-context (get_module_context) journal selection used by pipeline modules. It is meant to be triggered manually (or via a separate scheduled maintenance job) after frontiers stop folders have accumulated for a set of journals (not as a regular part of the per-article pipeline).

The module contains a single Python file:

  1. flow.py

flow.py

This file defines both the flow and all of its logic for restoring Frontiers stop-processing folders, using the Prefect library and prefect's get_run_logger.

frontiers()

  • Required Parameters:

  • list_of_issns (list): ISSNs whose stop-processing folders should be reconciled. No default.

  • test_copy (bool): Flag to indicate if it is a test run. Default is False

  • Context for Use:

  • This function is the main entry point. For each ISSN in list_of_issns, it scans every article directory for a subfolder whose name both starts with the stop-processing indicator and contains "frontiers" in its path (i.e. a stop-processing-frontiers_<date> folder). If found, it walks that folder's contents looking for a nested subfolder whose name starts with "validate_metadata"; when one is found, it's copied out to sit alongside the stop folder (replacing whatever currently occupies that location), and the entire stop folder is then deleted. If no validate_metadata* subfolder was found inside the stop folder, nothing is deleted and a log message notes this. After processing all articles for all given ISSNs, the module also reads the module's persistent error CSV log and removes every row whose issn is one of the ISSNs just processed.

  • Example Usage:

  • python frontiers(['2813-4168', '2813-0464'], test_copy=False)

  • Example Output:

  • INFO: Path to log file: /mnt/.../logs/frontiers_delete_stop_folders/....log INFO: Module name: frontiers_delete_stop_folders INFO: Set base path to: /mnt/.../wdm-test INFO: copied: /mnt/.../stop-processing-frontiers_2025-01-17/validate_metadata_2025-01-17 -> /mnt/.../validate_metadata_2025-01-17 INFO: deleted the following folder: /mnt/.../stop-processing-frontiers_2025-01-17

    When no restorable `validate_metadata*` folder was found inside a stop folder:
    
    INFO: did not delete (no validate_metadata* copied): /mnt/.../stop-processing-frontiers_2025-01-17