reanahub / reana-client

REANA command-line client
http://reana-client.readthedocs.io/
MIT License
10 stars 46 forks source link

cli: quota-show human-readable flag behaviour #575

Closed tiborsimko closed 2 years ago

tiborsimko commented 2 years ago

Current behaviour

The human-readable flag has no effect:

$ reana-client quota-show --resource disk                  
1.5 MiB used 
$ reana-client quota-show --resource disk -h              
1.5 MiB used 

Expected behaviour

The values should be more exact, aka machine-friendly without -h flag, and human-friendly with -h flag, for example:

$ reana-client quota-show --resource disk
1577259 bytes used
$ reana-client quota-show --resource disk -h              
1.5 MiB used 

Following df and df -h example.

mvidalgarcia commented 2 years ago

It looks like this was a pre-meditated decision. To get machine-friendly values one can use the --report flag.

tiborsimko commented 2 years ago

I think we should change it, because it looks as if the -h option is currently not doing anything. Moreover, we are loosing the analogy with du -h. I guess we have basically two options:

  1. If we'd like to retain the -h option, then the default output behaviour should be raw units, and -h would switch on the human-readable mode, so to speak, for all command reporting options and all CPU and Disk resource types.

  2. If we'd like to retain printing human-readable values by default, then we should remove the -h option, and rather introduce a new --raw option to display raw units.

Basically, either raw output or human output should be "on demand", but not once this one that, for consistency's sake.

P.S. The former alternative retains the analogy with du -h, so I guess I'd favour that one...

mvidalgarcia commented 2 years ago

Assuming we want to go for option 1., would it be ok to print just an integer for the raw output? E.g.

$ reana-client quota-show --resource disk
1577259
$ reana-client quota-show --resource disk -h              
1.5 MiB used 

Otherwise, I think we'll have issues getting the basic unit string, i.e. bytes, as for other resources it'd different. Trying to avoid harcoded strings here.

tiborsimko commented 2 years ago

Yes, printing raw numbers is OK. This will be exactly like reana-client du -w myworkflow, so nicely consistent.