-
Notifications
You must be signed in to change notification settings - Fork 115
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
host package_list fix #13989
host package_list fix #13989
Conversation
trigger: test-robottelo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see https://bugzilla.redhat.com/show_bug.cgi?id=2263041 for more context since it is indirectly related to Peter's patch here.
Ideally, we should expect hammer to provide a valid CSV format if we specify it / request it.
In this case, the is_csv
function is rejecting the CSV since the hammer output has only one column.
Nvra\nrabbit-1.5.6-1.noarch\n
I propose to revert #13797 first and then #13737, and a local workaround to remove the extra line in the output of job-invocation create
.
@ogajduse You can still use the output from CSV function and do a local workaround of removing extra new line. Not sure why would you like to revert the entire PR for ? How often do we have tables with one column ? |
@jyejare Can you please be more specific? What is the |
@ogajduse parse_csv function, btw I am agree with having local handling of non csv returns as is and hence removing all those workarounds putting in parse_csv function including this one. |
@ogajduse We could also create a separate filter/parser for such STDOUTs that does not fit into is_csv but could be parsed using CSV lib parser. That way we will have a good segregation and also fits into the defination of CSV and non-CSV! Something like:
Now is_csvlike will search for specific regex pattern etc that fits the definition of is_csvlike function. Thoughts ? |
Case with one column, one line
This does not seem to be the correct question that should be on the table. I would put the question: Let me put another question here.
In this case, [ins] In [142]: text6 = 'Nvra\nrabbit-1.5.6-1.noarch\n'
[ins] In [143]: reader = csv.reader(text6.splitlines())
[ins] In [144]: for l in reader:
...: print(l)
...:
['Nvra']
['rabbit-1.5.6-1.noarch'] However, [ins] In [149]: text6 = 'Nvra\nrabbit-1.5.6-1.noarch\n'
[ins] In [150]: sniffer = csv.Sniffer()
[ins] In [151]: sniffer.sniff(text6)
---------------------------------------------------------------------------
Error Traceback (most recent call last)
Cell In[151], line 1
----> 1 sniffer.sniff(text6)
File /usr/lib64/python3.11/csv.py:187, in Sniffer.sniff(self, sample, delimiters)
183 delimiter, skipinitialspace = self._guess_delimiter(sample,
184 delimiters)
186 if not delimiter:
--> 187 raise Error("Could not determine delimiter")
189 class dialect(Dialect):
190 _name = "sniffed"
Error: Could not determine delimiter Expectations of
|
Let me clarify what I mean by revert. By revert I mean using In the current state, robottelo is masking a product bug https://bugzilla.redhat.com/show_bug.cgi?id=2263041. Introducing the flake8-bugbear rule https://docs.astral.sh/ruff/rules/zip-without-explicit-strict/ that made us use strict mode for zipping CSV header and lines together, revealed this product bug. Let's dive into the code. Let's start from the method that wraps the robottelo/robottelo/cli/job_invocation.py Lines 34 to 38 in 362c6e8
We explicitly request hammer to provide output in CSV by output_format='csv' . The customer expects to receive ONLY the data in the requested format on stdout. If we expect hammer to provide the output in the base format, the human-readable only, we do not specify output_format='csv' and leave it set to None which results in our hammer wrapper not providing the --output argument to the hammer command. Therefore it is then up to us to work with that format and parse it on our own, but if we explicitly specify the format we want hammer to spit out the data in, we should rely on hammer in this. If hammer corrupts that data in any way, we should file a bug.With that stated, parse_csv function should throw an exception in case it can not parse the CSV output - indicating a product bug.
I would like to focus on providing a real fix that would ensure that we are catching real product bugs instead of creating mechanisms that might potentially hide them. |
I largely like what @ogajduse has proposed here. More accuracy is definitely better and the lack of identification of single column csv is a real problem with the current detection method. Additionally, one nitpick on the proposed code for stripping the bad line. I think this version is more readable, but does not include a trailing newline character. I don't believe this would break the reader, but could be arguably less aesthetic than a preserved trailing newline. result.stdout = "\n".join(result.stdout.splitlines()[:-1]) which results in
compared to the proposed version's
|
Lets see some background of why and what kind of STDOUTs we had to patch the #13737 for. In simple terms many STDOUTs arent fitting into the format of CSV and I agree that we as QE should not accept such faulty outputs and even customers who is willing to get CSV output demands from us to be the CSV only. Thanks @ogajduse for filing that bug though its nitpcik we could explain DEVs how this could affect customers if they are using CSV output for some automation and converting the STDOUT into CSV returning only half information (example is described in #13737). So what does #13737 do is what @ogajduse suppose it to do. That means Tests are asking for CSV but the STDOUT is not eligible for CSV (verified by CSV modules own Sniffer module for it, but it seems that is not helping us with single column. My proposal is to right our own function for such pattrens to identify its eligible for CSV conversion), hence its returning the STDOUT So, my opinion is to combining the approach of the Sniffer/Sniffing and develop our own |
I'm putting this to draft. I'll be working on a solution to reflect all said above, will notify you in a separate PR |
trigger: test-robottelo |
trigger: test-robottelo |
1 similar comment
trigger: test-robottelo |
(cherry picked from commit b83e4f4)
(cherry picked from commit b83e4f4)
(cherry picked from commit b83e4f4)
(cherry picked from commit b83e4f4)
Problem Statement
similar problem to #13797 -- the output of the cli package search won't qualify as csv but otherwise can be processed all right by the parse_csv function
This pr adds an exception, fixes around 6 tests