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

chore(sdk): clean up v2 CLI #7558

Merged
merged 13 commits into from
Apr 20, 2022
4 changes: 4 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Global options:

[mypy]
ignore_missing_imports = true
41 changes: 41 additions & 0 deletions sdk/python/kfp/cli/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2018-2022 The Kubeflow Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import logging
import sys

import click
import typer
from kfp.cli import cli
from kfp.cli import components
from kfp.cli import diagnose_me_cli
from kfp.cli import experiment
from kfp.cli import pipeline
from kfp.cli import recurring_run
from kfp.cli import run


def main():
logging.basicConfig(format='%(message)s', level=logging.INFO)
cli.cli.add_command(run.run)
cli.cli.add_command(recurring_run.recurring_run)
cli.cli.add_command(pipeline.pipeline)
cli.cli.add_command(diagnose_me_cli.diagnose_me)
cli.cli.add_command(experiment.experiment)
cli.cli.add_command(typer.main.get_command(components.app))
try:
cli.cli(obj={}, auto_envvar_prefix='KFP')
except Exception as e:
click.echo(str(e), err=True)
sys.exit(1)
30 changes: 2 additions & 28 deletions sdk/python/kfp/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import logging
import sys

import click
import typer
from kfp.cli import components
from kfp.cli.diagnose_me_cli import diagnose_me
from kfp.cli.experiment import experiment
from kfp.cli.output import OutputFormat
from kfp.cli.pipeline import pipeline
from kfp.cli.recurring_run import recurring_run
from kfp.cli.run import run
from kfp.client import Client

_NO_CLIENT_COMMANDS = ['diagnose_me', 'components']


@click.group()
@click.option('--endpoint', help='Endpoint of the KFP API service to connect.')
Expand Down Expand Up @@ -58,25 +46,11 @@ def cli(ctx: click.Context, endpoint: str, iap_client_id: str, namespace: str,
Feature stage:
[Alpha](https://github.com/kubeflow/pipelines/blob/07328e5094ac2981d3059314cc848fbb71437a76/docs/release/feature-stages.md#alpha)
"""
if ctx.invoked_subcommand in _NO_CLIENT_COMMANDS:
NO_CLIENT_COMMANDS = ['diagnose_me', 'components']
if ctx.invoked_subcommand in NO_CLIENT_COMMANDS:
# Do not create a client for these subcommands
return
ctx.obj['client'] = Client(endpoint, iap_client_id, namespace,
other_client_id, other_client_secret)
ctx.obj['namespace'] = namespace
ctx.obj['output'] = output


def main():
logging.basicConfig(format='%(message)s', level=logging.INFO)
cli.add_command(run)
cli.add_command(recurring_run)
cli.add_command(pipeline)
cli.add_command(diagnose_me, 'diagnose_me')
cli.add_command(experiment)
cli.add_command(typer.main.get_command(components.app))
try:
cli(obj={}, auto_envvar_prefix='KFP')
except Exception as e:
click.echo(str(e), err=True)
sys.exit(1)
Loading