-
Notifications
You must be signed in to change notification settings - Fork 90
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
Entrypoint Consolidation: All Functionality accessible via mlflow-export-import
#30
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Justin Flannery <juftin@juftin.com>
877ae18
to
d6d05ba
Compare
@click.group() | ||
@click.version_option(version=__version__, prog_name=__application__) | ||
@click.pass_context | ||
def cli(ctx: click.core.Context) -> None: | ||
""" | ||
MLflow Export / Import CLI: Command Line Interface | ||
""" | ||
ctx.ensure_object(dict) | ||
|
||
|
||
CLI_COMMANDS: List[click.Command] = [ | ||
export_all, | ||
export_models, | ||
import_all, | ||
export_run, | ||
import_run, | ||
export_experiment, | ||
import_experiment, | ||
export_experiments, | ||
import_experiments, | ||
export_model, | ||
import_model, | ||
list_models, | ||
http_client, | ||
find_artifacts, | ||
] | ||
|
||
for command in CLI_COMMANDS: | ||
cli.add_command(command) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's where all the magic happens to consolidate each click command. You can distribute a click CLI over different files in a few ways, but this way results in the least refactor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's how the official MLflow CLI is organized using a similar method: https://github.com/mlflow/mlflow/blob/fd1f3aa246ca55a6dc0121ecf582c48b1c0287d0/mlflow/cli.py#L578-L583
@click.command("list-models") | ||
@click.option("--output-dir", help="Output directory.", default=".", type=str) | ||
def main(output_dir): # pragma: no cover | ||
""" | ||
Lists all registered models. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's where I tell the main
function that it's click command is "list-models". Click will handle this for us automatically if the function being decorated with click.command()
was named list_models
.
I also place the docstring on the function - click will automatically pass this to the CLI
mlflow-export-import
This PR addresses Issue #29
Changes
1) All Click Commands have been added to a new master Click Group
2) All entrypoints have been replaced with the new Click Group:
3) All packaging configuration moved to
setup.cfg
-setup.py
inherits from this automaticallypyproject.toml
file which instructs Python to use setuptools as the build tool. Again nothing actually changes here - we're just using thesetup.cfg
file to be a little more declarative and having no arbitrary code execution at install time viasetup.py
4) Version management moved to the
_version.py
file - this allows us to do things likefrom mlflow_export_import import __version__
5) Standard Python
.gitignore
added (withmlruns/
exclusion)Notes
import-models
- this was a duplicate ofimport-all
export-model-list
- this code is missing