File tree Expand file tree Collapse file tree 3 files changed +51
-2
lines changed Expand file tree Collapse file tree 3 files changed +51
-2
lines changed Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ def __init__(self, dvc_dir):
171
171
# need to convert our config to dict before passing it to
172
172
self ._config = self ._lower (self ._config )
173
173
local = self ._lower (local )
174
- self ._config . update ( local )
174
+ self ._config = self . _merge ( self . _config , local )
175
175
176
176
self ._config = Schema (self .SCHEMA ).validate (self ._config )
177
177
@@ -182,6 +182,17 @@ def __init__(self, dvc_dir):
182
182
except Exception as ex :
183
183
raise ConfigError (ex )
184
184
185
+ @staticmethod
186
+ def _merge (first , second ):
187
+ res = {}
188
+ sections = list (first .keys ()) + list (second .keys ())
189
+ for section in sections :
190
+ f = first .get (section , {}).copy ()
191
+ s = second .get (section , {}).copy ()
192
+ f .update (s )
193
+ res [section ] = f
194
+ return res
195
+
185
196
@staticmethod
186
197
def _lower (config ):
187
198
new_config = {}
Original file line number Diff line number Diff line change @@ -96,7 +96,20 @@ def dump(self):
96
96
97
97
@staticmethod
98
98
def mtime (path ):
99
- return str (int (nanotime .timestamp (os .path .getmtime (path ))))
99
+ if os .path .isdir (path ):
100
+ mtime = - 1
101
+ for root , dirs , files in os .walk (path ):
102
+ for fname in files :
103
+ f = os .path .join (root , fname )
104
+ m = os .path .getmtime (f )
105
+ if m > mtime :
106
+ mtime = m
107
+ if mtime == - 1 :
108
+ mtime = os .path .getmtime (path )
109
+ else :
110
+ mtime = os .path .getmtime (path )
111
+
112
+ return str (int (nanotime .timestamp (mtime )))
100
113
101
114
@staticmethod
102
115
def inode (path ):
Original file line number Diff line number Diff line change @@ -255,6 +255,31 @@ def test(self):
255
255
self .assertEqual (len (stages ), 1 )
256
256
257
257
258
+ class TestReproChangedDirData (TestDvc ):
259
+ def test (self ):
260
+ dir_name = 'dir'
261
+ dir_code = 'dir_code.py'
262
+ with open (dir_code , 'w+' ) as fd :
263
+ fd .write ("import os; import sys; import shutil; shutil.copytree(sys.argv[1], sys.argv[2])" )
264
+
265
+ stage = self .dvc .run (outs = [dir_name ],
266
+ deps = [self .DATA_DIR , dir_code ],
267
+ cmd = "python {} {} {}" .format (dir_code ,
268
+ self .DATA_DIR ,
269
+ dir_name ))
270
+ self .assertTrue (stage is not None )
271
+
272
+ stages = self .dvc .reproduce (stage .path )
273
+ self .assertEqual (len (stages ), 0 )
274
+
275
+ with open (self .DATA_SUB , 'a' ) as fd :
276
+ fd .write ('add' )
277
+
278
+ stages = self .dvc .reproduce (stage .path )
279
+ self .assertEqual (len (stages ), 1 )
280
+ self .assertTrue (stages [0 ] is not None )
281
+
282
+
258
283
class TestReproMissingMd5InStageFile (TestRepro ):
259
284
def test (self ):
260
285
with open (self .file1_stage , 'r' ) as fd :
You can’t perform that action at this time.
0 commit comments