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

Martin fileinfo cache 2 #2833

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open

Martin fileinfo cache 2 #2833

wants to merge 26 commits into from

Conversation

schreiberx
Copy link
Collaborator

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.

@schreiberx schreiberx requested a review from arporter December 19, 2024 16:39
@schreiberx schreiberx self-assigned this Dec 19, 2024
@schreiberx
Copy link
Collaborator Author

@arporter That's the final PR for the file info caching stuff.
It's probably best to first get the previous PR in the master.

Copy link

codecov bot commented Dec 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.89%. Comparing base (6afc06a) to head (473e0d2).

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.
📢 Have feedback on the report? Share it here.

@schreiberx
Copy link
Collaborator Author

@arporter Your turn. Let's try to stay below 50 comments :-)

@schreiberx schreiberx marked this pull request as ready for review January 13, 2025 22:12
Copy link
Member

@arporter arporter left a 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
Copy link
Member

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.

Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

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

:returns: ...

Copy link
Member

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]:
Copy link
Member

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.

Copy link
Member

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]:
Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

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

Not addressed?

SCHREIBER Martin added 2 commits February 20, 2025 12:53
@schreiberx
Copy link
Collaborator Author

@arporter Back to you :-)

@arporter
Copy link
Member

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.

Copy link
Member

@arporter arporter left a 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(
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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]:
Copy link
Member

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]:
Copy link
Member

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:
Copy link
Member

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?

Copy link
Member

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.

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

Successfully merging this pull request may close these issues.

2 participants