i6_core.util

class i6_core.util.MultiOutputPath(creator, path_template, hidden_paths, cached=False)
class i6_core.util.MultiPath(path_template, hidden_paths, cached=False, path_root=None, hash_overwrite=None)
i6_core.util.add_suffix(string: str, suffix: str) str
i6_core.util.backup_if_exists(file: str)
i6_core.util.cached_path(path: Union[str, Path]) Union[str, bytes]
i6_core.util.check_file_sha256_checksum(filename: str, reference_checksum: str)

Validates the sha256sum for a file against the target checksum

Parameters:
  • filename – a single file to be checked

  • reference_checksum – checksum to verify against

i6_core.util.chunks(l: List, n: int) List[List]
Parameters:
  • l – list which should be split into chunks

  • n – number of chunks

Returns:

yields n chunks

i6_core.util.compute_file_sha256_checksum(filename: str) str

Computes the sha256sum for a file

Parameters:

filename – a single file to be checked

Returns:

checksum

:rtype:str

i6_core.util.create_executable(filename: str, command: List[str])

create an executable .sh file calling a single command :param filename: executable name ending with .sh :param command: list representing the command and parameters :return:

i6_core.util.delete_if_exists(file: str)
i6_core.util.delete_if_zero(file: str)
i6_core.util.get_executable_path(path: Optional[Path], gs_member_name: Optional[str], default_exec_path: Optional[Path] = None) Path

Helper function that allows to select a specific version of software while maintaining compatibility to different methods that were used in the past to select software versions. It will return a Path object for the first path found in

Parameters:
  • path – Directly specify the path to be used

  • gs_member_name – get path from sisyphus.global_settings.<gs_member_name>

  • default_exec_path – general fallback if no specific version is given

i6_core.util.get_g2p_path(g2p_path: Path) Path

gets the path to the sequitur g2p script

i6_core.util.get_g2p_python(g2p_python: Path) Path

gets the path to a python binary or script that is used to run g2p

i6_core.util.get_returnn_python_exe(returnn_python_exe: Path) Path

gets the path to a python binary or script that is used to run RETURNN

i6_core.util.get_returnn_root(returnn_root: Path) Path

gets the path to the root folder of RETURNN

i6_core.util.get_subword_nmt_repo(subword_nmt_repo: Path) Path

gets the path to the root folder of subword-nmt repo

i6_core.util.get_val(var: Any) Any
i6_core.util.instanciate_delayed(o: Any) Any

Recursively traverses a structure and calls .get() on all existing Delayed Operations, especially Variables in the structure

Parameters:

o – nested structure that may contain DelayedBase objects

Returns:

i6_core.util.num_cart_labels(path: Union[str, Path]) int
i6_core.util.partition_into_tree(l: List, m: int) List[List]

Transforms the list l into a nested list where each sub-list has at most length m + 1

i6_core.util.reduce_tree(func, tree)
i6_core.util.remove_suffix(string: str, suffix: str) str
i6_core.util.uopen(path: Union[str, Path], *args, **kwargs) Union[open, open]
i6_core.util.update_nested_dict(dict1: Dict[str, Any], dict2: Dict[str, Any])

updates dict 1 with all the items from dict2, both dict1 and dict2 can be nested dict

i6_core.util.write_paths_to_file(file: Union[str, Path], paths: List[Union[str, Path]])
i6_core.util.write_xml(filename: ~typing.Union[<sisyphus.toolkit.RelPath object at 0x7f991c680490>, str], element_tree: ~typing.Union[~xml.etree.ElementTree.ElementTree, ~xml.etree.ElementTree.Element], prettify: bool = True)

writes element tree to xml file :param filename: name of desired output file :param element_tree: element tree which should be written to file :param prettify: prettify the xml. Warning: be careful with this option if you care about whitespace in the xml.

i6_core.util.zmove(src: Union[str, Path], target: Union[str, Path])