Zum Inhalt

Test-only pipeline restart

Warning: bookkeeping_pipeline_restarter() is intended exclusively for tests with test data and a test bookkeeping graph. Do not run it against a productive environment. It retains the existing bookkeeping resources as restart artifacts, and every restarted processing run adds another generation of resources. Repeated use therefore bloats the graph. It can also permanently delete the journal's processing files when delete_files=True.

bookkeeping_pipeline_restarter() is a Prefect flow in bookkeeping/bookkeeping_tools.py. It prepares one journal pipeline to be processed again during tests. It does not start the harvesting pipeline itself.

The restart consists of two separate operations:

  1. Existing processing-file locations in the bookkeeping graph are retyped so that they are no longer treated as the pipeline's current wdmvoc:NASProcessingFiles locations.
  2. The journal directory below the processing-data root is either renamed for later manual deletion or removed immediately.

The next test run can consequently create fresh processing state for the journal without confusing the previous processing locations with the current ones.

Parameters

bookkeeping_pipeline_restarter(source, issn, delete_files=False)
Parameter Meaning
source Source name used by BookkeepingHandler, for example copernicus. It determines the source-specific pipeline IRIs and must exist in the bookkeeping configuration. Use a source connected to a test graph.
issn Base pipeline identifier and journal-directory name, normally the journal's ISSN, for example 2363-4715.
delete_files When False (the default), preserve the journal directory by renaming it. When True, recursively and permanently delete it.

How to run it

Before running the flow:

  • stop any flows that could read from or write to the selected journal;
  • verify that the bookkeeping configuration for source points to the correct test graph (should be the case unless something was changed for tests on the bookkeeping system itself)

Then run the flow from the respective prefect deployment with the source and journal's ISSN as parameters. It's safer to input false for the delete_files parameter and just have the journal folder renamed. Currently, the deployment on wdm-test is https://wdm-test.ulb.tu-darmstadt.de/v2/deployments/deployment/e8e74b73-a24f-4db2-aa32-95ae06f064f7?tab=Runs.

What changes in the bookkeeping graph

For the selected source, the flow processes these four pipeline IDs:

  • <issn>
  • <issn>_inLTA
  • <issn>_reconvert
  • <issn>_reclassify

For each pipeline, every location that is both controlled by that pipeline and typed as wdmvoc:NASProcessingFiles is changed to type wdmvoc:NASProcessingFilesRestartArtefact. The SPARQL update removes only the old RDF type statement and inserts the restart-artifact type statement. The location resource and its other triples remain in the graph.

After all four updates, the flow logs that it has finished retyping the journal's NAS processing-file locations and that the pipelines can now be restarted. This message describes a retyping operation, not deletion: the information is retained but excluded from operations that select current wdmvoc:NASProcessingFiles locations. It is not archived or cleaned up by this flow.

Each later test run creates new bookkeeping resources and provenance. Repeating the restart therefore leaves old restart artifacts alongside each new generation and progressively enlarges the graph. This behavior is acceptable only in a disposable or deliberately maintained test graph. It is the reason this mechanism must not be used in productive environments.

What changes on the filesystem

The journal directory is resolved through get_journal_dir_path(issn), normally as:

<WDM_DATA_ROOT_TEMP>/Automatische_Prozessierung/<issn>

With the default delete_files=False, the directory is moved by renaming it to a sibling path with a UTC timestamp:

<issn>-save_to_delete_YYYYMMDD_HHMMSS_utc

For example:

2363-4715-save_to_delete_20260916_142530_utc

This is a rename, not a copy. The saved directory is not removed automatically; inspect it if necessary and delete it according to the normal test-data cleanup procedure.

With delete_files=True, shutil.rmtree() recursively removes the journal directory and all content below it. This cannot be undone by the restarter.

Failure and recovery considerations

The graph update happens before the filesystem rename or deletion, and the two operations are not transactional. For example, if the journal directory does not exist, cannot be renamed, or cannot be deleted, the flow raises an exception only after the matching graph locations have already been retyped. Check both the graph and filesystem after a failed run before retrying.

The flow also does not check whether another process is using the journal, whether the selected graph is productive, or whether the selected files are test data. These checks are the operator's responsibility.

Safe-use checklist

  • Use only a test source, test graph, and test filesystem root.
  • Use only disposable test data.
  • Stop concurrent processing for the journal.
  • Prefer the default delete_files=False so the directory can be inspected or recovered manually.
  • Confirm the renamed or deleted directory and the four affected pipeline IDs in the Prefect logs.
  • Do not use the mechanism as routine cleanup and do not use it in production; it accumulates restart artifacts and bloats the graph.