pytest_wdl/executors/__init__.py
def read_write_inputs(
    inputs_file: Optional[Union[str, Path]] = None,
    inputs_dict: Optional[dict] = None,
    inputs_formatter: Optional[InputsFormatter] = InputsFormatter.get_instance(),
    write_formatted_inputs: bool = True,
    **kwargs
) -> Tuple[dict, Optional[Path]]:
    """
    If `inputs_file` is specified and it exists, read its contents. Otherwise, if
    `inputs_dict` is specified, format it using `inputs_formatter` (if specified) and
    write it to `inputs_file` or a temporary file.

    Args:
        inputs_file:
        inputs_dict:
        inputs_formatter:
        write_formatted_inputs:
        kwargs:

    Returns:
        The (formatted) inputs dict and the resolved inputs file. If both `inputs_dict`
        and `inputs_file` are None, returns `({}, None)`.
    """
    if inputs_file:
        inputs_file = ensure_path(inputs_file, is_file=True, create=True)

        if inputs_file.exists():
            with open(inputs_file, "rt") as inp:
                inputs_dict_from_file = json.load(inp)
                return inputs_dict_from_file, inputs_file

    if inputs_dict:
        inputs_dict = inputs_formatter.format_inputs(inputs_dict, **kwargs)

        if write_formatted_inputs:
            if not inputs_file:
                inputs_file = Path(tempfile.mkstemp(suffix=".json")[1])

            with open(inputs_file, "wt") as out:
                json.dump(inputs_dict, out, default=str)

        return inputs_dict, inputs_file

    return {}, None

    If `inputs_file` is specified and it exists, read its contents. Otherwise, if
    `inputs_dict` is specified, format it using `inputs_formatter` (if specified) and
    write it to `inputs_file` or a temporary file.

    Args:
        inputs_file:
        inputs_dict:
        inputs_formatter:
        write_formatted_inputs:
        kwargs:

    Returns:
        The (formatted) inputs dict and the resolved inputs file. If both `inputs_dict`
        and `inputs_file` are None, returns `({}, None)`.
    
If `inputs_file` is specified and it exists, read its contents.
If ` inputs_file ` is specified and it exists read its contents .
def read_write_inputs(
    inputs_file: Optional[Union[str, Path]] = None,
    inputs_dict: Optional[dict] = None,
    inputs_formatter: Optional[InputsFormatter] = InputsFormatter.get_instance(),
    write_formatted_inputs: bool = True,
    **kwargs
) -> Tuple[dict, Optional[Path]]:
    if inputs_file:
        inputs_file = ensure_path(inputs_file, is_file=True, create=True)
        if inputs_file.exists():
            with open(inputs_file, "rt") as inp:
                inputs_dict_from_file = json.load(inp)
                return inputs_dict_from_file, inputs_file
    if inputs_dict:
        inputs_dict = inputs_formatter.format_inputs(inputs_dict, **kwargs)
        if write_formatted_inputs:
            if not inputs_file:
                inputs_file = Path(tempfile.mkstemp(suffix=".json")[1])
            with open(inputs_file, "wt") as out:
                json.dump(inputs_dict, out, default=str)
        return inputs_dict, inputs_file
    return {}, None
def read_write_inputs ( inputs_file : Optional [ Union [ str , Path ] ] = None , inputs_dict : Optional [ dict ] = None , inputs_formatter : Optional [ InputsFormatter ] = InputsFormatter . get_instance ( ) , write_formatted_inputs : bool = True , ** kwargs ) -> Tuple [ dict , Optional [ Path ] ] : if inputs_file : inputs_file = ensure_path ( inputs_file , is_file = True , create = True ) if inputs_file . exists ( ) : with open ( inputs_file , "rt" ) as inp : inputs_dict_from_file = json . load ( inp ) return inputs_dict_from_file , inputs_file if inputs_dict : inputs_dict = inputs_formatter . format_inputs ( inputs_dict , ** kwargs ) if write_formatted_inputs : if not inputs_file : inputs_file = Path ( tempfile . mkstemp ( suffix = ".json" ) [ 1 ] ) with open ( inputs_file , "wt" ) as out : json . dump ( inputs_dict , out , default = str ) return inputs_dict , inputs_file return { } , None
If `inputs_file` is specified and it exists, read its contents.
If ` inputs_file ` is specified and it exists read its contents .
"""
    If `inputs_file` is specified and it exists, read its contents. Otherwise, if
    `inputs_dict` is specified, format it using `inputs_formatter` (if specified) and
    write it to `inputs_file` or a temporary file.

    Args:
        inputs_file:
        inputs_dict:
        inputs_formatter:
        write_formatted_inputs:
        kwargs:

    Returns:
        The (formatted) inputs dict and the resolved inputs file. If both `inputs_dict`
        and `inputs_file` are None, returns `({}, None)`.
    """
The (formatted) inputs dict and the resolved inputs file. If both `inputs_dict`
and `inputs_file` are None, returns `({}, None)`.
The ( formatted ) inputs dict and the resolved inputs file . If both ` inputs_dict ` and ` inputs_file ` are None returns ` ( {} None ) ` .
inputs_file
Optional[Union[str, Path]]
None
inputs_dict
Optional[dict]
None
inputs_formatter
Optional[InputsFormatter]
None
write_formatted_inputs
bool
None
kwargs
None