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

Import UVL File #5

Merged
merged 19 commits into from
Aug 31, 2024
Merged

Import UVL File #5

merged 19 commits into from
Aug 31, 2024

Conversation

Valle12
Copy link
Collaborator

@Valle12 Valle12 commented Aug 12, 2024

Ability to import .uvl files
@DanielZhangDP it seems like the random-sampling option throws an error when i try to run it with my example. The created model does not have an instance_cardinality on the top level, so your code throws an IndexError. We need to talk about that, if you need to change something or if I need to change something:)

@DoctorJohn DoctorJohn requested a review from Aonokishi August 13, 2024 00:46
@DanielZhangDP
Copy link
Collaborator

If it is just the root that is missing its instance cardinality, then I would add [1,1] as its instance cardinality since it is defined to always be that.

Copy link
Collaborator

@DoctorJohn DoctorJohn left a comment

Choose a reason for hiding this comment

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

Impressive set of changes. Here's a few general suggestions upfront:

  • I'd recomment following the python naming convention. i.e. snake_case for all functions, methods, and variables
  • In case you have an assignment expression like a: A = A(), the type of a can already be inferred and does not need a type annotation (i.e. a = A() is fully sufficient, but less verbose)

@Valle12
Copy link
Collaborator Author

Valle12 commented Aug 13, 2024

Yes you are right @DoctorJohn i tried changing as much as possible, but unfortunately i cannot change the Listener and the Error class, because they inherit from the classes inside of the uvlparser/antlr4 package. And for whatever reason, they are in the Java style, because antlr4 created them, even though it is not the typical Python naming scheme:(

@Aonokishi Aonokishi requested review from DanielZhangDP and DoctorJohn and removed request for Aonokishi and DanielZhangDP August 27, 2024 20:31
Copy link
Collaborator

@DoctorJohn DoctorJohn left a comment

Choose a reason for hiding this comment

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

I just noticed I had a pending review with some minor suggestions.

cfmtoolbox/plugins/uvl_import.py Outdated Show resolved Hide resolved
cfmtoolbox/plugins/uvl_import.py Outdated Show resolved Hide resolved
Comment on lines +256 to +273
self.constraints.append(
Constraint(
True,
self.feature_map[ref_1],
Cardinality([Interval(1, None)]),
self.feature_map[ref_2],
Cardinality([Interval(1, None)]),
)
)
self.constraints.append(
Constraint(
True,
self.feature_map[ref_2],
Cardinality([Interval(1, None)]),
self.feature_map[ref_1],
Cardinality([Interval(1, None)]),
)
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
self.constraints.append(
Constraint(
True,
self.feature_map[ref_1],
Cardinality([Interval(1, None)]),
self.feature_map[ref_2],
Cardinality([Interval(1, None)]),
)
)
self.constraints.append(
Constraint(
True,
self.feature_map[ref_2],
Cardinality([Interval(1, None)]),
self.feature_map[ref_1],
Cardinality([Interval(1, None)]),
)
)
self.constraints.extend([
Constraint(
True,
self.feature_map[ref_1],
Cardinality([Interval(1, None)]),
self.feature_map[ref_2],
Cardinality([Interval(1, None)]),
),
Constraint(
True,
self.feature_map[ref_2],
Cardinality([Interval(1, None)]),
self.feature_map[ref_1],
Cardinality([Interval(1, None)]),
)
])

if len(self.features) > 0:
self.features[0].instance_cardinality = Cardinality([Interval(1, 1)])

def exitFeature(self, ctx: UVLPythonParser.FeatureContext):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This method is currently overly complex, but we can work on it in a separate PR. For now it'll most useful to merge these changes so that they can serve as a basis for the UVL export.

@DoctorJohn DoctorJohn merged commit 3707bef into main Aug 31, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants