Example #1
0
def logs(client: ModelTrainingClient, train_id: str, file: str, follow: bool):
    """
    \b
    Stream training logs.
    For this command, you must provide a training ID or path to file with one training.
    The file must contain only one training.
    \b
    Usage example:
        * odahuflowctl train delete --id examples-git
        * odahuflowctl train delete -f train.yaml
    \f
    :param follow: Follow logs stream
    :param client: Model training HTTP client
    :param train_id: Model training ID
    :param file: Path to the file with only one training
    """
    check_id_or_file_params_present(train_id, file)

    if file:
        train = parse_resources_file_with_one_item(file).resource
        if not isinstance(train, ModelTraining):
            raise ValueError(
                f'Model training expected, but {type(train)} provided')

        train_id = train.id

    for msg in client.log(train_id, follow):
        print_logs(msg)
def delete(client: ToolchainIntegrationClient, ti_id: str, file: str,
           ignore_not_found: bool):
    """
    Delete a toolchain integration.\n
    For this command, you must provide a toolchain integration ID or path to file with one toolchain integration.
    The file must contain only one toolchain integration.
    If you want to delete multiples toolchain integrations than you should use "odahuflowctl res delete" instead.
    For now, CLI supports yaml and JSON file formats.
    The command will be failed if you provide both arguments.\n
    Usage example:\n
        * odahuflowctl tn-integration delete --id examples-git\n
        * odahuflowctl tn-integration delete -f ti.yaml
    \f
    :param client: Toolchain integration HTTP client
    :param ti_id: Toolchain integration ID
    :param file: Path to the file with only one toolchain integration
    :param ignore_not_found: ignore if toolchain integration is not found
    """
    check_id_or_file_params_present(ti_id, file)

    if file:
        ti = parse_resources_file_with_one_item(file).resource
        if not isinstance(ti, ToolchainIntegration):
            raise ValueError(
                f'Toolchain Integration expected, but {type(ti)} provided')

        ti_id = ti.id

    try:
        click.echo(client.delete(ti_id))
    except WrongHttpStatusCode as e:
        if e.status_code != http.HTTPStatus.NOT_FOUND or not ignore_not_found:
            raise e

        click.echo(IGNORE_NOT_FOUND_ERROR_MESSAGE.format(ti_id))
Example #3
0
def logs(client: ModelPackagingClient, pack_id: str, file: str, follow: bool):
    """
    \b
    Stream packaging logs.
    For this command, you must provide a packaging ID or path to file with one packaging.
    The file must contain only one packaging.
    The command will fail if you provide both arguments.
    \b
    Usage example:
        * odahuflowctl pack delete --id examples-git
        * odahuflowctl pack delete -f pack.yaml
    \f
    :param follow: Follow logs stream
    :param client: Model packaging HTTP client
    :param pack_id: Model packaging ID
    :param file: Path to the file with only one packaging
    """
    check_id_or_file_params_present(pack_id, file)

    if file:
        pack = parse_resources_file_with_one_item(file).resource
        if not isinstance(pack, ModelPackaging):
            raise ValueError(
                f'Model packaging expected, but {type(pack)} provided')

        pack_id = pack.id

    for msg in client.log(pack_id, follow):
        print_logs(msg)
Example #4
0
def delete(client: ModelRouteClient, mr_id: str, file: str,
           ignore_not_found: bool):
    """
    Delete a model route.\n
    For this command, you must provide a model route ID or path to file with one model route.
    The file must contain only one model route.
    If you want to delete multiples routes than you should use "odahuflowctl res delete" instead.
    For now, CLI supports yaml and JSON file formats.
    The command will be failed if you provide both arguments.\n
    Usage example:\n
        * odahuflowctl route delete --id examples-git\n
        * odahuflowctl route delete -f route.yaml
    \f
    :param client: ModelRoute HTTP client
    :param mr_id: ModelRoute ID
    :param file: Path to the file with only one model route
    :param ignore_not_found: ignore if Model Deployment is not found
    """
    check_id_or_file_params_present(mr_id, file)

    if file:
        route_resource = parse_resources_file_with_one_item(file).resource
        if not isinstance(route_resource, ModelRoute):
            raise ValueError(
                f'ModelRoute expected, but {type(route_resource)} provided')

        mr_id = route_resource.id

    try:
        click.echo(client.delete(mr_id))
    except WrongHttpStatusCode as e:
        if e.status_code != 404 or not ignore_not_found:
            raise e

        click.echo(f'Model route {mr_id} was not found. Ignore')
Example #5
0
def delete(client: ModelDeploymentClient, md_id: str, file: str,
           ignore_not_found: bool, wait: bool, timeout: int):
    """
    \b
    Delete a deployment.
    For this command, you must provide a deployment ID or path to file with one deployment.
    The file must contain only one deployment.
    If you want to delete multiple deployments, you should use "odahuflowctl bulk delete" instead.
    For now, CLI supports YAML and JSON file formats.
    The command will fail if you provide both arguments.
    \b
    Usage example:
        * odahuflowctl dep delete --id examples-git
        * odahuflowctl dep delete -f dep.yaml
    \f
    :param timeout: timeout in seconds. for wait (if no-wait is off)
    :param wait: no wait until deletion will be finished
    :param client: Model deployment HTTP client
    :param md_id: Model deployment ID
    :param file: Path to the file with only one deployment
    :param ignore_not_found: ignore if Model Deployment is not found
    """
    check_id_or_file_params_present(md_id, file)

    if file:
        md = parse_resources_file_with_one_item(file).resource
        if not isinstance(md, ModelDeployment):
            raise ValueError(
                f'Model deployment expected, but {type(md)} provided')

        md_id = md.id

    try:
        message = client.delete(md_id)

        wait_delete_operation_finish(timeout, wait, md_id, client)
        click.echo(message)
    except WrongHttpStatusCode as e:
        if e.status_code != 404 or not ignore_not_found:
            raise e

        click.echo(
            IGNORE_NOT_FOUND_ERROR_MESSAGE.format(
                kind=ModelDeployment.__name__, id=md_id))
Example #6
0
def delete(client: ModelTrainingClient, train_id: str, file: str,
           ignore_not_found: bool):
    """
    \b
    Delete a training.
    For this command, you must provide a training ID or path to file with one training.
    The file must contain only one training.
    For now, CLI supports YAML and JSON file formats.
    If you want to delete multiple trainings, you should use "odahuflowctl bulk delete" instead.
    The command will fail if you provide both arguments.
    \b
    Usage example:
        * odahuflowctl train delete --id examples-git
        * odahuflowctl train delete -f train.yaml
    \f
    :param client: Model training HTTP client
    :param train_id: Model training ID
    :param file: Path to the file with only one training
    :param ignore_not_found: ignore if Model Training is not found
    """
    check_id_or_file_params_present(train_id, file)

    if file:
        train = parse_resources_file_with_one_item(file).resource
        if not isinstance(train, ModelTraining):
            raise ValueError(
                f'Model training expected, but {type(train)} provided')

        train_id = train.id

    try:
        message = client.delete(train_id)
        click.echo(message)
    except WrongHttpStatusCode as e:
        if e.status_code != 404 or not ignore_not_found:
            raise e

        click.echo(
            IGNORE_NOT_FOUND_ERROR_MESSAGE.format(kind=ModelTraining.__name__,
                                                  id=train_id))
Example #7
0
def delete(client: ModelPackagingClient, pack_id: str, file: str,
           ignore_not_found: bool):
    """
    \b
    Delete a packaging.
    For this command, you must provide a packaging ID or path to file with one packaging.
    The file must contain only one packaging.
    If you want to delete multiple packagings, you should use "odahuflowctl bulk delete" instead.
    For now, CLI supports YAML and JSON file formats.
    The command will fail if you provide both arguments.
    \b
    Usage example:
        * odahuflowctl pack delete --id examples-git
        * odahuflowctl pack delete -f pack.yaml
    \f
    :param client: Model packaging HTTP client
    :param pack_id: Model packaging ID
    :param file: Path to the file with only one packaging
    :param ignore_not_found: ignore if Model Packaging is not found
    """
    check_id_or_file_params_present(pack_id, file)

    if file:
        pack = parse_resources_file_with_one_item(file).resource
        if not isinstance(pack, ModelPackaging):
            raise ValueError(
                f'Model packaging expected, but {type(pack)} provided')

        pack_id = pack.id

    try:
        message = client.delete(pack_id)
        click.echo(message)
    except WrongHttpStatusCode as e:
        if e.status_code != 404 or not ignore_not_found:
            raise e

        click.echo(f'Model packaging {pack_id} was not found. Ignore')
Example #8
0
def delete(client: ConnectionClient, conn_id: str, file: str,
           ignore_not_found: bool):
    """
    \b
    Delete a connection.
    For this command, you must provide a connection ID or path to file with one connection.
    The file must contain only one connection.
    If you want to delete multiple connections, you should use "odahuflowctl bulk delete" instead.
    For now, CLI supports YAML and JSON file formats.
    The command will fail if you provide both arguments.
    \b
    Usage example:
        * odahuflowctl conn delete --id examples-git
        * odahuflowctl conn delete -f conn.yaml
        * odahuflowctl conn delete --id examples-git --ignore-not-found
    \f
    :param client: Connection HTTP client
    :param conn_id: Connection ID
    :param file: Path to the file with only one connection
    :param ignore_not_found: ignore if connection is not found
    """
    check_id_or_file_params_present(conn_id, file)

    if file:
        conn = parse_resources_file_with_one_item(file).resource
        if not isinstance(conn, Connection):
            raise ValueError(f'Connection expected, but {type(conn)} provided')

        conn_id = conn.id

    try:
        click.echo(client.delete(conn_id))
    except WrongHttpStatusCode as e:
        if e.status_code != http.HTTPStatus.NOT_FOUND or not ignore_not_found:
            raise e

        click.echo(IGNORE_NOT_FOUND_ERROR_MESSAGE.format(conn_id))