mirror of
https://github.com/Graphify-Labs/graphify.git
synced 2026-09-14 19:34:09 +08:00
b8dc31f760
The GRAPHIFY_OUT override (custom output-dir name / absolute path, #686) was only respected by some readers. `graphify extract` and several commands hardcoded the literal "graphify-out", so `GRAPHIFY_OUT=custom-out graphify extract` still wrote to graphify-out/ and downstream query/serve/update looked in the wrong place. Resolve the output-dir name through graphify.paths everywhere it matters: - new graphify.paths.out_path()/default_graph_json() helpers - __main__: extract write dir, cluster-only/label, query/affected/benchmark defaults, save-result --memory-dir, uninstall --purge, cache-check - detect: _MANIFEST_PATH, memory/ + converted/ dirs, and the scan-exclude (a renamed output dir is no longer re-ingested as source input) - transcribe._TRANSCRIPTS_DIR; build_merge/serve/benchmark/prs graph-path defaults Default behaviour is unchanged: with no env var everything still uses graphify-out/. Verified end-to-end (extract -> cluster-only -> query under GRAPHIFY_OUT=custom-out writes/reads custom-out/, no stray graphify-out/) and added a CLI regression test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
47 lines
1.9 KiB
Python
47 lines
1.9 KiB
Python
"""Single source of truth for the graphify output-directory name.
|
|
|
|
The output directory is ``graphify-out`` by default and overridable with the
|
|
``GRAPHIFY_OUT`` env var (worktrees or shared-output setups, #686). It accepts a
|
|
relative name (``"graphify-out-feature"``) or an absolute path
|
|
(``"/shared/graphify-out"``).
|
|
|
|
This used to be duplicated as an identical ``_GRAPHIFY_OUT`` constant in
|
|
``__main__``, ``cache``, and ``watch``, while ``security`` and ``callflow_html``
|
|
hardcoded the literal ``"graphify-out"`` and silently ignored the override
|
|
(#1423). Centralising it here keeps the name in one place. The value is read
|
|
once at import time, matching the previous per-module constants — set
|
|
``GRAPHIFY_OUT`` before the process starts (the normal worktree/shared-output
|
|
flow) and every reader honours it.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
GRAPHIFY_OUT = os.environ.get("GRAPHIFY_OUT", "graphify-out")
|
|
|
|
# Bare directory name even when GRAPHIFY_OUT is an absolute path. Used by the
|
|
# path guards that walk parents looking for the output dir by name, and by the
|
|
# detect scan-exclude so a custom output dir is never re-ingested as source.
|
|
GRAPHIFY_OUT_NAME = os.path.basename(os.path.normpath(GRAPHIFY_OUT))
|
|
|
|
|
|
def out_path(*parts: str) -> Path:
|
|
"""A path inside the configured output dir, e.g. ``out_path("cache")``.
|
|
|
|
``Path(GRAPHIFY_OUT) / ...`` resolves correctly for both a relative name
|
|
("graphify-out") and an absolute override ("/shared/graphify-out").
|
|
"""
|
|
return Path(GRAPHIFY_OUT, *parts)
|
|
|
|
|
|
def default_graph_json() -> str:
|
|
"""Default ``graph.json`` path under the configured output dir.
|
|
|
|
The package-wide fallback used by serve/build/benchmark/prs and the CLI read
|
|
commands so a ``GRAPHIFY_OUT`` override is honoured everywhere, not just where
|
|
the path is passed explicitly (#1423).
|
|
"""
|
|
return str(out_path("graph.json"))
|