Stages

A Phlex job is usually one step of a larger processing workflow. For example, a simulation job writes generated events to a file, a digitization job reads that file and writes the simulated detector response, and a reconstruction job reads the digitized data and writes reconstructed objects. Each of these steps is a processing stage, and each Phlex job runs one stage. A job can therefore see products from several stages: products read from its input files, created by earlier stages, alongside the products it creates itself.

A stage name identifies the processing stage that created a data product. Examples of stage names include simulation, digitization, and reconstruction. Together with the creator, suffix, data layer and type, it is part of a product’s identity. It allows Phlex to distinguish between products that otherwise look the same but were created by different Phlex jobs, such as a hits product read from a simulation file and a hits product recomputed in the current job.

Choose a name that stays the same when an equivalent job is rerun. Timestamps, host names and batch-job IDs are poor stage names.

Naming the stage of a job

Every job must name its stage, either with the top-level stage key or with the --stage option, which takes precedence:

{
  stage: 'reconstruction',
  driver: { /* ... */ },
  modules: { /* ... */ },
}
phlex -c workflow.jsonnet --stage reconstruction

A job fails at startup if no stage is given, if it is empty, or if it is "CURRENT", which is reserved (see below). The stage requirement was introduced in Phlex v0.4.0; configurations written for earlier versions need a stage key added.

Stages of created products

Every product created by a transform, fold or unfold in the job carries the job’s stage.

Providers registered with PHLEX_REGISTER_PROVIDERS declare their product with output_product(creator, suffix, layer, stage). The stage argument defaults to "CURRENT", which Phlex replaces by the job’s stage name. A provider that reads products written by an earlier job can instead pass that job’s stage name, so that its products keep their original identity.

Implicit providers, which a phlex::source returns from create_providers(), must set provider_bundle::stage to a real stage name. Returning "CURRENT" is an error, because no substitution takes place for implicit providers.

Note

In Phlex v0.4 a phlex::source has no access to the job’s stage, so a source that creates new products, such as an event generator, must take the stage name from its own configuration. Whether sources should support the "CURRENT" stage name is under discussion in issue #957.

Selecting products by stage

product_selector has an optional stage field; in a configuration file a selector object accepts a stage key.

Not specified

Products of any stage match.

"CURRENT"

Only products of the job’s own stage match. Sources are the exception for now: the selector reaches create_providers() with the literal "CURRENT", which a source that checks candidates with selector.match(spec, layer, stage) will not match (see issue #957). To select a product that a source supplies, leave stage unspecified or name the stage explicitly.

Any other name

Only products of that stage match. If it is not the job’s own stage, Phlex looks for the product only among providers, because everything computed in the job carries the job’s stage.

m.transform("refit", refit, concurrency::unlimited)
  .input_family(product_selector{
    .creator = "tracks", .layer = "event", .stage = "reconstruction"});

Selectors written in Python cannot set stage yet.

An algorithm that takes a phlex::handle<T> can read the stage of the product it received with handle::stage().