File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,6 +62,10 @@ def scan_artifacts(
6262 (not necessarily an `artifacts/` subdir), so this scan can include the whole
6363 run directory.
6464
65+ Hidden files and directories are omitted from the artifact list so workspace
66+ internals such as `.git`, `.venv`, and dotfiles do not appear in the
67+ dashboard Files tab.
68+
6569 `exclude_dirs` should contain directory names (not paths) to skip.
6670 """
6771 if not base_dir .exists ():
@@ -71,10 +75,15 @@ def scan_artifacts(
7175
7276 entries : list [ArtifactEntry ] = []
7377 for root , dirs , files in os .walk (base_dir ):
74- # prune excluded dirs
75- dirs [:] = [d for d in dirs if d not in exclude_dirs ]
78+ # Prune excluded and hidden dirs in-place so os.walk never descends
79+ # into entries such as .git or .venv.
80+ dirs [:] = [
81+ d for d in dirs if d not in exclude_dirs and not d .startswith ("." )
82+ ]
7683
7784 for fn in files :
85+ if fn .startswith ("." ):
86+ continue
7887 p = Path (root ) / fn
7988 if not p .is_file ():
8089 continue
Original file line number Diff line number Diff line change 1+ from __future__ import annotations
2+
3+ from pathlib import Path
4+
5+ from ursa_dashboard .artifacts import scan_artifacts
6+
7+
8+ def _touch (path : Path , text : str = "x" ) -> None :
9+ path .parent .mkdir (parents = True , exist_ok = True )
10+ path .write_text (text )
11+
12+
13+ def test_scan_artifacts_hides_dotfiles_and_hidden_directories (
14+ tmp_path : Path ,
15+ ) -> None :
16+ _touch (tmp_path / "visible.txt" )
17+ _touch (tmp_path / ".hidden.txt" )
18+ _touch (tmp_path / ".git" / "config" )
19+ _touch (tmp_path / ".venv" / "pyvenv.cfg" )
20+ _touch (tmp_path / "outputs" / "result.txt" )
21+ _touch (tmp_path / "outputs" / ".secret" )
22+ _touch (tmp_path / "outputs" / ".cache" / "data.json" )
23+
24+ rel_paths = {entry ["rel_path" ] for entry in scan_artifacts (tmp_path )}
25+
26+ assert rel_paths == {"outputs/result.txt" , "visible.txt" }
You can’t perform that action at this time.
0 commit comments