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

Documented that nothing should be defined outside the plugin class in Python storage plugins #867

Conversation

jesper-friis
Copy link
Collaborator

Description

Documented that nothing should be defined outside the plugin class in Python storage plugins,

Type of change

  • Bug fix & code cleanup
  • New feature
  • Documentation update
  • Test update

Checklist for the reviewer

This checklist should be used as a help for the reviewer.

  • Is the change limited to one issue?
  • Does this PR close the issue?
  • Is the code easy to read and understand?
  • Do all new feature have an accompanying new test?
  • Has the documentation been updated as necessary?

Comment on lines +178 to +184
:::{danger}
**When writing a Python storage plugin, do not define any variables or functions outside the `DLiteStorageBase` subclass!**

The reason for this requirement is that all plugins will be loaded into the same shared scope within the built-in interpreter.
Hence, variables or functions outside the plugin class may interfere with other plugins, resulting in confusing and hard-to-find bugs.
:::

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good, but can we add an example in https://github.com/SINTEF/dlite/blob/master/doc/user_guide/storage_plugin.py (doen't matter if it is not used), and in the template?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good, but can we add an example in https://github.com/SINTEF/dlite/blob/master/doc/user_guide/storage_plugin.py (doen't matter if it is not used), and in the template?

Do you mean the note added on line 3 in https://github.com/SINTEF/dlite/blob/81261950afd235dd4c280103bcca798c46ec9463/doc/user_guide/storage_plugin.py?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No I was thinking more along the lines
class plugin....:
....
...

def _local_help_function():
""" An optional class method or a function if desired.
Note that no functions or variables should be set outside the class
for a DLite plugin python 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.

Added an example help method to the storage plugin template

jesper-friis and others added 4 commits July 1, 2024 17:45
…ing-outside-the-plugin-class' of github.com:SINTEF/dlite into 866-document-that-dlite-plugins-should-not-define-anything-outside-the-plugin-class
@jesper-friis jesper-friis merged commit 5b67e56 into master Jul 3, 2024
15 checks passed
@jesper-friis jesper-friis deleted the 866-document-that-dlite-plugins-should-not-define-anything-outside-the-plugin-class branch July 3, 2024 19:09
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.

Document that DLite plugins should not define anything outside the plugin class.
2 participants