-
-
Notifications
You must be signed in to change notification settings - Fork 663
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] Permit user-defined arguments if needed #215
Comments
Hi, |
Basically, if you are trying to port an existing application that is using ArgParse to use Hydra, you should remove argparse. If you can describe your use case in more details I can give some advice on how to do it. Close this issue as this is a fundamental design choice that is not going to change. |
@omry : Thanks for your kindly reply. But what if I want to receive a certain command as well as configurations through argument? For example, python my_app.py db.user_id=test —command push ... |
you can add a command to your config, for example: config.yaml:
Once you do that, you can call your app like: |
Great suggestion! but what should I do if I want to add a description of the command to help menu? Users will habitually call ‘—help’ to get a guide for the command. |
At the moment the closest thing to this is to use -c to print the configuration. See this for info: I am planning to improve this though. |
See issue #1. For now you can do most of it manually, for example:
|
@omry : Thanks a lot for your detail guide! I'm trying to apply |
Awesome. |
Btw, I started to work on #1, It will be possible to create fully custom application help in the next Hydra release. |
Great news! I finished to migrate my Python app using hydra. I’m following you. |
awesome. |
I'm developing the in-house ML platform, which is in charge of pipelining, training, deploying and real-time serving. And I'm refactoring the legacy version of the commander /w conf. management ML tool using |
This sounds like a great use case! |
By the way: If you want to try, I can give you some pointers (but let's move the discussion to the Google group, I want others to know this is an option). |
It seems to be very useful for us because we have separated training / serving clusters. However, in official document, I can't find how to launch a job to run remotely. Could you share some sample codes to do it? |
This is not well documented right now because there isn't any public plugin that can do it at the moment. |
What system are you using to launch jobs to your cluster(s)? |
Thanks for sharing your history. If
In our case, we use basically Airflow + own commander/conf tool. |
The idea is that there can be a plugin to launch with Airflow. |
@omry |
very nice. |
I will add the mentioned description to my app as soon as possible. Thanks! |
I'm not sure if this is the place to add to this, but it seems to me that there's some value in allowing user-defined parsers. Specifically, consider this use-case: An ML application that has a single endpoint, say What work-around would you suggest? |
@jungerm2: @hydra.main(config_path="train.yaml")
def train(cfg):
.. test.py: @hydra.main(config_path="test.yaml")
def test(cfg):
.. If you actually do want to share most of the config, you create a mode parameter in your config: config.yaml:
then the code can behave differently based on the mode. |
Thank you that makes sense. In the case where we have multiple (2+) mutually exclusive args, multiple entry points is probably better design anyways... |
I'm not sure if adding a custom CLI option is supported at this point. Anyway here is my code for this by lazily calling the import argparse
import sys
import hydra
def main(cfg):
...
def _main():
parser = argparse.ArgumentParser()
parser.add_argument("--custom_option", type=int)
args, unknown = parser.parse_known_args()
# do some pre-processing
sys.argv = [sys.argv[0]] + unknown
hydra.main(version_base=None, config_path=".", config_name="default")(main)()
if __name__ == "__main__":
_main() |
🚀 Feature Request
Motivation
Is your feature request related to a problem? Please describe.
Because
hydra
definesargparse.ArgumentParser
internally, user cannot add own new parser.Pitch
Describe the solution you'd like
I added a new param(
user_arg_parser
) to thehydra.main
decorator. Thenmy_app
function can receive the additionalargs
param passed through Hydra.Describe alternatives you've considered
Are you willing to open a pull request? (See CONTRIBUTING)
Yes.
Additional context
Add any other context or screenshots about the feature request here.
You can also record a video
The text was updated successfully, but these errors were encountered: