Skip to content
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

Documentation: Added documentation for custom columns #225

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions docs/dfanalyzer_custom_columns.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
===========================================
Custom Columns Derived from DFTracer
===========================================

This section describes how to derive custom columns for a DFAnalyzer data framework from DFTracer events using a custom function and load specific fields.

Example: Custom Workflow Columns
================================

We can define custom columns in `DFAnalyzer` by specifying a function that extracts the desired fields from the `json_object` and then loading those fields with their corresponding types.

Below is an example of how to define a custom function to derive columns from a Pegasus Montage workflow trace:

.. code-block:: python

def wf_cols_function(json_object, current_dict, time_approximate, condition_fn, load_data):
d = {}
if "args" in json_object:
if "size" in json_object["args"]:
d["size"] = int(json_object["args"]["size"])
if "ret" in json_object["args"]:
d["ret"] = int(json_object["args"]["ret"])
return d

load_cols_wf = {'size': "int64[pyarrow]", 'ret': "int64[pyarrow]"}

Next, use this function in `DFAnalyzer` to load traces with the custom columns (here is an example of loading Montage traces):

.. code-block:: python

from dfanalyzer import DFAnalyzer

analyzer = DFAnalyzer(
"/path/to/montage-*-preload.pfw.gz",
load_fn=wf_cols_function,
load_cols=load_cols_wf
)

Here, the custom columns `size`, `ret`, and `cmd` are loaded into the `DFAnalyzer` using the `wf_cols_function`.

You can modify the function and column types to match the fields relevant to your workload.
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ DFTracer: is a library for profiling I/O calls and application functions.
dfanalyzer_conf
dfanalyzer_alcf_polaris
dfanalyzer_overlap_analysis
dfanalyzer_custom_columns

.. toctree::
:maxdepth: 2
Expand Down
Loading