Skip to content

datarobot_genai.eval.utils

utils

make_run_id

make_run_id() -> str

Timestamp identifying a single run.

Microsecond precision, not seconds: the run ID names both the raw artifact directory and (by default) the archived results file, so two runs starting in the same second would otherwise overwrite each other's output. The format stays lexically sortable, which is what consumers listing the output directory rely on to order runs by name.

Source code in datarobot_genai/eval/utils.py
def make_run_id() -> str:
    """Timestamp identifying a single run.

    Microsecond precision, not seconds: the run ID names both the raw artifact
    directory and (by default) the archived results file, so two runs starting
    in the same second would otherwise overwrite each other's output. The format
    stays lexically sortable, which is what consumers listing the output
    directory rely on to order runs by name.
    """
    return datetime.now().strftime("%Y%m%d_%H%M%S_%f")

resolve_archive_name

resolve_archive_name(output_name: str | None, pipeline: str, run_id: str) -> str

Filename for a run's archived results copy, relative to the output dir.

Defaults to <pipeline stem>_<run_id>.json so successive runs of the same pipeline are self-describing, sort chronologically, and never overwrite one another. An explicit output_name must be a bare filename: the archive always lands in the output directory, and a path would let it escape.

Source code in datarobot_genai/eval/utils.py
def resolve_archive_name(output_name: str | None, pipeline: str, run_id: str) -> str:
    """Filename for a run's archived results copy, relative to the output dir.

    Defaults to ``<pipeline stem>_<run_id>.json`` so successive runs of the same
    pipeline are self-describing, sort chronologically, and never overwrite one
    another. An explicit ``output_name`` must be a bare filename: the archive
    always lands in the output directory, and a path would let it escape.
    """
    if output_name:
        name = output_name if output_name.endswith(".json") else f"{output_name}.json"
        if Path(name).name != name or name.startswith("."):
            raise ValueError(
                f"Output name must be a bare filename with no directory separators "
                f"and no leading dot, got {output_name!r}"
            )
    else:
        name = f"{Path(pipeline).stem}_{run_id}.json"

    if name in RESERVED_OUTPUT_NAMES:
        reserved = ", ".join(sorted(RESERVED_OUTPUT_NAMES))
        raise ValueError(f"Output name may not be one of the reserved names: {reserved}")
    return name