Commit 0daeb803 authored by Anika Treffehn's avatar Anika Treffehn
Browse files

Merge branch '1-problem-with-relative-directories-for-input-items' of...

Merge branch '1-problem-with-relative-directories-for-input-items' of https://forge.3gpp.org/rep/ivas-codec-pc/ivas-processing-scripts into test_runner_binaries
parents e565dcbe bb507272
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -498,7 +498,9 @@ def check_ISM_metadata(

                elif len(current_item) == num_objects:
                    # just read out
                    list_item = current_item
                    list_item = []
                    for c_item in current_item:
                        list_item.append(Path(c_item).resolve())
                else:
                    raise ValueError("Number of objects and metadata does not match.")
                list_meta.append(list_item)
@@ -528,7 +530,7 @@ def metadata_search(
            )
            # check if file exists and add to list
            if file_name_meta.is_file():
                list_item.append(file_name_meta)
                list_item.append(Path(file_name_meta).resolve())
            else:
                raise ValueError(f"Metadata file {file_name_meta} not found.")
        if len(item_names) == 1:
+28 −11
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
#  the United Nations Convention on Contracts on the International Sales of Goods.
#

from pathlib import Path
from typing import Optional

from ivas_processing_scripts.processing.config import TestConfig
@@ -79,7 +80,7 @@ def init_processing_chains(cfg: TestConfig) -> None:

    # list items in input directory
    cfg.items_list = list_audio(
        cfg.input_path, absolute=True, select_list=getattr(cfg, "input_select", None)
        cfg.input_path, select_list=getattr(cfg, "input_select", None)
    )
    if not cfg.items_list:
        raise SystemExit(
@@ -135,7 +136,9 @@ def get_preprocessing_2(cfg: TestConfig) -> dict:
    if background_cfg:
        background = {
            "snr": background_cfg.get("snr", None),
            "background_noise_path": background_cfg.get("background_noise_path", None),
            "background_noise_path": get_abs_path(
                background_cfg.get("background_noise_path", None)
            ),
            "seed_delay": background_cfg.get("seed_delay", 0),
            "master_seed": cfg.master_seed,
            "output_fmt": cfg.postprocessing["fmt"],
@@ -250,7 +253,9 @@ def get_processing_chain(
            if tx_cfg_tmp.get("type", None) == "FER":
                tx_cfg = {
                    "type": tx_cfg_tmp.get("type", None),
                    "error_pattern": tx_cfg_tmp.get("error_pattern", None),
                    "error_pattern": get_abs_path(
                        tx_cfg_tmp.get("error_pattern", None)
                    ),
                    "error_rate": tx_cfg_tmp.get("error_rate", None),
                    "master_seed": cfg.master_seed,
                    "prerun_seed": tx_cfg_tmp.get("prerun_seed", 0),
@@ -258,7 +263,9 @@ def get_processing_chain(
            elif tx_cfg_tmp.get("type", None) == "JBM":
                tx_cfg = {
                    "type": tx_cfg_tmp.get("type", None),
                    "error_pattern": tx_cfg_tmp.get("error_pattern", None),
                    "error_pattern": get_abs_path(
                        tx_cfg_tmp.get("error_pattern", None)
                    ),
                    "error_profile": tx_cfg_tmp.get("error_profile", None),
                    "n_frames_per_packet": tx_cfg_tmp.get("n_frames_per_packet", None),
                }
@@ -281,9 +288,9 @@ def get_processing_chain(
                    "in_fs": tmp_in_fs,
                    "out_fs": dec_cfg.get("fs", tmp_in_fs),
                    "bitrate": bitrate,
                    "cod_bin": cod_cfg.get("bin"),
                    "cod_bin": get_abs_path(cod_cfg.get("bin", None)),
                    "cod_opts": cod_cfg.get("opts"),
                    "dec_bin": dec_cfg.get("bin"),
                    "dec_bin": get_abs_path(dec_cfg.get("bin", None)),
                    "dec_opts": dec_cfg.get("opts"),
                    "multiprocessing": cfg.multiprocessing,
                    "tx": tx_cfg,
@@ -309,7 +316,9 @@ def get_processing_chain(
            if tx_cfg_tmp.get("type", None) == "FER":
                tx_cfg = {
                    "type": tx_cfg_tmp.get("type", None),
                    "error_pattern": tx_cfg_tmp.get("error_pattern", None),
                    "error_pattern": get_abs_path(
                        tx_cfg_tmp.get("error_pattern", None)
                    ),
                    "error_rate": tx_cfg_tmp.get("error_rate", None),
                    "master_seed": cfg.master_seed,
                    "prerun_seed": tx_cfg_tmp.get("prerun_seed", 0),
@@ -317,7 +326,7 @@ def get_processing_chain(
            elif tx_cfg_tmp.get("type", None) == "JBM":
                tx_cfg = {
                    "type": tx_cfg_tmp.get("type", None),
                    "error_pattern": tx_cfg_tmp.get("error_pattern", None),
                    "error_pattern": tx_cfg_tmp.get("error_rate", None),
                    "error_profile": tx_cfg_tmp.get("error_profile", None),
                    "n_frames_per_packet": tx_cfg_tmp.get("n_frames_per_packet", None),
                }
@@ -341,9 +350,9 @@ def get_processing_chain(
                    "out_fmt": dec_cfg.get("fmt", tmp_out_fmt),
                    "out_fs": dec_cfg.get("fs", tmp_in_fs),
                    "bitrate": bitrate,
                    "cod_bin": cod_cfg.get("bin"),
                    "cod_bin": get_abs_path(cod_cfg.get("bin", None)),
                    "cod_opts": cod_cfg.get("opts"),
                    "dec_bin": dec_cfg.get("bin"),
                    "dec_bin": get_abs_path(dec_cfg.get("bin", None)),
                    "dec_opts": dec_cfg.get("opts"),
                    "multiprocessing": cfg.multiprocessing,
                    "tx": tx_cfg,
@@ -372,7 +381,7 @@ def get_processing_chain(
                "bin_dataset": post_cfg.get("bin_dataset"),
                "bin_lfe_gain": post_cfg.get("bin_lfe_gain"),
                "limit": post_cfg.get("limit", True),
                "trajectory": post_cfg.get("trajectory"),
                "trajectory": get_abs_path(post_cfg.get("trajectory", None)),
                "multiprocessing": cfg.multiprocessing,
                "mnru_q": tmp_mnru_q,
                "esdru_alpha": tmp_esdru_alpha,
@@ -381,3 +390,11 @@ def get_processing_chain(
    )

    return chain


def get_abs_path(rel_path):
    if rel_path is not None:
        abs_path = Path(rel_path).resolve().absolute()
    else:
        abs_path = None
    return abs_path
+2 −2
Original line number Diff line number Diff line
@@ -90,8 +90,8 @@ class TestConfig:
        self._yaml_dump = self._dump_yaml(cfg)

        # convert to Path
        self.input_path = Path(self.input_path)
        self.output_path = Path(self.output_path)
        self.input_path = Path(self.input_path).resolve().absolute()
        self.output_path = Path(self.output_path).resolve().absolute()

    def _parse_yaml(self, filename):
        """parse configuration file"""
+3 −3
Original line number Diff line number Diff line
@@ -223,7 +223,7 @@ def preprocess(cfg, logger):

    # update the configuration to use preprocessing outputs as new inputs
    cfg.items_list = list_audio(
        cfg.out_dirs[0], absolute=False, select_list=getattr(cfg, "input_select", None)
        cfg.out_dirs[0], select_list=getattr(cfg, "input_select", None)
    )

    # Re-ordering items based on concatenation order
@@ -274,7 +274,7 @@ def preprocess_2(cfg, logger):

    # update the configuration to use preprocessing 2 outputs as new inputs
    cfg.items_list = list_audio(
        cfg.out_dirs[0], absolute=False, select_list=getattr(cfg, "input_select", None)
        cfg.out_dirs[0], select_list=getattr(cfg, "input_select", None)
    )

    # Re-ordering items based on concatenation order
@@ -313,7 +313,7 @@ def reverse_process_2(cfg, logger):
        # if no concatenation read files from folder
        out_paths_splits = []
        for out_dir in cfg.out_dirs:
            list_audio_dir = list_audio(out_dir, absolute=True)
            list_audio_dir = list_audio(out_dir)
            out_paths_splits.append(list_audio_dir)
        if cfg.postprocessing["fmt"].startswith("ISM"):
            out_meta_splits = []
+8 −16
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ class DirManager:
                )


def list_audio(path: str, absolute: bool = False, select_list: list = None) -> list:
def list_audio(path: str, select_list: list = None) -> list:
    """
    Return list with all files with ALLOWED_INPUT_EXT found under the given path.

@@ -105,23 +105,15 @@ def list_audio(path: str, absolute: bool = False, select_list: list = None) -> l

    if path.exists():
        if path.is_dir():
            if absolute:
                [audio_list.extend(list(path.glob(ext))) for ext in ALLOWED_INPUT_EXT]
            audio_list = [
                    path.joinpath(f)
                f.resolve().absolute()
                for f in path.iterdir()
                if f.suffix in ALLOWED_INPUT_EXT
            ]
        else:
                audio_list = [
                    f for f in path.iterdir() if f.suffix in ALLOWED_INPUT_EXT
                ]
        else:
            if not absolute:
                path = path.name
            ext = path.suffix
            if ext in ALLOWED_INPUT_EXT:
                audio_list.append(path)
                audio_list.append(path.resolve().absolute())

    # filter according to select list
    if select_list:
@@ -168,7 +160,7 @@ def find_binary(
    else:
        if logger:
            logger.debug(f"Found binary {bin}")
        return Path(bin)
        return Path(bin).resolve().absolute()


def get_devnull():