Repository navigation
docs: document processing stages #1031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| Stages | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @matclim We may want to explain what a stage is before getting into details about the stage name. For example, discuss how a Phlex execution happens in the context of workflow consisting of multiple stages.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added an opening paragraph that places a stage in a multi-stage workflow before talking about stage names. I kept it short, since #1083 will settle the full definition |
||
| ====== | ||
|
|
||
| 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: | ||
|
|
||
| .. code-block:: jsonnet | ||
|
|
||
| { | ||
| stage: 'reconstruction', | ||
| driver: { /* ... */ }, | ||
| modules: { /* ... */ }, | ||
| } | ||
|
|
||
| .. code-block:: console | ||
|
|
||
| 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 <https://github.com/Framework-R-D/phlex/issues/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. | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you check if this is correct? When allowed,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had a look at the code: it’s correct as current behaviour, though it (probably) isn’t the intended design. For explicit providers and for products created in the job, "CURRENT" is replaced by the job’s stage (make_computational_edges.cpp l40, producer_catalog.cpp l34). Sources, though, receive the selector unchanged in create_providers(), so a source comparing against its own stage never matches the literal "CURRENT". I’ve marked this as an exception for now am now pointing to #957. |
||
| 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. | ||
|
|
||
| .. code-block:: cpp | ||
|
|
||
| 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()``. | ||
Uh oh!
There was an error while loading. Please reload this page.