Skip to content

Latest commit

 

History

History
125 lines (91 loc) · 3.07 KB

README.md

File metadata and controls

125 lines (91 loc) · 3.07 KB

Phlex examples

This repository contains examples of the use of the Phlex framework.

Building this repository

To use the code in this repository, first install it:

git clone -b phlex-v0.4 https://github.com/Framework-R-D/phlex-examples.git

Now create a build directory:

mkdir build-phlex-examples
cd build-phlex-examples

The repository can now be easily built by activating the environment you created when installing Phlex:

spack env activate my-phlex-environment
spack load gcc@15 cmake  # adjust if you used a different compiler for phlex
cmake ../phlex-examples
make -j 12  # choose a suitable number of jobs for your machine

Running the code

Add your build directory to PHLEX_PLUGIN_PATH

# Make sure you do this from your build directory
export PHLEX_PLUGIN_PATH=${PWD}:${PHLEX_PLUGIN_PATH}

You should now be able to run a simple phlex job:

Job with C++ algorithms

phlex -c ../phlex-examples/test-cpp-workflow.jsonnet

The output should look like:

Using configuration file: ../phlex-examples/test-cpp-workflow.jsonnet
[2025-12-22 13:17:51.496] [info] Number of worker threads: 24
Registering FORM output module...
Configuration:
  output_file: output.root
  technology: ROOT_TTREE
FormOutputModule initialized
⋮
[2025-12-22 13:17:51.760] [info]
Processed layers:

  job
   │
   └ spill: 10

[2025-12-22 13:17:51.760] [info] CPU time: 0.21204s  Real time: 0.26498s
  CPU efficiency: 80.02%
[2025-12-22 13:17:51.760] [info] Max. RSS: 268.848 MB

Job with an unfold

To run a job that demonstrates the unfold higher-order function — splitting a parent-layer product into a child layer of data cells — use:

phlex -c ../phlex-examples/test-cpp-unfold-workflow.jsonnet

The source provides a std::vector<int> per spill, the unfold emits one int per element on a child number layer, a transform squares each value, and an observer asserts the result. The output should look like:

[info]
Processed layers:

  job
   │
   └ spill: 5
      │
      └ number: 15

[info] CPU time: ...

number: 15 is 3 elements × 5 spills.

Job with Python algorithms

To run a job that uses a Python algorithm, the PYTHONPATH environment variable must be adjusted to include the directory with the Python module:

export PYTHONPATH=$(realpath ../phlex-examples):${PYTHONPATH}
phlex -c ../phlex-examples/test-py-workflow.jsonnet

The output should look like:

Using configuration file: ../phlex-examples/test-py-workflow.jsonnet
[2025-12-22 13:50:07.999] [info] Number of worker threads: 24
[2025-12-22 13:50:08.013] [info]
Processed layers:

  job

[2025-12-22 13:50:08.013] [info] CPU time: 0.01022s  Real time: 0.01483s
  CPU efficiency: 68.91%
[2025-12-22 13:50:08.013] [info] Max. RSS: 29.628 MB

Note

For Phlex v0.4.3, Python data products cannot be written to output files.