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

Document guarantees about the stability of the CLI output #291

Open
scarlehoff opened this issue Jun 2, 2024 · 1 comment
Open

Document guarantees about the stability of the CLI output #291

scarlehoff opened this issue Jun 2, 2024 · 1 comment
Labels
question Further information is requested
Milestone

Comments

@scarlehoff
Copy link
Member

scarlehoff commented Jun 2, 2024

The PineaAPPL cli is much faster than e.g., the python interface. As a result, sometimes it is quite convenient to use it and then parse the results.

I'm currently parsing the cli instead of using convolute_with_one (with or without scales). This seems to work in most (all?) cases. Can I trust this output to be constant in time? If now, can we have some kind of --stable-output that will be stable in time?

At the moment my assumptions for uncert and convolve are:

  1. The three first lines are part of the header.
  2. The results are always the last columns and there's nothing beyond.

For reference, this is the code I'm using:

# before 0.74 you need to add `--silence-lhapdf`
def _convolute_with_pineappl_cli(grid_path, pdf_name, member):
    """Use the pineappl cli to compute the convolution of the grid with the given pdf

    Equivalent to:
        pineappl convolve <grid_path> <pdf>
    """
    cmd = ["pineappl", "convolve", grid_path, f"{pdf_name}/{member}"]
    result_raw = sp.run(cmd, stdout=sp.PIPE)
    results = result_raw.stdout.decode("utf-8").strip()
    predictions = [line.split()[-1] for line in results.split("\n")[3:]]
    return np.array(predictions, dtype=float)


def _scales_with_pineappl_cli(grid_path, pdf_name, n_scales):
    """Use the pineappl cli to compute the scale uncertainties for the grid

    Equivalent to:
        pineappl uncert <grid_path> <pdf> --scale-abs=9
    """
    cmd = ["pineappl", "uncert", grid_path, pdf_name, f"--scale-abs={n_scales}"]
    result_raw = sp.run(cmd, stdout=sp.PIPE)
    results = result_raw.stdout.decode("utf-8").strip()
    predictions = [line.split()[-n_scales:] for line in results.split("\n")[3:]]
    return np.array(predictions, dtype=float)
@scarlehoff scarlehoff added the question Further information is requested label Jun 2, 2024
@cschwan
Copy link
Contributor

cschwan commented Jun 2, 2024

It's not guaranteed to be stable, but so far the changes have been minimal between versions.

I'm thinking of making the output stable at some point and furthermore prefixing each line that's not data with # so you can simply parse the output as an ascii table.

Of course, the real issue here is that the Python interface is slower.

@cschwan cschwan changed the title Is the pineappl cli printout a stable well defined output? Is the CLI's stdout stable? Jun 2, 2024
@cschwan cschwan changed the title Is the CLI's stdout stable? Document guarantees about the stability of the CLI output Jun 24, 2024
@cschwan cschwan added this to the v1.0 milestone Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants