-
Notifications
You must be signed in to change notification settings - Fork 28
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
Martin fileinfo cache 2 #2833
base: master
Are you sure you want to change the base?
Martin fileinfo cache 2 #2833
Conversation
@arporter That's the final PR for the file info caching stuff. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2833 +/- ##
========================================
Coverage 99.89% 99.89%
========================================
Files 359 359
Lines 51073 51307 +234
========================================
+ Hits 51021 51255 +234
Misses 52 52 ☔ View full report in Codecov by Sentry. |
@arporter Your turn. Let's try to stay below 50 comments :-) |
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.
Looks good Martin, this is functionality that will be important to have.
There are a couple of places where you appear to be duplicating functionality that we already have so I've asked for clarification.
I've not looked at the tests yet (but these will require updating anyway when you remove the bare asserts from the code).
|
||
def get_all_module_infos(self) -> List[ModuleInfo]: | ||
""" | ||
Return a list of all module infos |
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.
:returns: list of all module infos.
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.
You've missed this one?
|
||
def get_all_file_infos(self) -> List[FileInfo]: | ||
""" | ||
Return a list of all FileInfo objects |
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.
:returns: ...
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.
Thanks. There's no need to duplicate when it's this simple - you can just have the :returns: ...
line instead of the initial "Returns a list of ..." text.
|
||
return list(self._modules.values()) | ||
|
||
def get_all_file_infos(self) -> List[FileInfo]: |
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.
Am I right in thinking this doesn't do anything other than return information on objects we've already created? If so, I think this should be an @property
named all_file_infos
.
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.
Not addressed?
|
||
self._filepath_to_module_info[filepath] = module_info_in_file | ||
|
||
def get_all_module_infos(self) -> List[ModuleInfo]: |
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.
c.f. my comment on get_all_file_infos
, could this be a property named all_module_infos
?
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.
Not addressed?
@arporter Back to you :-) |
Thanks Martin. There are a few things to look at including a few you seem to have missed last time :-) I note that there is still at least one bare assert in the code but I'll do a proper grep next time around. Please could you also bring up-to-date with master. |
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 inline comments.
@@ -324,6 +325,22 @@ def get_symbol(self, name: str) -> Union[Symbol, None]: | |||
except KeyError: | |||
return None | |||
|
|||
def get_routine_by_name( |
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.
This is still outstanding?
@@ -286,7 +304,7 @@ def load_all_fparser_trees(self, verbose: bool = False) -> None: | |||
fileinfo: FileInfo | |||
fileinfo.get_fparser_tree(verbose=verbose) | |||
|
|||
def load_all_psyir_nodes(self, verbose: bool = False) -> None: | |||
def create_all_psyir_nodes(self, verbose: bool = False) -> None: | |||
""" | |||
Routine to load the psyir nodes of all files added |
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.
s/load/create/
|
||
def get_all_module_infos(self) -> List[ModuleInfo]: | ||
""" | ||
Return a list of all module infos |
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.
You've missed this one?
|
||
def get_all_file_infos(self) -> List[FileInfo]: | ||
""" | ||
Return a list of all FileInfo objects |
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.
Thanks. There's no need to duplicate when it's this simple - you can just have the :returns: ...
line instead of the initial "Returns a list of ..." text.
|
||
return list(self._modules.values()) | ||
|
||
def get_all_file_infos(self) -> List[FileInfo]: |
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.
Not addressed?
|
||
self._filepath_to_module_info[filepath] = module_info_in_file | ||
|
||
def get_all_module_infos(self) -> List[ModuleInfo]: |
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.
Not addressed?
order of dependencies, i.e. a module which is used by another module | ||
is listed before the module which uses it. | ||
|
||
The differences to `get_all_dependencies_recursively` are as follows: |
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.
Thanks for updating. However, I still think that with a little bit of work, this method could mostly use get_all_dependencies_recursively
- you could pass it a list containing just the module info you're after. Why do you need to preserve the ordering of the list of dependent ModuleInfos?
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.
When doing this, please also remove the bare assert.
This is the final PR for the updates on caching fparser (and later on psyir).
This update avoids using the same file multiple times for individual modules in each file.