Hi, is it possible to further enhance the `cli` to...
# dev-metaflow
f
Hi, is it possible to further enhance the
cli
to add extra options just for our internal usage? We have some stuff like what metaflow deployment the job should run on and currently we are hiding all
cli
options you see and only allowing the
env
and
username
since we call it inside
subprocess
. I was thinking if there was some function that I could import which has more or less all the expected arguments I can further add our options on top of it.
Copy code
python flow_name.py argo-workflows create --help
d
you want to add something to
argo-workflows create
or do you want to add a completely separate command like
my-argo-workflows
?
f
Basically separate command which adds some extra options but underneath it's still calling
argo-workflows create
Copy code
python deploy_flow.py --env <prd|stg|dev>
d
Separate command is easier I suppose. I’ll post tomorrow but you can build an extension and add your own cli. Under the hood you can parse your arguments and then call rhr relevant Argo functions.
thankyou 1
If it is a separate command like this, it’s pretty straightforward.
it will look something like this:
Copy code
CLIS_DESC = [("mycli", ".mycli.mycli_cli.cli")]
to add something to do
myflow.py mycli …
You then need to have in the
plugins
folder there a file like
mycli/mycli_cli.py
and inside that have something like:
Copy code
@click.group()
def cli():
    pass


@cli.group(help="Commands related to my awesome CLI")
def mycli():
    pass
Define your options/etc there as you would with any other click based CLI and you should be good to go.
If you want to augment argo stuff, you can look at how argo is implemented starting here: https://github.com/Netflix/metaflow/blob/master/metaflow/plugins/argo/argo_workflows_cli.py#L55 and pick and choose what you need from there.
Note that the extension mechanism is not officially supported and there is no guarantee of it not having breaking change.
That being said, it’s been stable for a while and we use it so it’s not going to randomly stop working and/or provide less functionality than it currently is.
Let me know if you have more questions. This is just a high level overview but should at least get you started.