@@ -62,6 +62,37 @@ def test_subrepo(proj_path):
6262 assert node_loaded .outs == {"param1" : 3 , "param2" : 4 }
6363
6464
65+ def test_from_rev_in_subrepo (proj_path ):
66+ """Test loading a node with from_rev when cwd is inside a subrepo.
67+
68+ This tests the scenario where:
69+ 1. The DVC repo root is at the parent directory
70+ 2. The project is in a subdirectory
71+ 3. The user is inside that subdirectory
72+ 4. The user calls zntrack.from_rev("NodeName") without specifying a path
73+
74+ This should work because the zntrack.json and other files are in the
75+ current directory. The path should NOT be duplicated.
76+ """
77+ directory = pathlib .Path ("subrepo" )
78+ directory .mkdir (parents = True , exist_ok = True )
79+ os .chdir (directory )
80+
81+ project = zntrack .Project ()
82+ with project :
83+ _ = zntrack .examples .ParamsToOuts (
84+ params = {"param1" : 1 , "param2" : 2 },
85+ )
86+ project .repro ()
87+
88+ # Now we're inside the subdirectory and want to load the node
89+ # This should work - we shouldn't need to specify the path since
90+ # zntrack.json is in the current directory
91+ node_loaded = zntrack .from_rev ("ParamsToOuts" )
92+ assert node_loaded .params == {"param1" : 1 , "param2" : 2 }
93+ assert node_loaded .outs == {"param1" : 1 , "param2" : 2 }
94+
95+
6596def test_subrepo_external_node (proj_path ):
6697 """Test subrepo functionality with external dataclasses."""
6798 # Create external node module file that can be imported
0 commit comments