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

issue: 4176956: move the text handling to the analyzers classes #284

Merged
merged 26 commits into from
Dec 4, 2024

Conversation

Miryam-Schwartz
Copy link
Contributor

@Miryam-Schwartz Miryam-Schwartz commented Nov 28, 2024

What

Move text and dataframes handling from main to the analyzers classes.

Why ?

https://redmine.mellanox.com/issues/4176956
For the sake of code aesthetics, readability, and encapsulation.

How ?

Some sub-classes of BaseAnalyzer class, override the implementation of analysis method, to add their own logic (handle text and dataframes).

Testing ?

Tested manually with various inputs to ensure the output file remains consistent.

Special triggers

Use the following phrases as comments to trigger different runs

  • bot:retest rerun Jenkins CI (to rerun GitHub CI, use "Checks" tab on PR page and rerun all jobs)
  • bot:upgrade run additional update tests

@boazhaim boazhaim requested a review from ananalaghbar December 1, 2024 06:05
@@ -85,7 +86,7 @@ def add_list_of_dicts_as_text(self, data_list, title=None, headers=None):

def add_dataframe_as_text(self, data_frame, title=None):
"""Adds a DataFrame to the PDF as aligned text without row numbers."""
if data_frame is None or data_frame.empty:
if not isinstance(data_frame, pd.DataFrame) or data_frame.empty:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about None?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if data_frame is None, 'isinstance(data_frame, pd.DataFrame)' will return False

@@ -193,3 +193,34 @@ def get_number_of_core_dumps(self):
self._log_data_sorted["type"] == "timeout_dump_core"
]
return {"Amount": len(core_dumps)}

def full_analysis(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miryam,
You misunderstood the purpose of the assignment. The base class already created an infrastructure to run the analysis. You should add methods to run as part of the base class full_analysis and NOT implement your own full_analysis method.
If it not clear let talk.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I changed it

@@ -33,4 +33,5 @@ def full_analysis(self):
Returns a list of all the graphs created and their title
"""
self.print_fabric_size()
return []
fabric_info = self.get_fabric_size()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing. Use the infrastructure in the base class to run this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -142,5 +142,7 @@ def plot_link_flapping_last_week(self):
)

def full_analysis(self):
self.get_link_flapping_last_week()
return super().full_analysis()
super().full_analysis()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing. Use the infrastructure in the base class to run this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

) as infile, open(
temp_file, "w", newline="", encoding=DataConstants.UTF8ENCODING
) as outfile:
with (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this display

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ruff requires this display

@drorlevy drorlevy merged commit c2d2e10 into main Dec 4, 2024
3 checks passed
@drorlevy drorlevy deleted the encapsulation branch December 4, 2024 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants