@@ -210,63 +210,62 @@ def instance(self):
210210 return DummyProtocol (settings = DummyProtocol .default_settings ())
211211
212212 @pytest .fixture
213- def protocol_dag (self , solvated_ligand , vacuum_ligand , tmpdir ):
213+ def protocol_dag (self , solvated_ligand , vacuum_ligand , tmp_path ):
214214 protocol = DummyProtocol (settings = DummyProtocol .default_settings ())
215215 dag = protocol .create (
216216 stateA = solvated_ligand ,
217217 stateB = vacuum_ligand ,
218218 name = "a dummy run" ,
219219 mapping = None ,
220220 )
221- with tmpdir .as_cwd ():
222- shared = pathlib .Path ("shared" )
223- shared .mkdir (parents = True )
224221
225- scratch = pathlib .Path ("scratch " )
226- scratch .mkdir (parents = True )
222+ shared = pathlib .Path (tmp_path / "shared " )
223+ shared .mkdir (parents = True )
227224
228- stderr = pathlib .Path ("stderr " )
229- stderr .mkdir (parents = True )
225+ scratch = pathlib .Path (tmp_path / "scratch " )
226+ scratch .mkdir (parents = True )
230227
231- stdout = pathlib .Path ("stdout " )
232- stdout .mkdir (parents = True )
228+ stderr = pathlib .Path (tmp_path / "stderr " )
229+ stderr .mkdir (parents = True )
233230
234- dagresult : ProtocolDAGResult = execute_DAG (
235- dag , shared_basedir = shared , scratch_basedir = scratch , stderr_basedir = stderr , stdout_basedir = stdout
236- )
231+ stdout = pathlib .Path (tmp_path / "stdout" )
232+ stdout .mkdir (parents = True )
233+
234+ dagresult : ProtocolDAGResult = execute_DAG (
235+ dag , shared_basedir = shared , scratch_basedir = scratch , stderr_basedir = stderr , stdout_basedir = stdout
236+ )
237237
238238 return protocol , dag , dagresult
239239
240240 @pytest .fixture
241- def protocol_dag_broken (self , solvated_ligand , vacuum_ligand , tmpdir ):
241+ def protocol_dag_broken (self , solvated_ligand , vacuum_ligand , tmp_path ):
242242 protocol = BrokenProtocol (settings = BrokenProtocol .default_settings ())
243243 dag = protocol .create (
244244 stateA = solvated_ligand ,
245245 stateB = vacuum_ligand ,
246246 name = "a broken dummy run" ,
247247 mapping = None ,
248248 )
249- with tmpdir .as_cwd ():
250- shared = pathlib .Path ("shared" )
251- shared .mkdir (parents = True )
249+ shared = pathlib .Path (tmp_path / "shared" )
250+ shared .mkdir (parents = True )
252251
253- scratch = pathlib .Path ("scratch" )
254- scratch .mkdir (parents = True )
252+ scratch = pathlib .Path (tmp_path / "scratch" )
253+ scratch .mkdir (parents = True )
255254
256- stderr = pathlib .Path ("stderr" )
257- stderr .mkdir (parents = True )
255+ stderr = pathlib .Path (tmp_path / "stderr" )
256+ stderr .mkdir (parents = True )
258257
259- stdout = pathlib .Path ("stdout" )
260- stdout .mkdir (parents = True )
258+ stdout = pathlib .Path (tmp_path / "stdout" )
259+ stdout .mkdir (parents = True )
261260
262- dagfailure : ProtocolDAGResult = execute_DAG (
263- dag ,
264- shared_basedir = shared ,
265- scratch_basedir = scratch ,
266- stderr_basedir = stderr ,
267- stdout_basedir = stdout ,
268- raise_error = False ,
269- )
261+ dagfailure : ProtocolDAGResult = execute_DAG (
262+ dag ,
263+ shared_basedir = shared ,
264+ scratch_basedir = scratch ,
265+ stderr_basedir = stderr ,
266+ stdout_basedir = stdout ,
267+ raise_error = False ,
268+ )
270269
271270 return protocol , dag , dagfailure
272271
@@ -381,28 +380,27 @@ def test_dag_execute_failure(self, protocol_dag_broken):
381380
382381 assert len (succeeded_units ) > 0
383382
384- def test_dag_execute_failure_raise_error (self , solvated_ligand , vacuum_ligand , tmpdir ):
383+ def test_dag_execute_failure_raise_error (self , solvated_ligand , vacuum_ligand , tmp_path ):
385384 protocol = BrokenProtocol (settings = BrokenProtocol .default_settings ())
386385 dag = protocol .create (
387386 stateA = solvated_ligand ,
388387 stateB = vacuum_ligand ,
389388 name = "a broken dummy run" ,
390389 mapping = None ,
391390 )
392- with tmpdir .as_cwd ():
393- shared = pathlib .Path ("shared" )
394- shared .mkdir (parents = True )
395-
396- scratch = pathlib .Path ("scratch" )
397- scratch .mkdir (parents = True )
398-
399- with pytest .raises (ValueError , match = "I have failed my mission" ):
400- execute_DAG (
401- dag ,
402- shared_basedir = shared ,
403- scratch_basedir = scratch ,
404- raise_error = True ,
405- )
391+ shared = pathlib .Path (tmp_path / "shared" )
392+ shared .mkdir (parents = True )
393+
394+ scratch = pathlib .Path (tmp_path / "scratch" )
395+ scratch .mkdir (parents = True )
396+
397+ with pytest .raises (ValueError , match = "I have failed my mission" ):
398+ execute_DAG (
399+ dag ,
400+ shared_basedir = shared ,
401+ scratch_basedir = scratch ,
402+ raise_error = True ,
403+ )
406404
407405 def test_create_execute_gather (self , protocol_dag ):
408406 protocol , dag , dagresult = protocol_dag
@@ -651,15 +649,14 @@ def dag(self, protocol):
651649 def test_create (self , dag ):
652650 assert len (dag .protocol_units ) == 3
653651
654- def test_gather (self , protocol , dag , tmpdir ):
655- with tmpdir .as_cwd ():
656- shared = pathlib .Path ("shared" )
657- shared .mkdir (parents = True )
652+ def test_gather (self , protocol , dag , tmp_path ):
653+ shared = pathlib .Path (tmp_path / "shared" )
654+ shared .mkdir (parents = True )
658655
659- scratch = pathlib .Path ("scratch" )
660- scratch .mkdir (parents = True )
656+ scratch = pathlib .Path (tmp_path / "scratch" )
657+ scratch .mkdir (parents = True )
661658
662- dag_result = execute_DAG (dag , shared_basedir = shared , scratch_basedir = scratch )
659+ dag_result = execute_DAG (dag , shared_basedir = shared , scratch_basedir = scratch )
663660
664661 assert dag_result .ok ()
665662
@@ -668,16 +665,15 @@ def test_gather(self, protocol, dag, tmpdir):
668665 assert result .get_estimate () == 0 + 1 + 4
669666 assert result .get_uncertainty () == 3
670667
671- def test_terminal_units (self , protocol , dag , tmpdir ):
672- with tmpdir .as_cwd ():
673- shared = pathlib .Path ("shared" )
674- shared .mkdir (parents = True )
668+ def test_terminal_units (self , protocol , dag , tmp_path ):
669+ shared = pathlib .Path (tmp_path / "shared" )
670+ shared .mkdir (parents = True )
675671
676- scratch = pathlib .Path ("scratch" )
677- scratch .mkdir (parents = True )
672+ scratch = pathlib .Path (tmp_path / "scratch" )
673+ scratch .mkdir (parents = True )
678674
679- # we have no dependencies, so this should be all three Unit results
680- dag_result = execute_DAG (dag , shared_basedir = shared , scratch_basedir = scratch )
675+ # we have no dependencies, so this should be all three Unit results
676+ dag_result = execute_DAG (dag , shared_basedir = shared , scratch_basedir = scratch )
681677
682678 terminal_results = dag_result .terminal_protocol_unit_results
683679
@@ -798,67 +794,65 @@ def test_foreign_objects(self, units, successes):
798794 dagresult .result_to_unit (successes [2 ])
799795
800796
801- def test_execute_DAG_retries (solvated_ligand , vacuum_ligand , tmpdir ):
797+ def test_execute_DAG_retries (solvated_ligand , vacuum_ligand , tmp_path ):
802798 protocol = BrokenProtocol (settings = BrokenProtocol .default_settings ())
803799 dag = protocol .create (
804800 stateA = solvated_ligand ,
805801 stateB = vacuum_ligand ,
806802 mapping = None ,
807803 )
808804
809- with tmpdir .as_cwd ():
810- shared = pathlib .Path ("shared" )
811- shared .mkdir (parents = True )
812- scratch = pathlib .Path ("scratch" )
813- scratch .mkdir (parents = True )
814-
815- r = execute_DAG (
816- dag ,
817- shared_basedir = shared ,
818- scratch_basedir = scratch ,
819- keep_shared = True ,
820- keep_scratch = True ,
821- raise_error = False ,
822- n_retries = 3 ,
823- )
805+ shared = pathlib .Path (tmp_path / "shared" )
806+ shared .mkdir (parents = True )
807+ scratch = pathlib .Path (tmp_path / "scratch" )
808+ scratch .mkdir (parents = True )
809+
810+ r = execute_DAG (
811+ dag ,
812+ shared_basedir = shared ,
813+ scratch_basedir = scratch ,
814+ keep_shared = True ,
815+ keep_scratch = True ,
816+ raise_error = False ,
817+ n_retries = 3 ,
818+ )
824819
825- assert not r .ok ()
820+ assert not r .ok ()
826821
827- number_unit_failures = len (r .protocol_unit_failures )
828- number_unit_results = len (r .protocol_unit_results )
829- number_dirs = len (list (shared .iterdir ()))
822+ number_unit_failures = len (r .protocol_unit_failures )
823+ number_unit_results = len (r .protocol_unit_results )
824+ number_dirs = len (list (shared .iterdir ()))
830825
831- # failed first attempt of BrokenSimulationUnit, failed 3 retries
832- assert number_unit_failures == 4
833- # InitializeUnit and 21 SimulationUnits run before guaranteed
834- # final failure
835- assert number_unit_results == number_dirs == 26
826+ # failed first attempt of BrokenSimulationUnit, failed 3 retries
827+ assert number_unit_failures == 4
828+ # InitializeUnit and 21 SimulationUnits run before guaranteed
829+ # final failure
830+ assert number_unit_results == number_dirs == 26
836831
837832
838- def test_execute_DAG_bad_nretries (solvated_ligand , vacuum_ligand , tmpdir ):
833+ def test_execute_DAG_bad_nretries (solvated_ligand , vacuum_ligand , tmp_path ):
839834 protocol = BrokenProtocol (settings = BrokenProtocol .default_settings ())
840835 dag = protocol .create (
841836 stateA = solvated_ligand ,
842837 stateB = vacuum_ligand ,
843838 mapping = None ,
844839 )
845840
846- with tmpdir .as_cwd ():
847- shared = pathlib .Path ("shared" )
848- shared .mkdir (parents = True )
849- scratch = pathlib .Path ("scratch" )
850- scratch .mkdir (parents = True )
841+ shared = pathlib .Path (tmp_path / "shared" )
842+ shared .mkdir (parents = True )
843+ scratch = pathlib .Path (tmp_path / "scratch" )
844+ scratch .mkdir (parents = True )
851845
852- with pytest .raises (ValueError ):
853- r = execute_DAG (
854- dag ,
855- shared_basedir = shared ,
856- scratch_basedir = scratch ,
857- keep_shared = True ,
858- keep_scratch = True ,
859- raise_error = False ,
860- n_retries = - 1 ,
861- )
846+ with pytest .raises (ValueError ):
847+ r = execute_DAG (
848+ dag ,
849+ shared_basedir = shared ,
850+ scratch_basedir = scratch ,
851+ keep_shared = True ,
852+ keep_scratch = True ,
853+ raise_error = False ,
854+ n_retries = - 1 ,
855+ )
862856
863857
864858def test_settings_readonly ():
0 commit comments