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

Fix bug in Code.get_full_text_info #4083

Merged

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented May 19, 2020

Fixes #4079

This method was not tested and so it went unnoticed that it was still
using the _get_folder_pathsubfolder repository method that has been
removed in aiida-core==1.0.0. Direct access to the folder underlying
the node repository is no longer allowed and instead the API should be
used to inspect the available objects, in this case list_objects.

@sphuber sphuber force-pushed the fix/4079/code-local-full-text-info branch 2 times, most recently from def1516 to 81289fe Compare May 19, 2020 16:22
@sphuber sphuber requested a review from greschd May 19, 2020 16:22
Copy link
Member

@ramirezfranciscof ramirezfranciscof left a comment

Choose a reason for hiding this comment

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

Thanks! I think it all should be good. I only made one specific comment and now two general question:

(1) Why a list of lists? I mean, I understand we don't want to change the interface now, but is there another reason no to have used a dictionary (since this list of lists seems like a "hacked" dict) or even a list of tupples (since this return being info on the node should perhaps not have mutable "info-pieces")?

(2) This was not just the get_full_text_info method that was not being tested, but nothing from the code class correct? Then maybe it could be good to open an issue to discuss what other tests should be making for it?

tests/orm/data/test_code.py Outdated Show resolved Hide resolved
@sphuber
Copy link
Contributor Author

sphuber commented May 20, 2020

(1) Why a list of lists? I mean, I understand we don't want to change the interface now, but is there another reason no to have used a dictionary (since this list of lists seems like a "hacked" dict) or even a list of tupples (since this return being info on the node should perhaps not have mutable "info-pieces")?

This is indeed a remnant of old (sub-ideal) design. In old versions of AiiDA, the ORM classes also included many methods to do a lot of formatting of information such that it is easier, for example, for CLI commands to call them. I think this is not a good design as the formatting of data is not the task of an ORM class but exactly that of a CLI. I have been removing a lot of them, or at the very least, return them in a form where they can still be manipulated somewhat for formatting (i.e. do not return a preformatted string). I totally agree that this current form also makes little sense, so maybe we can deprecate this and remove it for 2.0. I would maybe do this in another PR with all other comparable commands in the ORM interface that should be removed.

(2) This was not just the get_full_text_info method that was not being tested, but nothing from the code class correct? Then maybe it could be good to open an issue to discuss what other tests should be making for it?

Yes, please go ahead

@sphuber sphuber force-pushed the fix/4079/code-local-full-text-info branch 2 times, most recently from 37e18bd to ff9b2dd Compare May 20, 2020 08:10
@sphuber
Copy link
Contributor Author

sphuber commented May 20, 2020

Ok this is super annoying: the test failed for Py3.5, but I fixed it and pushed the changes. The change shows up here on the PR changes:

filepath = os.path.join(tmpdir.realpath(), filename)  # Python 3.5 does not support Path objects for `join` yet`

But on GHA, the test still fails and it still seems to be running the old code:

==================================== ERRORS ====================================
__________________ ERROR at setup of test_get_full_text_info ___________________

tmpdir = local('/tmp/pytest-of-runner/pytest-0/test_get_full_text_info0')
aiida_localhost = <Computer: localhost-test (localhost-test), pk: 274>

    @pytest.fixture
    def create_codes(tmpdir, aiida_localhost):
        """Create a local and remote `Code` instance."""
        import os
    
        filename = 'add.sh'
>       filepath = os.path.join(tmpdir, filename)

@greschd do you maybe have an idea? Is GHA caching the code? I think I have force pushed very often to fix open PRs and it has never been a problem.

@greschd
Copy link
Member

greschd commented May 20, 2020

Wow, that's a curious one - I doubt GHA is intentionally caching the code, that would be a curious choice to lay the least.

But looking at the log, it indeed showed

Successfully installed aiida-core
-e git+https://github.com/aiidateam/aiida-core@7dbd51ac88b9a30bf645b224524fd7c411aaaad0#egg=aiida_core

which is (see 7dbd51a) the merge-commit of 37e18bd (your previous commit) into develop.

Maybe there's an internal API somewhere that should tell GHA which commit this PR points to and failed. I've noticed minor glitches on GitHub quite frequently the last few weeks.

How about you make an insignificant edit and force-push again?

@sphuber sphuber force-pushed the fix/4079/code-local-full-text-info branch from ff9b2dd to 794e8a4 Compare May 20, 2020 12:25
@greschd
Copy link
Member

greschd commented May 20, 2020

Seems like GHA picked the right commit this time around 🎉

@sphuber
Copy link
Contributor Author

sphuber commented May 20, 2020

Seems like GHA picked the right commit this time around tada

Except turns out my "fix" was worth exactly nothing 😅

@sphuber sphuber force-pushed the fix/4079/code-local-full-text-info branch from 794e8a4 to 347f3e7 Compare May 20, 2020 12:45

# Cast `tmpdir` to str as it is a Path object and Python 3.5 does not support Path objects for `join` yet
dirpath = str(tmpdir)
filepath = os.path.join(dirpath, filename)
Copy link
Member

Choose a reason for hiding this comment

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

You could also cast to str here, and use the glorious / operator for joining:

filepath = str(dirpath / filename)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice! It is clear I have not yet worked with Paths at all. Was going to merge because I am sick of waiting for the builds of this PR, but this is too nice to pass on

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But, then I don't even need the cast right? Or does open also not support Path in 3.5?

Copy link
Member

Choose a reason for hiding this comment

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

You still need the cast, pathlib support across the board only came in 3.6.

Copy link
Member

Choose a reason for hiding this comment

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

I guess we're back to waiting for another build 😅

@codecov
Copy link

codecov bot commented May 20, 2020

Codecov Report

Merging #4083 into develop will increase coverage by 0.03%.
The diff coverage is 80.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4083      +/-   ##
===========================================
+ Coverage    78.77%   78.80%   +0.03%     
===========================================
  Files          463      463              
  Lines        34414    34414              
===========================================
+ Hits         27106    27116      +10     
+ Misses        7308     7298      -10     
Flag Coverage Δ
#django 70.71% <80.00%> (+0.03%) ⬆️
#sqlalchemy 71.59% <80.00%> (+0.03%) ⬆️
Impacted Files Coverage Δ
aiida/orm/nodes/data/code.py 88.94% <80.00%> (+3.69%) ⬆️
aiida/transports/plugins/local.py 80.47% <0.00%> (+0.26%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b86425f...fa608e9. Read the comment docs.

@sphuber sphuber force-pushed the fix/4079/code-local-full-text-info branch from 347f3e7 to c31c235 Compare May 20, 2020 13:04
This method was not tested and so it went unnoticed that it was still
using the `_get_folder_pathsubfolder` repository method that has been
removed in `aiida-core==1.0.0`. Direct access to the folder underlying
the node repository is no longer allowed and instead the API should be
used to inspect the available objects, in this case `list_objects`.
@sphuber sphuber force-pushed the fix/4079/code-local-full-text-info branch from c31c235 to fa608e9 Compare May 20, 2020 13:20
@sphuber
Copy link
Contributor Author

sphuber commented May 20, 2020

I guess that's a no ...

@sphuber sphuber merged commit f57a0b9 into aiidateam:develop May 20, 2020
@sphuber sphuber deleted the fix/4079/code-local-full-text-info branch May 20, 2020 13:36
@sphuber sphuber modified the milestone: v1.2.2 May 20, 2020
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.

code show crashes with 'local' code
3 participants