Пример #1
0
 def test_dev_env_configuration_human_readable(self,
                                               mock_executor_response):
     """Tests dev_env command execution."""
     dev_env.get_dev_env_configuration(dev_env.Commands.PIP3_LIST,
                                       human_readable=True)
     mock_executor_response().execute_command.assert_called_with(
         ['pip3', 'list'])
Пример #2
0
 def test_dev_env_configuration_version(self, mock_executor_response):
     """Tests dev_env command execution."""
     # human readable = false should not set format flag for version calls
     dev_env.get_dev_env_configuration(dev_env.Commands.PIP3_VERSION,
                                       human_readable=False)
     mock_executor_response().execute_command.assert_called_with(
         ['pip3', '-V'])
     dev_env.get_dev_env_configuration(dev_env.Commands.PYHYON3_PIP_VERSION,
                                       human_readable=False)
     mock_executor_response().execute_command.assert_called_with(
         ['python3', '-m', 'pip', '-V'])
Пример #3
0
def diagnose_me(ctx, json, project_id, namespace):
    """Runs environment diagnostic with specified parameters.

    Feature stage:
    [Alpha](https://github.com/kubeflow/pipelines/blob/07328e5094ac2981d3059314cc848fbb71437a76/docs/release/feature-stages.md#alpha)
    """
    # validate kubectl, gcloud , and gsutil exist
    local_env_gcloud_sdk = gcp.get_gcp_configuration(
        gcp.Commands.GET_GCLOUD_VERSION,
        project_id=project_id,
        human_readable=False)
    for app in ['Google Cloud SDK', 'gsutil', 'kubectl']:
        if app not in local_env_gcloud_sdk.json_output:
            raise RuntimeError(
                '%s is not installed, gcloud, gsutil and kubectl are required '
                % app + 'for this app to run. Please follow instructions at ' +
                'https://cloud.google.com/sdk/install to install the SDK.')

    click.echo('Collecting diagnostic information ...', file=sys.stderr)

    # default behaviour dump all configurations
    results = {}
    for gcp_command in gcp.Commands:
        results[gcp_command] = gcp.get_gcp_configuration(
            gcp_command, project_id=project_id, human_readable=not json)

    for k8_command in k8.Commands:
        results[k8_command] = k8.get_kubectl_configuration(
            k8_command, human_readable=not json)

    for dev_env_command in dev_env.Commands:
        results[dev_env_command] = dev_env.get_dev_env_configuration(
            dev_env_command, human_readable=not json)

    print_to_sdtout(results, not json)
Пример #4
0
def diagnose_me(ctx: click.Context, json: bool, project_id: str,
                namespace: str):
    """Runs KFP environment diagnostic."""
    # validate kubectl, gcloud , and gsutil exist
    local_env_gcloud_sdk = gcp.get_gcp_configuration(
        gcp.Commands.GET_GCLOUD_VERSION,
        project_id=project_id,
        human_readable=False)
    for app in ['Google Cloud SDK', 'gsutil', 'kubectl']:
        if app not in local_env_gcloud_sdk.json_output:
            raise RuntimeError(
                f'{app} is not installed, gcloud, gsutil and kubectl are required '
                + 'for this app to run. Please follow instructions at ' +
                'https://cloud.google.com/sdk/install to install the SDK.')

    click.echo('Collecting diagnostic information ...', file=sys.stderr)

    # default behaviour dump all configurations
    results: ResultsType = {
        gcp_command: gcp.get_gcp_configuration(gcp_command,
                                               project_id=project_id,
                                               human_readable=not json)
        for gcp_command in gcp.Commands
    }

    for k8_command in k8.Commands:
        results[k8_command] = k8.get_kubectl_configuration(
            k8_command, human_readable=not json)

    for dev_env_command in dev_env.Commands:
        results[dev_env_command] = dev_env.get_dev_env_configuration(
            dev_env_command, human_readable=not json)

    print_to_sdtout(results, not json)
Пример #5
0
 def test_dev_env_configuration(self, mock_executor_response):
     """Tests dev_env command execution."""
     dev_env.get_dev_env_configuration(dev_env.Commands.PIP3_LIST)
     mock_executor_response().execute_command.assert_called_with(
         ['pip3', 'list', '--format', 'json'])