Conversation
|
This will be great, thanks @golaz! |
|
A few more ideas for consideration
|
|
@golaz I'm very excited about this new feature! it can make zppy more extensible and effective to serve as an interface for needed tools. |
zppy/__main__.py
Outdated
| for plugin in user_config["default"]["plugins"]: | ||
| # Sanity check: plugin is a file and has .py extension | ||
| if not (os.path.isfile(plugin) and plugin.endswith(".py")): | ||
| print('WARNING: Skipping invalid external plugin = "%s"' % (plugin)) | ||
| continue |
There was a problem hiding this comment.
@golaz and @tangq, I don't think providing a path to a plugin is going to be a good approach if you want plugins to become conda packages. The path to the code will be pretty convoluted, machine specific and not easy for a user to figure out. Instead, it would be better if it were a python package with a standard format and you simply gave the name of the python package. (It would be even better the python packages for zppy plugins all started with zppy- because that's a very common convention for python plugins.)
You can use importlib.resources to get file locations and read text from files in python packages. This would be my strong recommendation here.
There was a problem hiding this comment.
@xylar, thank you for raising those good points.
We could certainly change how plugins are specified. As I was adapting @hsiangheleellnl and @tangq code, I looked for the simplest possible entry option to get users started interfacing their python code. As the development of a plugin matures, the code should become a standard python package. But it might be better to require this from the onset.
I like the idea of names starting with zppy-, not sure if some developers might prefer a standalone name though.
There was a problem hiding this comment.
I see, it depends on if the package has a life if its own outside of being a zppy plugin. Then, the zppy prefix wouldn't make much sense.
There was a problem hiding this comment.
We decided on chemdyg to match the repo name for that particular package. No zppy- prefix.
|
Unresolved: how do zppy plugins provide their |
I would think you could have a standard filename (probably |
|
I think it is a good idea to have |
|
Sorry, silly question. This is clearly the case looking at the code. |
|
@golaz Here's my commit of fixes you'll need: 3b2338e I ran the integration tests. I had to add in a The unit tests pass with the fixes in the commit. I also ran the pre-commit checks and made two changes to get those passing. |
|
I updated expected files for the integration tests, so it looks like those are all passing now. |
Plugins for zppy
A number of users have expressed interest in adding new functionality to zppy. Until now, the process of adding new tasks to zppy required directly modifying the zppy source code to add the appropriate hooks in the python code and add new Jinja2 templates. This is unnecessarily complicated and could cause the zppy code base to become bloated over time with code that should live in a separate repository. The goal of zppy is to streamline the workflow, not to directly incorporate tools and diagnostics.
The new zppy plugin functionality aims to solve these issues by providing a very simple mechanism for users to call custom python code without any modifications to the zppy source code. The plugin is maintained in a separate location, and the user only needs to modify the zppy configuration file:
Minimum directory structure of the plugin code:
Over time, we envision that certain user-created plugins will mature and gain sufficient adoption to become official zppy plugins. At that point, the plugin source code should be included into E3SM Unified and zppy will be modified to know its location without having to specify it explicitly in the configuration file. But testing and ensuring compatibility with new zppy releases will remain the responsibility of the plugin maintainer.