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

Add plugins support to pastas #657

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft

Add plugins support to pastas #657

wants to merge 2 commits into from

Conversation

dbrakenhoff
Copy link
Member

Introducing Plugins

Plugins are custom code (classes and functions) that can be registered in pastas. This allows custom Pastas-related to code to be developed in separate repositories, but they can be made available within pastas.

Some examples of custom code could be:

  • New stressmodels that support convolution. These could be registered under pastas.stressmodels
  • New stressmodels that do not use convolution. These could be registered under a new submodule, i.e. pastas.reservoirs
  • Completely new module for specific types of plots or post-processing. These could be registered under ps.customplots, or ps.postprocessing, respectively
  • etc.

How does it work?

Let's say you've developed some new StressModels in a file called my_new_stressmodels.py. All you have to do is import your module, and then use ps.plugins.register() to register the plugin classes and methods in pastas. The target keyword argument allows you to specify the location within the pastas module where you want your custom code to be made available.

import pastas as ps
import my_new_stressmodels as my_plugin

# to register new classes under `pastas.stressmodels`
ps.plugins.register(my_plugin, target="stressmodels")

# to register in a completely new sub-module
ps.plugins.register(my_plugin, target="reservoirs")

# to register all classes and functions in pastas root
ps.plugins.register(my_plugin, target=None)

Checklist before PR can be merged:

  • is documented
  • Format code with Black formatting
  • type hints for functions and methods
  • tests added / passed
  • Example Notebook (for new features)

- allow registering custom classes and functions in pastas
- add tests
@dbrakenhoff
Copy link
Member Author

dbrakenhoff commented Oct 17, 2023

Another new development that would benefit from a few of you taking a look, so I've requested all your reviews again 😇 !

Too soon, I need to rethink this a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Indicates development of new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant