raven: Cannot load plugins if pytest is installed


Issue Description

What did you expect to see happen?

Installed plugins should load independent of pytest being installed.

What did you see instead?

PluginManager unable to load plugins. If pytest is uninstalled then the plugins load fine.

Do you have a suggested fix for the development team?

Installing ravenframework as editable fixes this issue, but that is not an option for some. A configuration to pytest might be required. I suspect something in PluginManager line 159 to be the culprit. Instead of __file__ returning the path within the directory it is returning the path to the virtual environment and is unable to find the relative path to plugin_directory.xml. I would suggest using absolute file paths based on the installation directory.

Please attach the input file(s) that generate this error. The simpler the input, the faster we can find the issue.

Installed ravenframework with pip.

$ cd raven
$ pip install .
$ pip install pytest
$ python
 import ravenframework
 from ravenframework import PluginManager

output image

$ pip uninstall pytest
$ python
 import ravenframework
 from ravenframework import PluginManager

output

image


For Change Control Board: Issue Review

This review should occur before any development is performed as a response to this issue.

  • 1. Is it tagged with a type: defect or task?
  • 2. Is it tagged with a priority: critical, normal or minor?
  • 3. If it will impact requirements or requirements tests, is it tagged with requirements?
  • 4. If it is a defect, can it cause wrong results for users? If so an email needs to be sent to the users.
  • 5. Is a rationale provided? (Such as explaining why the improvement is needed or why current code is wrong.)

For Change Control Board: Issue Closure

This review should occur when the issue is imminently going to be closed.

  • 1. If the issue is a defect, is the defect fixed?
  • 2. If the issue is a defect, is the defect tested for in the regression test system? (If not explain why not.)
  • 3. If the issue can impact users, has an email to the users group been written (the email should specify if the defect impacts stable or master)?
  • 4. If the issue is a defect, does it impact the latest release branch? If yes, is there any issue tagged with release (create if needed)?
  • 5. If the issue is being closed without a pull request, has an explanation of why it is being closed been provided?

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 21

Commits related to this issue

Most upvoted comments

@wangcj05 Yes, thank you, we have a workaround now.

I started documentation on how we do the TEAL pip package: https://github.com/idaholab/raven/wiki/Plugins#pip-plugins

@joshua-cogliati-inl @cbroman-usnctech maybe the usage of [options.package_data] (in setup.cfg) can be useful to make sure all the essential datafiles (e.g. plugin_directory.xml) are stored in the package?

(And then, it can be loaded using pkg_resources -> pkg_resources.resource_stream(path_to_file_in_package)

@cbroman-usnctech I made a branch with your suggested fix.

FYI: PluginFactory: No installed plugins detected. is also listed in this issue: https://github.com/gmlc-dispatches/dispatches/issues/173