Zum Inhalt

Batch reassignment of the next module

batch_module_reassignment() is a Prefect flow in bookkeeping/bookkeeping_tools.py. It changes the next-module assignment of processing-file locations for one source and one or more pipelines. Use it when bookkeeping locations must be redirected from one module to another, for example after changing a pipeline configuration or replacing a module.

Warning: This flow changes the bookkeeping graph directly. Pause the affected processing deployments and verify every parameter before starting the run. A wrong source, pipeline, or module name can leave work assigned to an unintended or nonexistent agent IRI.

The flow is operated exclusively through its Prefect deployment. It is not intended to be started from a command line.

Parameters

Parameter Type Meaning
source string Source name known to BookkeepingHandler. It selects the source-specific bookkeeping graph and forms part of each pipeline IRI.
pipeline string or list of strings One pipeline identifier or a JSON list of pipeline identifiers. Use identifiers such as 2363-4715 or 2363-4715_inLTA, not full RDF IRIs.
old_module_name string Module name currently assigned through xkos:next. This assignment is removed from matching locations.
new_module_name string Module name that replaces old_module_name as the xkos:next assignment.

Module names are converted to their unversioned agent IRIs. Enter only the module name, not an agent IRI and not a module version.

Running the deployment in Prefect

Before starting the deployment:

  1. Pause or otherwise stop flows that can claim or update work in the affected pipelines. In particular, prevent the old and new modules from obtaining jobs while the reassignment is running.
  2. Confirm that source selects the intended bookkeeping environment and graph.
  3. Copy the pipeline and module names from the active configuration. The flow does not validate them against the pipeline configuration.
  4. Decide whether the operation concerns only the base pipeline or also an auxiliary pipeline such as _inLTA, _reconvert, or _reclassify. Auxiliary pipelines are not added automatically.

In the Prefect user interface, open the deployment for batch_module_reassignment, create a new run, and enter the four parameters.

For one pipeline, enter pipeline as a string, for example:

{
  "source": "copernicus",
  "pipeline": "2363-4715",
  "old_module_name": "old_module",
  "new_module_name": "new_module"
}

For several pipelines, enter pipeline as a JSON list. Do not enter a comma-separated string:

{
  "source": "copernicus",
  "pipeline": [
    "2363-4715",
    "2363-4715_inLTA",
    "2363-4715_reconvert"
  ],
  "old_module_name": "old_module",
  "new_module_name": "new_module"
}

Review the parameters in Prefect once more, then start the flow run. Keep the affected processing deployments paused until the run has completed and its result has been checked.

Selection and update rules

For each supplied pipeline identifier, the flow builds this source-specific pipeline IRI:

https://rdf.ulb.tu-darmstadt.de/wdm/pipeline/<source>/<pipeline>

It then selects locations that meet all three conditions:

  • the location has RDF type wdmvoc:NASProcessingFiles;
  • the location is linked to that exact pipeline through rico:hasOrHadController;
  • the location is assigned to the unversioned agent IRI for old_module_name through xkos:next.

For every matching location, the old xkos:next triple is deleted and a new one pointing to the agent IRI for new_module_name is inserted. The location's type, pipeline controller, previous-module assignment, flags, paths, files, and other metadata remain unchanged. The flow does not modify files on the filesystem and does not start the newly assigned module.

If pipeline contains a list, the flow performs a separate SPARQL update for each item in the given order. It does not infer related pipelines or combine the list into one graph operation.

Locations are not changed when they belong to another pipeline, have another RDF type, or no longer have the specified old assignment. A repeated run with the same parameters normally finds nothing to change because the old assignment has already been removed.

Result and verification

After each successful pipeline update, the Prefect log contains a message in this form:

Reassigned NAS processing-file locations in pipeline <pipeline> from <old_module_name> to <new_module_name>.

This message confirms that the update request completed; it does not report how many locations matched. A successful flow can therefore have changed zero locations. For a consequential reassignment, verify in the bookkeeping graph that:

  • no intended location in the selected pipeline still has old_module_name as xkos:next;
  • the intended locations now have new_module_name as xkos:next;
  • locations in pipelines outside the request were not changed.

Resume downstream deployments only after this verification.

Failure and recovery

Multiple pipelines are updated sequentially and the complete flow run is not transactional. If the update for a later pipeline fails, updates for earlier pipelines remain in the graph. Read the Prefect logs to identify the last successful pipeline, inspect the graph, and retry only the pipelines that still require reassignment.

The flow constructs agent IRIs from the supplied names but does not check that the names occur in the current workflow configuration or that the target agent has already been registered. Correct misspellings by running a new, deliberate reassignment from the erroneous name to the intended name after confirming the affected triples.