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

Added some utility in disk library #3637

Closed

Conversation

PraveenPenguin
Copy link
Collaborator

added a utility that performs the operation on io scheduler

Signed-off-by: Praveen K Pandey praveen@linux.vnet.ibm.com

@codecov
Copy link

codecov bot commented Mar 9, 2020

Codecov Report

Merging #3637 into master will decrease coverage by 0.02%.
The diff coverage is 42.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3637      +/-   ##
==========================================
- Coverage   69.38%   69.35%   -0.03%     
==========================================
  Files         133      133              
  Lines       17015    17029      +14     
==========================================
+ Hits        11806    11811       +5     
- Misses       5209     5218       +9
Impacted Files Coverage Δ
avocado/utils/disk.py 70.73% <42.85%> (-14.46%) ⬇️
...plugins/varianter_cit/avocado_varianter_cit/Cit.py 99.51% <0%> (-0.49%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e2d8351...476b3e5. Read the comment docs.

added a utility that performs the operation on io scheduler

Signed-off-by: Praveen K Pandey <praveen@linux.vnet.ibm.com>
Copy link
Contributor

@willianrampazzo willianrampazzo left a comment

Choose a reason for hiding this comment

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

Hi @PraveenPenguin, so far, your code looks promising. I have made some comments, but I also would like you to check double spaces all over your docstrings. I have not added individual comments to those as it would pollute the review.

:return: list of IO scheduler
"""
names = open(__sched_path(device_name)).read()
return names.translate(string.maketrans('[]', ' ')).split()
Copy link
Contributor

Choose a reason for hiding this comment

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

What python version are you running? I tried this code with python 3.7 and got AttributeError: module 'string' has no attribute 'maketrans'. I also found this note on python release 3.1: The string.maketrans() function is deprecated and is replaced by new static methods, bytes.maketrans() and bytearray.maketrans().

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah let me check my setup


from . import process


class DiskUtilsError(Exception):
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an excellent intention, but I suggest you use a more specific exception, like OSError, for example.

Copy link
Member

Choose a reason for hiding this comment

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

OSError is generic, too.

Copy link
Contributor

Choose a reason for hiding this comment

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

@beraldoleal, I agree, but it, at least, covers a more specific set of exceptions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@willianrampazzo idea here is it catch Exceptions for utility, right now it seems OSError but idea is that Exceptions can be reused for any exception from this utility as I am planning to add more library will use this, please let me your thought

Copy link
Member

Choose a reason for hiding this comment

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

IMO, DiskUtilsError is better than an OSError, because tells the user that the error was in our library. But, I might be missing something.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@beraldoleal I also agree with this @willianrampazzo please let us know your thought so we can have V2

Copy link
Contributor

Choose a reason for hiding this comment

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

My initial comment was about changing class DiskUtilsError(Exception) by class DiskUtilsError(OSError) as OSError is more specific to what is been covered here, and not changing the DiskUtilsError by OSError.

But I don't have problems keeping the way it is now, it was just a suggestion to restrict the kind of exceptions covered by DiskUtilsError.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@willianrampazzo sure but I feel we need to have DiskUtilsError having broader Exception so we need not to change it on future but when we raise it in utility we can narrow down there like in OSError case we have to expect in that utility how that sound

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, I got it. Let's go with Exception.

:param device_name: Device name example like sda , hda
:return: list of IO scheduler
"""
names = open(__sched_path(device_name)).read()
Copy link
Contributor

Choose a reason for hiding this comment

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

You are using context manager all over the code, so just for the sake of consistency, my suggestion is to use a context manager here too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure make sense

:rtype : str
"""
return re.split(r'[\[\]]',
open(__sched_path(device_name)).read())[1]
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment for the context manager here.

@beraldoleal
Copy link
Member

beraldoleal commented May 12, 2020

@PraveenPenguin any updates here? Do you still need this or can we close?

@PraveenPenguin
Copy link
Collaborator Author

@PraveenPenguin any updates here? Do you still need this or can we close?

@beraldoleal ah i miss this will send PR soon

@richtja richtja force-pushed the master branch 12 times, most recently from 6a7bd06 to 07e4ea2 Compare December 15, 2022 14:07
@clebergnu
Copy link
Contributor

@PraveenPenguin any updates here? Do you still need this or can we close?

@beraldoleal ah i miss this will send PR soon

Hi @PraveenPenguin,

Gentle ping here.

@clebergnu clebergnu added this to the #104 - Codename TBD milestone Jul 13, 2023
@richtja
Copy link
Contributor

richtja commented Jan 15, 2024

Hi @PraveenPenguin do you plan to follow up on this PR? Thank you for your answer.

@PraveenPenguin
Copy link
Collaborator Author

PraveenPenguin commented Jan 22, 2024

Hi @PraveenPenguin do you plan to follow up on this PR? Thank you for your answer.

Hi @richtja , ah missed this PR my bad , will respin adopting with review comment asap ,

@richtja
Copy link
Contributor

richtja commented Mar 22, 2024

Hi @PraveenPenguin gentle ping here.

@PraveenPenguin
Copy link
Collaborator Author

closing this PR as raised new version of this code changes #5928

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done 105
Development

Successfully merging this pull request may close these issues.

None yet

5 participants