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

Adding reification step4 #38

Closed
wants to merge 38 commits into from
Closed

Conversation

lute47lillo
Copy link
Collaborator

Addressing issue #37 being step 4 of issue #5 .

@jorgefandinno
Copy link
Owner

It looks good. Now we have to apply this to reife the whole rule. For instance, the following test

def test_epistemic_atom(self):
self.assert_equal_program(
parse_program(":- &k{a}."), ":- k_u(a). {k_u(a)} :- u(a)."
)

should now be

    def test_epistemic_atom(self):
        self.assert_equal_program(
            parse_program(":- &k{a}."), ":- k(u(a)). {k(u(a))} :- u(a)."
        )

This is the next step.

@lute47lillo
Copy link
Collaborator Author

It looks good. Now we have to apply this to reife the whole rule. For instance, the following test

def test_epistemic_atom(self):
self.assert_equal_program(
parse_program(":- &k{a}."), ":- k_u(a). {k_u(a)} :- u(a)."
)

should now be

    def test_epistemic_atom(self):
        self.assert_equal_program(
            parse_program(":- &k{a}."), ":- k(u(a)). {k(u(a))} :- u(a)."
        )

This is the next step.

Okay, I was thinking through it. In this case, do you want to make the call to parse_progrma function and do a reification there and then continue with the parse of the program, or will we need a new parse_program function that accounts for the reification steps?
Because, as it is, we also have the ":-" characters indicating that it is a rule, and if we were to reify the whole thing that is not accounted for in the first place

@lute47lillo
Copy link
Collaborator Author

@jorgefandinno While I'm looking into completing the reification as we talked, for which I'll post a couple comments since I have seen there are a couple ways of addressing it, I have gotten the 3 test_app.Test_Examples to fail.

I have not made any big change since the PR and you can also see what I have just started to change on the commits. But I cannot find the reason why they are failing now. Could you take a look into those? Maybe trying to see if they fail on your local machine too. Thank you

@jorgefandinno
Copy link
Owner

@jorgefandinno While I'm looking into completing the reification as we talked, for which I'll post a couple comments since I have seen there are a couple ways of addressing it, I have gotten the 3 test_app.Test_Examples to fail.

I have not made any big change since the PR and you can also see what I have just started to change on the commits. But I cannot find the reason why they are failing now. Could you take a look into those? Maybe trying to see if they fail on your local machine too. Thank you

Those are integration tests (they test the whole up instead of a single module).
It is strange that no other test fails. This means that there are no enough test for the part that fails.
My advice is to add more tests to the module you are modifying, until you find the bug.
Also, be sure reification is only used when the option is passed.

@lute47lillo
Copy link
Collaborator Author

@jorgefandinno While I'm looking into completing the reification as we talked, for which I'll post a couple comments since I have seen there are a couple ways of addressing it, I have gotten the 3 test_app.Test_Examples to fail.
I have not made any big change since the PR and you can also see what I have just started to change on the commits. But I cannot find the reason why they are failing now. Could you take a look into those? Maybe trying to see if they fail on your local machine too. Thank you

Those are integration tests (they test the whole up instead of a single module). It is strange that no other test fails. This means that there are no enough test for the part that fails. My advice is to add more tests to the module you are modifying, until you find the bug. Also, be sure reification is only used when the option is passed.

Okay, I figured it out. Apparently if you import something into a file like parser.py and then do not use it, the integration tests will fail. Why? That I do not know, but once I deleted them, the tests started to pass.

Copy link
Collaborator Author

@lute47lillo lute47lillo left a comment

Choose a reason for hiding this comment

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

@jorgefandinno Please review this comments and let me know what should be the right approach, I'll made the changes based on what is expected. Thank you

tests/test_reification.py Show resolved Hide resolved
tests/test_reification.py Outdated Show resolved Hide resolved
@lute47lillo
Copy link
Collaborator Author

On top of that, I'm getting an error with flake 8, isort cannot import name SortImports. I'm pretty sure I haven't changed any req file. Do you know if flake8 has maybe been updated?

@jorgefandinno
Copy link
Owner

On top of that, I'm getting an error with flake 8, isort cannot import name SortImports. I'm pretty sure I haven't changed any req file. Do you know if flake8 has maybe been updated?

I am not aware of that. I pulled the content of lute/reificationStep4 and all test pass on my computer.
Do you refer to other branch?

@lute47lillo
Copy link
Collaborator Author

On top of that, I'm getting an error with flake 8, isort cannot import name SortImports. I'm pretty sure I haven't changed any req file. Do you know if flake8 has maybe been updated?

I am not aware of that. I pulled the content of lute/reificationStep4 and all test pass on my computer. Do you refer to other branch?

The tests are passing, but here on github when the checks are running, flak8 fails and that is why the checks are failing. If you peek details you'll see how the actual tests are all up to date and passing

Copy link
Collaborator Author

@lute47lillo lute47lillo left a comment

Choose a reason for hiding this comment

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

noxfile.py Outdated Show resolved Hide resolved
@jorgefandinno jorgefandinno force-pushed the lute/reificationStep4 branch from 45dec4a to 3f93d62 Compare August 29, 2022 22:51
@jorgefandinno
Copy link
Owner

Can you try the tests in your computer by running nox?

They fail in github and in my computer.
If I run them with coverage run -m unittest, they work.

It is very strange.

@lute47lillo
Copy link
Collaborator Author

Can you try the tests in your computer by running nox?

They fail in github and in my computer. If I run them with coverage run -m unittest, they work.

It is very strange.

I'm pretty sure that there's an error with the installation of the requirements. I was doing some testing using the AST test case class and running them with the command nox -r. And I saw this message and tried the command nox without the flag -r and now the tests are failing due to a coverage exit code -11.

It is indeed very strange

@jorgefandinno
Copy link
Owner

Can you try the tests in your computer by running nox?
They fail in github and in my computer. If I run them with coverage run -m unittest, they work.
It is very strange.

I'm pretty sure that there's an error with the installation of the requirements. I was doing some testing using the AST test case class and running them with the command nox -r. And I saw this message and tried the command nox without the flag -r and now the tests are failing due to a coverage exit code -11.

It is indeed very strange

This is solved. Coverage is not 100%. Can you look into it?

@lute47lillo
Copy link
Collaborator Author

Can you try the tests in your computer by running nox?
They fail in github and in my computer. If I run them with coverage run -m unittest, they work.
It is very strange.

I'm pretty sure that there's an error with the installation of the requirements. I was doing some testing using the AST test case class and running them with the command nox -r. And I saw this message and tried the command nox without the flag -r and now the tests are failing due to a coverage exit code -11.
It is indeed very strange

This is solved. Coverage is not 100%. Can you look into it?

Is there a way of running all tests without having to list them one by one on the noxfile session.run command?

Coverage will fail to achieve 100% if some functions are not being used for the specified tests

@lute47lillo
Copy link
Collaborator Author

@jorgefandinno Coverage is fixed now by running all tests

@lute47lillo
Copy link
Collaborator Author

@jorgefandinno Please review the latest changes I have made, I believe it is all fixed now, and all the tests are passing.

from clingo.ast import Transformer


def _rule_to_symbolic_term_adapter(rules):
Copy link
Owner

Choose a reason for hiding this comment

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

Is this function used anywhere besides the tests? If not, the function should go to the test file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not for now, is the function I used as helper to call the transformer. It can be moved back to the tests

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is already solved and moved to the test file. @jorgefandinno

Copy link
Owner

Choose a reason for hiding this comment

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

Ok, now I understand. It make sense to have a function that wraps the transformer. It is a good idea.
I got confused by the naming. The convention is to start by a underscore _ private functions that are only used in the module. The best idea would be to move the function back here renamed without the underscore. Prepend an underscore to the Transformer and outside of this file use only the function and never the transformer. Is that possible?

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 moved it back and removed the underscore, but I do not understand the prepend an underscore to the Transformer, should I rename the Transformer class to be _? I have not seen any other Transformer being named like that

Copy link
Owner

Choose a reason for hiding this comment

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

@lute47lillo
Copy link
Collaborator Author

@jorgefandinno The refactor issue should be solved now

@lute47lillo lute47lillo closed this Mar 3, 2023
@lute47lillo lute47lillo deleted the lute/reificationStep4 branch May 6, 2023 19:38
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.

2 participants