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

[Feature Request] I would like resolvers to access the decorated main function's docstring and the name of the running script, as well as some other capabilities. #2944

Open
2 tasks
mmcdermott opened this issue Sep 3, 2024 · 3 comments
Labels
enhancement Enhanvement request

Comments

@mmcdermott
Copy link

🚀 Feature Request

  • I would like a resolver that returns the docstring of the decorated main function. This could be added, I think, very easily, here:
    @functools.wraps(task_function)
  • I would also like a resolver that tells me the name of the python function in which the main function that is decorated is located, and/or the name of the current command / script that is being run.

Motivation

Is your feature request related to a problem? Please describe.
I want an easy way to specify command line help messages that are semantically annotated with my code, and I use main function docstrings to do this. I currently have a hacky solution, here: https://github.com/mmcdermott/MEDS_transforms/blob/95885836b876d3bcbcae1d2bfd4567ab54595767/src/MEDS_transforms/utils.py#L112C1-L138C34

But this would be much easier to do reliably if it could be implemented in this code base in the decorator for the main function as you'd have access to the function being decorated directly.

Pitch

Describe the solution you'd like
A simple resolver added into the decorator function that returns (via inspect) the docstring of the function being documented.

Describe alternatives you've considered
See the links above for my attempts to get this dynamically without being able to leverage the decorated main function directly.

Are you willing to open a pull request? (See CONTRIBUTING)
Yes.

@mmcdermott
Copy link
Author

This would also help with #633

@mmcdermott
Copy link
Author

I'm thinking something as simple as main...mmcdermott:hydra:patch-1, to operationalize this a bit more (though I haven't actually tested that PR yet, so it may not be the right approach).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhanvement request
Projects
None yet
Development

No branches or pull requests

2 participants
@mmcdermott and others