Skip to content

Improvements on the @cmd.declare_command API #448

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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

pslacerda
Copy link
Contributor

A write a bunch of tests and did my best to achieve best ergonomic API.

Only optional (None) data is still failing in some cases.

image

@pslacerda pslacerda mentioned this pull request Apr 12, 2025
@JarrettSJohnson
Copy link
Member

I'll ask if we can maintain our pattern of keeping tests in testing (rather than adding tests in module).

@pslacerda
Copy link
Contributor Author

Sorry, it was my bad. I'll tackle this in a few days.

@pslacerda pslacerda force-pushed the declare_command branch 2 times, most recently from 80eb0ce to 7c9f7ff Compare May 13, 2025 15:41
@pslacerda
Copy link
Contributor Author

@JarrettSJohnson I'd like to ask, should I proceed and refactor existing commands to adhere the declare_command API?

@pslacerda
Copy link
Contributor Author

The first step is to refactor the help command to also support this API.

@JarrettSJohnson
Copy link
Member

@JarrettSJohnson I'd like to ask, should I proceed and refactor existing commands to adhere the declare_command API?

We can address that in a separate PR, if possible. Also I think some things were accidentally deleted, perhaps during the merging process? (e.g. testDeleteStates)

@pslacerda
Copy link
Contributor Author

The tip of branch were based on an old commit. It took me several hours to finish this git chore task.

Copy link
Member

@JarrettSJohnson JarrettSJohnson left a comment

Choose a reason for hiding this comment

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

Generally looks fine to me, I was under the impression from the original PR that this would just be for extended, custom functions rather than native ones. I'm a little hesitant to change current commands just yet. I still need to play around with this first to ensure no functional changes.

@@ -1,50 +0,0 @@
import sys
Copy link
Member

Choose a reason for hiding this comment

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

Was this file intended to be removed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Is it ok?

Copy link
Member

Choose a reason for hiding this comment

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

Please keep for now since we still have code that uses this pattern.

@pslacerda
Copy link
Contributor Author

I still need to play around with this first to ensure no functional changes.

Me too. Except for the help command which I want to adjust soon, I'll take a time before any progress.

@pslacerda
Copy link
Contributor Author

If I remove the docs-on-comment feature will this be merged faster?

@JarrettSJohnson
Copy link
Member

Apologies. Give me until the weekend, and I'll come back to this review. My involvement with incentive and open-source comes in waves, and I'm still pretty deep in 3.2/3.3 work.

@pslacerda
Copy link
Contributor Author

I think this is important to get merged before 3.2 because otherwise will have a delay starting in the current incomplete feature awaiting 3.3.

@@ -1,50 +0,0 @@
import sys
Copy link
Member

Choose a reason for hiding this comment

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

Please keep for now since we still have code that uses this pattern.

break
i += 1
else:
i -= 3
Copy link
Member

Choose a reason for hiding this comment

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

I don't think I follow this line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Me neither, I just placed it here because was needed. I'd need to debug to remember exactly, but seems to me that it's related to rewind the cursor i when no doc is found.


raise pymol.CmdException(f"Unsupported argument type {type}")

def parse_documentation(func):
Copy link
Member

Choose a reason for hiding this comment

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

I think this function probably needs its own unit test as well. The API to me is not inherently clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is tested integrated with declare_command on test_declare_command_arg_docs.

Copy link
Member

Choose a reason for hiding this comment

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

I understand, but something like this probably deserves its own test too if possible. I'll make it optional, but I will likely add it later.

@pslacerda
Copy link
Contributor Author

pslacerda commented Jul 23, 2025

Give me some days and I'll fix according to your review.

As nobody is using this yet, including me, may cmd.declare_command be renamed to cmd.new or cmd.new_command?

@JarrettSJohnson
Copy link
Member

Sure. new_command is fine. We already make use of cmd._new privately and it would be good for us not to be confused with the two.

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.

5 participants