Skip to content
This repository has been archived by the owner on Sep 11, 2023. It is now read-only.

Rename time_resolution_minutes to sample_period_minutes to make the code consistent #587

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Rename time_resolution_minutes to sample_period_minutes to make the code consistent #587

wants to merge 3 commits into from

Conversation

RishiKumarRay
Copy link

Pull Request

Description

Rename time_resolution_minutes to sample_period_minutes to make the code consistent

Fixes #584

Checklist:

  • [ x] My code follows OCF's coding style guidelines
  • [ x] I have performed a self-review of my own code
  • [ x] I have made corresponding changes to the documentation
  • [ ]x I have added tests that prove my fix is effective or that my feature works
  • [ x] I have checked my code and corrected any misspellings

Copy link
Member

@JackKelly JackKelly left a comment

Choose a reason for hiding this comment

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

Thank you so much for jumping in and writing a PR for issue #587! (And welcome to the project!)

Just one comment...

@@ -98,7 +98,7 @@ def __post_init__(self): # noqa
@property
def sample_period_minutes(self) -> int:
"""Override the default sample minutes"""
return self.time_resolution_minutes
return self.sample_period_minutes
Copy link
Member

Choose a reason for hiding this comment

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

Ah, sorry, I hadn't thought about this issue when I wrote issue #587! I don't think Python allows classes where a @property method has the same name as an attribute of the class. (Because, in Python, methods are attributes, too 🙂). Sorry, I should've thought about this!

Perhaps the cleanest solution is to completely get rid of the sample_period_minutes @property method from DataSource and all subclasses of DataSource. But then I think we bump into the issue that dataclass subclasses can't set new default values. (Although maybe that's changed in more recent versions of Python?)

If you're up for it, it'd be amazing if you could have a tinker and see if it's possible to remove the sample_period_minutes @property method, and then find a way to allow subclasses of DataSource to set their own default values for sample_period_minutes?

Copy link
Author

Choose a reason for hiding this comment

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

@JackKelly I have to learn python for this, I don't know much about python

Copy link
Member

Choose a reason for hiding this comment

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

OK, no rush! It's totally up to you: If you fancy doing this then please go for it, there's no rush for this issue! But, if you'd prefer not to, then please just shout!

The relevant part of the Python docs might be this page on inheritance in dataclasses. On skim-reading the docs, it actually looks like it might be fine to just delete the sample_period_minutes @property method from all our code, and just use a sample_period_minutes attribute, which can be set to different values for each subclass.

Copy link
Author

Choose a reason for hiding this comment

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

@JackKelly Sorry for this , I thought it was all about renaming thats why I raised the PR , maybe I am not suitable for this now to do the changes , If you want i will close this pull request and maybe you can assign someone else, i looked at the problem , removing sample_period_minutes @Property method is easy as you know but using just as atribute , I don't know much of it since i am totally unaware of python.

Copy link
Member

Choose a reason for hiding this comment

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

Cool, absolutely no worries! Don't worry about deleting this PR, as your changes are definitely useful! Maybe someone else can pick up where this left off... Thanks again for your help, and please do keep an eye out for other "renaming" issues!

Copy link
Author

Choose a reason for hiding this comment

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

@JackKelly If it is useful , can you merge it , maybe some other issue should be opened for adding as attribute , Just a suggestion , Thanks :) also I will start learning python in my free time , thanks for suggestions

Copy link
Member

Choose a reason for hiding this comment

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

I'm not certain but I think the code might break if we merge as is (even though the unittests pass... but I think the passing tests might be a "false pass" because maybe we don't have any unittests which call the sample_period_minutes @property?)

Copy link
Author

Choose a reason for hiding this comment

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

@JackKelly yeah got your point , lets wait then for someone to take this

@JackKelly
Copy link
Member

@all-contributors please add @RishiKumarRay for code

@allcontributors
Copy link
Contributor

@JackKelly

I've put up a pull request to add @RishiKumarRay! 🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Status: Review in Progress
Development

Successfully merging this pull request may close these issues.

Rename time_resolution_minutes to sample_period_minutes to make the code consistent
2 participants