Skip to content

Conversation

leviathan747
Copy link
Collaborator

Selective parsing increases performance significantly when using a small bit of an external project. It also enables pulling in a dependency project for parsing without pulling in the whole dependency tree if the part you need does not rely on all the other dependencies.

@coveralls
Copy link
Collaborator

coveralls commented Feb 21, 2021

Coverage Status

Coverage decreased (-0.8%) to 79.217% when pulling 67fd993 on leviathan747:selective-parsing into 2f740fe on xtuml:master.

@leviathan747
Copy link
Collaborator Author

TODO:

  • support package following package references
  • handle case when parent name is a prefix of a different parent element



def prebuild_model(metamodel):
def prebuild_model(metamodel, parent_paths=[]):
Copy link
Contributor

Choose a reason for hiding this comment

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

Python has a somewhat unexpected behavior with mutable default values:

def append(number, number_list=[]):
    number_list.append(number)
    print(number_list)
    return number_list

append(5) # expecting: [5], actual: [5]
append(7) # expecting: [7], actual: [5, 7]
append(2) # expecting: [2], actual: [5, 7, 2]

Perhaps it does not matter in this case, but I usually do it like this instead:

def prebuild_model(metamodel, parent_paths=None):
    parent_paths = parent_paths or list()
    ...

Or you could use a default tuple() value instead, which is immutable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think I will change it to have no default since the option parser will handle passing a default value if the user does not provide one.

Copy link
Collaborator Author

@leviathan747 leviathan747 Feb 22, 2021

Choose a reason for hiding this comment

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

Actually, I will go with your suggestion since maybe that is more expressive when reading the code and does not assume the utility is run from the command line...

@leviathan747
Copy link
Collaborator Author

Package references are supported. Now the model_paths function returns a list of all possible paths to an element (including through package references).

I also changed the implementation so that paths are represented as lists of individual segments instead of strings. This solves the weakness with using startswith that I mentioned before.

@john-tornblom
Copy link
Contributor

I am still not entirely sure what scenarios this PR cover, and I believe further documentation (on scenarios in /doc) is needed. However, before we commit time on review to identify missing corner cases, is this feature still relevant and desirable?

@leviathan747
Copy link
Collaborator Author

I'm going to close this one for now and postpone work on it. It will be tracked further here: https://support.onefact.net/issues/12251

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.

3 participants