NNPDF / pineappl

PineAPPL is not an extension of APPLgrid
https://nnpdf.github.io/pineappl/
GNU General Public License v3.0
12 stars 3 forks source link

Provide CLI subcommands to determine if a grid is also an FK table #188

Closed cschwan closed 1 year ago

cschwan commented 1 year ago

Right now it's not possible to figure out if a grid is also an FK table.

alecandido commented 1 year ago

Indeed, this is what I was thinking about. However, at the moment for a grid I obtain:

❯ pineappl obl --orders LHCB_DY_13TEV_DIELECTRON.pineappl.lz4
o      order
-+----------------
0 O(a^2)
1 O(a^3)
2 O(a^3 lr^1)
3 O(a^3 lf^1)
4 O(as^1 a^2)
5 O(as^1 a^2 lr^1)
6 O(as^1 a^2 lf^1)

while for an FkTable I get:

❯ pineappl obl --orders LHCB_DY_13TEV_DIELECTRON.pineappl.lz4
o order
-+-----
0 O()

It is true that for grids the output can be quite different, but FkTables are always giving that output, and no actual grid will have no dependency on $\alpha$ / $\alpha_s$. So it is a clear signature.

However, a dedicated command might be more user friendly, since in the structure is even more unambiguously written (it is an FkTable instance wrapping a Grid).

cschwan commented 1 year ago

However, a dedicated command might be more user friendly, [..].

That's the idea!

cschwan commented 1 year ago

It is true that for grids the output can be quite different, but FkTables are always giving that output, and no actual grid will have no dependency on α / αs. So it is a clear signature.

That's unfortunately not true, if you convert a DY LO APPLgrid, for instance, without explicitly giving the coupling order it will look like an FK table by that definition (but it is not).

alecandido commented 1 year ago

Candidates:

alecandido commented 1 year ago

However, given that for the external user an FkTable has to look like a PineAPPL grid, we can also promote the extension .fk.pineappl.lz4, in the same spirit of .pineappl.lz4:

cschwan commented 1 year ago

As far as it concerns PineAPPL you can name the FK tables (every grid in fact) as you like!

alecandido commented 1 year ago

As far as it concerns PineAPPL you can name the FK tables (every grid in fact) as you like!

Also PineAPPL grids you can name as you wish, but you have been successful in promoting the .pineappl.lz4. It is also nice to have them clearly recognizable from the file name, even though it is a disjoint thing from the checking command (since a name is directly there, but can lie)

cschwan commented 1 year ago

A first implementation of this is now available with commit f7e3994dcc2835e591845563c456086ec924ae02. Let me know if/how the output can be improved (I'm sure it can).

alecandido commented 1 year ago

I would rather exit with an error if it's false. Is not this the standard convention for Bash?

cschwan commented 1 year ago

I thought about that and I'd prefer that approach, but I see at least two problems:

  1. We must to distinguish between three statuses: 1) YES, 2) NO and 3) ERROR (for instance the given file wasn't found). That I think makes the use over some output printed to stdout questionable
  2. We probably have to use ExitCode, which is only available since Rust 1.61.0 (larger than our current MSRV)
alecandido commented 1 year ago

I know it might not be elegant, but what about a simple exit?

I believe we don't need any destructor for this command. We are always in time to improve when we'll drop support for older versions of Rust.

cschwan commented 1 year ago

Commits 3c8892db5d556080513b3e1f0fd430115e29e917 and 9ff6440e7d9803c6a41c99af1a12b3216bf6c873 add support for exit codes. You can now use

pineappl obl --fktable <grid> >/dev/null && echo "This is an FK table"