Open zihlmann opened 2 months ago
to be a little more specific about the differnences observed between "ccdb cat" and "ccdb dump" the "cat" part does not print a comment line first while the "dump" part does and in the "dump" part the option "-nc" does not work. So "ccdb cat" and "ccdb cat -nc" give the same result. Example here:
[zihlmann@ifarm2401 hdds]$ ccdb cat /TOF2/base_time_offset:120000
+-------------------------------------------------+
| TOF_BASE_TIME_OFFSET | TOF_TDC_BASE_TIME_OFFSET |
| double | double |
+-------------------------------------------------+
| -130.0 | -180.0 |
+-------------------------------------------------+
[zihlmann@ifarm2401 hdds]$ ccdb cat -nc /TOF2/base_time_offset:120000
+-------------------------------------------------+
| TOF_BASE_TIME_OFFSET | TOF_TDC_BASE_TIME_OFFSET |
| double | double |
+-------------------------------------------------+
| -130.0 | -180.0 |
+-------------------------------------------------+
[zihlmann@ifarm2401 hdds]$ ccdb dump /TOF2/base_time_offset:120000
#
-130.0 -180.0
[zihlmann@ifarm2401 hdds]$ ccdb dump -n /TOF2/base_time_offset:120000
ambiguous option: -n could match -nb, -nh, -nc
Lets start with the simple part.
dump
is an alias to cat
. Dump code is dumb:
return "cat --no-borders --no-header --comments --time --horizontal " + " ".join(args)
So you can experiment with cat as that is where things are happening. I also should say, that cat
has two modes to present data - horizontal or tables and vertical. Vertical is convenient when you have lots of columns and one row, i.e. name values.
--comments
and --no-comments
contradict each other and one of them is definitely is the cat
command default. That is why "ccdb cat" and "ccdb cat -nc" gives the same result. But both --comments
and --no-comments
exist even if one is default => putting this flag does nothing. The reason is to make it possible to leave a clear intent when writing code and later reading commands (in scripts). Like, imagine you open 10 years old bash file and see there cat --no-comment
or cat --comment
and you understand what you want here without any need to know what the default. Contrary to that if I see cat ...
, I have no idea, are there comments by default or not, or will there be borders or not, etc. I wrote this bloody command myself and I don't remember a clue now.
So "ccdb cat" and "ccdb cat -nc" are the same as -nc
is default. And dump gives errors as dump is cat --commnets
and then you add --no-comment
and get cat --comment --no-comment
and two flags contradict each other. Well one would probably could change the code to make the latest flag to be correct, but default python arg parsing library treat it as error by default.
Then I dove into the rabbit hole and propose you to jump with me. So there are two level of comments: type_table comments and assignment comments. When you create a type_table you can set a comment or description. And you can introspect that comment with info
command. Like:
ccdb info /TOF2/base_time_offset
But then there is also assignment comments. Each data assignment has its own comment just in case. One introspects assignments with two commands cat
and vers
. So cat
prints that assignment comments. Well... it probably should have a flag to write a table level comment too, but it is not implemented probably because noone asked for it.
Then...
ccdb vers /TOF2/base_time_offset
Basically kills you as it has 600k assignments slowly reading and displaying on screen. It is possible to specify the run with -r
flag:
ccdb vers -r 120000 /TOF2/base_time_offset
Doesn't help much as a lot of assignments added with x-inf
run range like 99123-inf which means that run 120000 falls into this range. And there are still hundred of thousands of such assignments. Maybe it is a good idea, to go over such assignment and set a finishing run as end of run-period. Still the last one:
462488 2023-01-15 09-39-31 2023-01-15 09-39-31 default 120000-129999
Has no comment.
ccdb
also has --no-color
flag in case ESC[32m|ESC[0mESC[34mESC[1...
is the problem.
[zihlmann@ifarm2401 TOFGEOM]$ ccdb dump -nc GEOMETRY/main_HDDS.xml:120000 argument -nc/--no-comments: not allowed with argument -c/--comments [zihlmann@ifarm2401 TOFGEOM]$
actually worse cat corrupts the output at the beginning but generates an output ESC[32m+------------+ ESC[32m|ESC[0mESC[34mESC[1m xml ESC[0mESC[32m|ESC[0m ESC[32m|ESC[0m string ESC[0mESC[32m|ESC[0m ESC[32m+------------+ ESC[32m|ESC[0m <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE HDDS [