This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Namespace-based Export Plugins #1006
Comments
Thanks for bringing this up; I've also been wanting to get our plugins re-done. I'm still thinking through this, but here are my thoughts so far.
That's all I've got for now. Sorry it's disorganized, but I'm still mulling over all of it. |
Oh, I forgot to mention pluggy. It looks like a very useful, lightweight library for managing this type of problem. We'd just have to design a spec for what we wanted, and it can handle pretty much the rest of it. |
I'm kinda liking the approach of moving the plugin directory (so a user can just drop in their plugins independent of the jrnl core plugins). This would buy us some time to redesign the plugin system while not breaking backwards compatibility (for now). What do you think, @MinchinWeb? |
Hey @wren ! I think your vision is fairly close to mine, so I'll start working on something! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
still planning on making this happen! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
not stale... |
@MinchinWeb How's this going? Any progress? Is there anything we can help with? I'd love to get the solution we talked about in to jrnl soon, since it'll make it easier to make updates to the exporters without worrying about breaking them for users. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
bump |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
not stale, still WIP |
Oh, ha. It looks like stalebot is working again. It had gone down for a while and I honestly wasn't sure if they were ever going to fix it. |
This code is currently in the merged PR in the
There's one more thing that I want to change, though it's not a showstopper: ideally, the feature file should be able to use a "Given" step to install and test plugins. When we start getting issues from plugin developers, this will make it a lot easier to prevent regressions. |
Working with this today, I noticed that there aren't any tests for import plugins. I think we need to add those as well. |
It looks like the sample importer plugin isn't writing to the journal at all - it reports that it is, but the journal doesn't show any data added to it. It looks like a write command needs to be sent, but that seems a little redundant for a plugin -- maybe it should automagically write instead of requiring the plugin author to tell it to write. There's also some funny stuff going on with the plugin's read logic, grabbing data differently based on whether it's coming from stdin vs. a file, and not appropriately reading from the file if it is a file. |
Further to #1275:
Now that we have the
#1281 deals with this:
|
Yup! Agreed and merged.
Yeah, I'm not jazzed about it either. Not sure if that's doable without the init files, though. Maybe we can move to something better like
I commented on the PR about not understanding the use case, but I wanted to bring up a separate point here. If the version for each plugin is always the same, and it's always imported from jrnl, then why do we even store or display it? I think we should either:
I think #1 makes sense for core plugins (the ones that ship with jrnl), and #2 makes sense for third-party plugins (contrib). What do you think?
Yup, I think so (at least, that's the same thing I was thinking). We should be able to conditionally copy the plugin filepath to the temp folder that the tests run in (pyest-bdd, not behave). |
I can make import jrnl
setattr(jrnl, "__version__", "2.8.0")
I've been thinking about this, and trying to come up with a plausible scenario where it might make a difference, and mostly coming up empty. One place where it might make a difference is when the plugin code is used as demo code for others writing their own plugins; I don't want them to set their version number to simply be jrnl's. As for 1, I think it's important/helpful to have a version number for debuging things when they break, at least for external plugins. By simply giving the built in plugins a version number, we don't have to deal with the special case of some plugins having version numbers and others not. By keeping internal and external plugins as close in implementation as possible, it makes it increadibly simple to move plugins from internal to external (which I think will prove helpful down the road). As for 2 (giving each internal plugin its own meaningful version), I'm not opposed to this as such, just the extra work involved is something to be aware of. As (internal) plugins will ship only with a specific version of jrnl, using jnrl's version number seemed like a way to provide a version number without any extra work. |
TIL about But--and maybe I'm reading your suggestion wrong--wouldn't putting
I agree we don't want third-party plugins hooking into the jrnl version. In that case, wouldn't we want to avoid showing them how to do it in the first place?
I personally don't think not having a version is a big deal, but I see what you're saying about keeping the implementations as close as possible. We could also leave the version as is and just not do anything with it (like in the diagnostic page we could just leave version out for core plugins).
To clarify, I was suggesting #2 for third-party plugins. So, it sounds to me like we're on the same page for this. |
Surprisingly no. Maybe this is because it's an explicit import? The one place you can't put it is in the
I suppose my logic was that by showing them that a version is defined, they'll know they need to provide one. But a guess someone new could draw either conclusion.
Do we also leave out the import paths? |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
I'm thinking about reworking the export plugin system to be auto-discovered based on the module name. Assuming this works well, it could be expanded to import plugins and possibly the storage backends as well.
There would be two namespaces: one for internal plugins, and another for external/contributed plugins.
The usecase would be to solve issues such as #779 where there is a difference of opinion of what the export should look like, or if you have a special format that you need. "Contributed" plugins could also be a way to test out a format before added in to the core of jrnl.
For myself, I have a "special" plugin that I used as a prep step to feed my jrnl entries into Pelican (a static site generator). It's always seemed like too "special" of a case to submit for the main repo, but it's something I use regularly. With the support and bug fixes to DayOne support, this is probably the only reason I have left to keep a private fork of jrnl.
In terms of implementation, I'm imagining that each plugin would have five methods:
["md", "markdown"]
; this is was will used by theexport
command of jrnl)I expect that contributed plugins would override the build-in plugins if they defined the same format code.
By using namespaced plugins, the plugin would be install-able via pip and would require no more configuration or activation beyond being importable by Python.
I haven't written any code yet (but I've been trying to figure out how to do this for probably 3 years...), but I wanted to get some thoughts on if there was support for this before I spend a bunch of time on it.
Thanks,
The text was updated successfully, but these errors were encountered: