-
Notifications
You must be signed in to change notification settings - Fork 287
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
Forwards better plugins #349
Conversation
I want to introduce https://circleci.com/ into the build/test/distribute pipeline to do automated tests on commit. What do you think? |
I noticed that you guys did lots of approvals today. My plan is to update pymol-scripts-repo as soon as possible to Python 3. The unique drawback I think is a small cost of |
Hi Pedro, I'll give it a couple of tests soon, but I'm a bit tied up for the next couple of days. For the CircleCI proposal, we're moving toward Github Actions instead which does build and automate tests already. Any reason to not just stick with that? As far as the |
I hadn't knew about Github Actions. How do you setup the environment? I'm running ./install-prefix/bin/pymol -ckqy testing/testing.py --run testing/tests/api/test_commanding.py Is there an easier method? |
If you have installed PyMOL into a virtual environment, then this should also work: cd testing
python -m pytest tests/api/test_commanding.py |
The only plugin that have Currently this PR accept |
def test_declare_command_type_return(self):
@cmd.declare_command
def func() -> int:
return 1
assert func() == 1 fails with if function.__code__.co_argcount != len(function.__annotations__):
> raise Exception("Messy annotations")
E Exception: Messy annotations since I'm assuming the return type annotation isn't considered. |
Yes, I missed the return type. |
All plugins I read from https://github.com/Pymol-Scripts/Pymol-script-repo/ would works with this API declaration. It isn't so comprehensible because miss types as List or Any. But how it works for many (all?) cases, I think it's good enough. |
Thanks, we're going to address the pending PRs after 3.0. |
I think this looks good to me! I had a few questions/comments, but these portions of the code that appear to mirror I really like the flexibility of bool! You could in theory test more permutations of these bool input combinations (though I don't really think this is necessary). We should make sure this is well documented and easy to use for anyone to use that isn't super familiar with PyMOL. Specifically, I think it's worth explaining that I'm also not sure that the Finally, super minor but could you add a blank line to the end of the All in all, great addition! |
Thank you, Stwart, I really enjoyed to develop this code! Was thinking that we could add support to I also want to improve the Where the documentation goes so I can start writing in it? My opinion is that it should be easy to understand. The I'd like that PyMOL had a plugin help usage panel to explore documentation, and I'm willing to develop it as I already have some code to do it somewhere. Abraços |
There definitely are instances of lists coming from strings that must be parsed and I think it's important to encourage a consistent "design language" for this type of input (i.e. if that's how we want lists to be entered, then that's how they should always be entered). I agree that some examples would be really helpful along with a clear docstring. This is a must before really even worrying where else we should add documentation for this. The help tab of the plugin manager links to https://pymolwiki.org/index.php/PluginArchitecture but @speleo3 would probably have the most informed opinion with regard to where documentation for this would be the most helpful. I don't remember if the existing plugin manager is an incentive only feature or not but I would say this should be added to open-source in some capacity rather than developing a separate "plugin help panel". |
Currently lists are encoded as a string with spaces or commas.
But it would be better to be parsed with shlex: Here "b c" is a single list item.
According to IA, a Python list as string passed to def my_cmd(lst):
assert eval(lst) == ["a", "b", "c", "d"] There is also the option to parse the AST (I really enjoy handle code with AST) without I just checked how to detect generic types like About the examples, you can check drugpy new version. It has all the currently supported types. Seems that the propietary and open-source Plugin Manager are the same: |
My opinion is that we can test for each individual type like |
ping @TstewDev |
@pslacerda Please forgive the delay on getting back to this!
I don't think it's necessary to use
Finally, for the python vs pml/command component, PyMOL itself needs to know where the commands are coming from in general. This appears to be handled by the parser itself in |
Now I'm checking the stacktrace with the I need to capture errors from |
It was trivial to use
Thank you, I'm glad you liked its code.
Based on your observation, I simply check if he previous call was from |
I still don't think you should include your |
I couldn't make It could always be declared with I'll remove my |
lgtm. Let me know when this is ready to go. |
Seems done to me! I don't see any further improvements in this PR, except if you have so. Some of what I imagined I didn't make, like support for enums (it is still possible), or like autocomplete arguments (seems impossible to do it in a reliable way because completions is tied to a specific argument by order, which is subject to change when passing as keyargs, e.g. f(second=1, first=2). I'm also imagining a help window where users can search for commands and view the command declaration and formatted docstring. |
Thanks! Feel free to open another PR if/when you want to augment it. |
Where should I document this feature? Some possible options are:
|
New page on |
My initial attempt to improve the plugin command extensions.
Related to: #347