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

CLI: Fix exception for verdi plugin list #6560

Merged
merged 1 commit into from
Aug 19, 2024

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Aug 19, 2024

Fixes #6557

In e952d77 a bug in verdi plugin list was fixed where the conditional to check whether the plugin was a process class would always raise an AttributeError if the plugin was not a Process or a proces function. As a result, the code would never get to the else-clause.

The else-clause contained itself another bug, which was now revealed by the fixing of the bug in the conditional. The else-clause would call the get_description classmethod of the plugin, but no classes in AiiDA that are pluginnable even define such a class method. Probably, the original author confused it with the instance method get_description but the verdi plugin list command just deals with the class.

The get_description call is replaced with just getting __doc__ which returns the docstring of the class/function, or None if it is not defined. In the latter case, a default message is displayed saying that no description is available.

Since the else-clause code was never reached before the recent fix and the get_description method was never supported officially by AiiDA's pluginnable interfaces, it is fine to just change this behavior.

In e952d77 a bug in `verdi plugin list`
was fixed where the conditional to check whether the plugin was a
process class would always raise an `AttributeError` if the plugin was
not a `Process` or a proces function. As a result, the code would never
get to the else-clause.

The else-clause contained itself another bug, which was now revealed by
the fixing of the bug in the conditional. The else-clause would call the
`get_description` classmethod of the plugin, but no classes in AiiDA
that are pluginnable even define such a class method. Probably, the
original author confused it with the instance method `get_description`
but the `verdi plugin list` command just deals with the class.

The `get_description` call is replaced with just getting `__doc__` which
returns the docstring of the class/function, or `None` if it is not
defined. In the latter case, a default message is displayed saying that
no description is available.

Since the else-clause code was never reached before the recent fix and
the `get_description` method was never supported officially by AiiDA's
pluginnable interfaces, it is fine to just change this behavior.
@sphuber sphuber requested review from khsrali and t-reents August 19, 2024 09:05
Copy link

codecov bot commented Aug 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.83%. Comparing base (ef60b66) to head (2bea022).
Report is 133 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6560      +/-   ##
==========================================
+ Coverage   77.51%   77.83%   +0.33%     
==========================================
  Files         560      566       +6     
  Lines       41444    41983     +539     
==========================================
+ Hits        32120    32675     +555     
+ Misses       9324     9308      -16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@khsrali khsrali left a comment

Choose a reason for hiding this comment

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

Thanks, @sphuber.
Changes make sense; the only thing is backward compatibility for plugins that have their description stored in 'get_description()' as a classmethod.

But since this is only a description, I think it's fine.

@sphuber
Copy link
Contributor Author

sphuber commented Aug 19, 2024

Thanks, @sphuber. Changes make sense; the only thing is backward compatibility for plugins that have their description stored in 'get_description()' as a classmethod.

Which plugins would have this though? This has never been part of any plugin API. There are no classes in AiiDA that have the get_description class method as part of their interface. It was just a mistake in verdi plugin list that wasn't even ever hit because of the other bug.

@khsrali
Copy link
Contributor

khsrali commented Aug 19, 2024

Which plugins would have this though? This has never been part of any plugin API. There are no classes in AiiDA that have the get_description class method as part of their interface. It was just a mistake in verdi plugin list that wasn't even ever hit because of the other bug.

aiida-firecrest was doing it that way, simply because of the way plugin_list() was written we thought that's the way.

Of course this would be an easy change for us.
Just saying that there might be other plugins out there that thought the same.

@sphuber
Copy link
Contributor Author

sphuber commented Aug 19, 2024

aiida-firecrest was doing it that way, simply because of the way plugin_list() was written we thought that's the way.

Ah I see, well in that case I think it is fine as you say. Thanks for the review

@sphuber sphuber changed the base branch from main to support/2.6.x August 19, 2024 10:31
@sphuber sphuber changed the base branch from support/2.6.x to main August 19, 2024 10:31
@sphuber sphuber merged commit c3b10b7 into aiidateam:main Aug 19, 2024
11 checks passed
@sphuber sphuber deleted the fix/6557/verdi-plugin-list branch August 19, 2024 10:32
mikibonacci pushed a commit to mikibonacci/aiida-core that referenced this pull request Sep 3, 2024
In e952d77 a bug in `verdi plugin list`
was fixed where the conditional to check whether the plugin was a
process class would always raise an `AttributeError` if the plugin was
not a `Process` or a proces function. As a result, the code would never
get to the else-clause.

The else-clause contained itself another bug, which was now revealed by
the fixing of the bug in the conditional. The else-clause would call the
`get_description` classmethod of the plugin, but no classes in AiiDA
that are pluginnable even define such a class method. Probably, the
original author confused it with the instance method `get_description`
but the `verdi plugin list` command just deals with the class.

The `get_description` call is replaced with just getting `__doc__` which
returns the docstring of the class/function, or `None` if it is not
defined. In the latter case, a default message is displayed saying that
no description is available.

Since the else-clause code was never reached before the recent fix and
the `get_description` method was never supported officially by AiiDA's
pluginnable interfaces, it is fine to just change this behavior.
agoscinski pushed a commit to agoscinski/aiida-core that referenced this pull request Nov 4, 2024
In e952d77 a bug in `verdi plugin list`
was fixed where the conditional to check whether the plugin was a
process class would always raise an `AttributeError` if the plugin was
not a `Process` or a proces function. As a result, the code would never
get to the else-clause.

The else-clause contained itself another bug, which was now revealed by
the fixing of the bug in the conditional. The else-clause would call the
`get_description` classmethod of the plugin, but no classes in AiiDA
that are pluginnable even define such a class method. Probably, the
original author confused it with the instance method `get_description`
but the `verdi plugin list` command just deals with the class.

The `get_description` call is replaced with just getting `__doc__` which
returns the docstring of the class/function, or `None` if it is not
defined. In the latter case, a default message is displayed saying that
no description is available.

Since the else-clause code was never reached before the recent fix and
the `get_description` method was never supported officially by AiiDA's
pluginnable interfaces, it is fine to just change this behavior.

Cherry-pick: c3b10b7
agoscinski pushed a commit to agoscinski/aiida-core that referenced this pull request Nov 5, 2024
In e952d77 a bug in `verdi plugin list`
was fixed where the conditional to check whether the plugin was a
process class would always raise an `AttributeError` if the plugin was
not a `Process` or a proces function. As a result, the code would never
get to the else-clause.

The else-clause contained itself another bug, which was now revealed by
the fixing of the bug in the conditional. The else-clause would call the
`get_description` classmethod of the plugin, but no classes in AiiDA
that are pluginnable even define such a class method. Probably, the
original author confused it with the instance method `get_description`
but the `verdi plugin list` command just deals with the class.

The `get_description` call is replaced with just getting `__doc__` which
returns the docstring of the class/function, or `None` if it is not
defined. In the latter case, a default message is displayed saying that
no description is available.

Since the else-clause code was never reached before the recent fix and
the `get_description` method was never supported officially by AiiDA's
pluginnable interfaces, it is fine to just change this behavior.

Cherry-pick: c3b10b7
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.

CLI: verdi plugin list fails for data plugins
2 participants