示例#1
0
文件: cli.py 项目: not522/optuna
def _format_output(
    records: Union[List[Dict[Tuple[str, str], Any]], Dict[Tuple[str, str],
                                                          Any]],
    columns: List[Tuple[str, str]],
    output_format: str,
    flatten: bool,
) -> str:
    if isinstance(records, list):
        values, header = _convert_to_dict(records, columns, flatten)
    else:
        values, header = _convert_to_dict([records], columns, flatten)

    if output_format == "table":
        return _dump_table(values, header).strip()
    elif output_format == "json":
        if isinstance(records, list):
            return json.dumps(values).strip()
        else:
            return json.dumps(values[0]).strip()
    elif output_format == "yaml":
        if isinstance(records, list):
            return yaml.safe_dump(values).strip()
        else:
            return yaml.safe_dump(values[0]).strip()
    else:
        raise CLIUsageError(
            f"Optuna CLI does not supported the {output_format} format.")
示例#2
0
文件: cli.py 项目: soskek/optuna
def _check_storage_url(storage_url):
    # type: (Optional[str]) -> str

    if storage_url is None:
        raise CLIUsageError(
            'Storage URL is not specified.')
    return storage_url
示例#3
0
文件: cli.py 项目: not522/optuna
def _check_storage_url(storage_url: Optional[str]) -> str:

    if storage_url is None:
        raise CLIUsageError("Storage URL is not specified.")
    return storage_url