Metadata-Version: 2.1
Name: caliper-reader
Version: 0.4.1
Summary: A Python library for reading Caliper .cali files
Author-email: David Boehme <boehme3@llnl.gov>
License: Copyright (c) 2015-2021, Lawrence Livermore National Security, LLC.
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        * Redistributions of source code must retain the above copyright notice, this
          list of conditions and the following disclaimer.
        
        * Redistributions in binary form must reproduce the above copyright notice,
          this list of conditions and the following disclaimer in the documentation
          and/or other materials provided with the distribution.
        
        * Neither the name of the copyright holder nor the names of its
          contributors may be used to endorse or promote products derived from
          this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Project-URL: Homepage, https://github.com/LLNL/Caliper
Classifier: Programming Language :: Python :: 3
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE

caliper-reader: A Python reader for Caliper files
=================================================

This Python package reads the native .cali files produced by the
[Caliper](https://github.com/LLNL/Caliper) performance profiling
library.

You can install caliper-reader with pip:

    $ pip install caliper-reader

Alternatively, add the `python/caliper-reader` path in the cloned
Caliper repository to `PYTHONPATH`.

Usage
---------------------------------------

The `CaliperReader` class reads a Caliper file and then provides its
contents in the `records` and `globals` class members, where `records`
is a Python list-of-dicts containing the recorded performance data
and `globals` is a Python dict with program metadata about the run.
The dicts represent Caliper attribute:value records: the key is the
Caliper attribute name; the value is a string or list of strings.
The example below prints the `avg#inclusive#sum#time.duration` metric
for every region path in the provided example profile data file:

```Python
import caliperreader as cr

r = cr.CaliperReader()
r.read('example-profile.cali')

metric = 'avg#inclusive#sum#time.duration'

for rec in r.records:
    path = rec['path'] if 'path' in rec else 'UNKNOWN'
    time = rec[metric] if metric in rec else '0'

    if (isinstance(path, list)):
        path = "/".join(path)

    print("{0}: {1}".format(path, time))
```

The CaliperReader `attributes()` function returns the list of Caliper
attributes. The `attribute()` function returns an `Attribute` object
to query metadata for a given Caliper attribute name:

```Python
>>> a = r.attribute('avg#inclusive#sum#time.duration')
>>> a.get('attribute.unit')
'sec'
```

You can use the `read_caliper_contents` function as a shortcut to read
Caliper data without creating a `CaliperReader` object:

```Python
(records,globals) = cr.read_caliper_contents('example-profile.cali')
```

Use `read_caliper_globals` if you only need the global (metadata) record:

```Python
globals = cr.read_caliper_globals('example-profile.cali')
```

Authors
---------------------------------------

Caliper was created by [David Boehme](https://github.com/daboehme), boehme3@llnl.gov.

Release
-------------------------------------

Caliper is released under a BSD 3-clause license.
See [LICENSE](LICENSE) for details.

``LLNL-CODE-678900``
