MCPcopy Create free account
hub / github.com/It4innovations/hyperqueue / test_restore_dependencies1

Function test_restore_dependencies1

tests/test_journal.py:381–418  ·  view source on GitHub ↗
(hq_env: HqEnv, tmp_path)

Source from the content-addressed store, hash-verified

379
380
381def test_restore_dependencies1(hq_env: HqEnv, tmp_path):
382 journal_path = os.path.join(tmp_path, "my.journal")
383 hq_env.start_server(args=["--journal", journal_path])
384 hq_env.start_worker(cpus=2)
385 tmp_path.joinpath("sleep_time").write_text("100")
386 tmp_path.joinpath("job.toml").write_text(
387 """
388[[task]]
389id = 1
390command = ["touch", "a"]
391
392[[task]]
393id = 2
394command = ["bash", "-c", "sleep `cat sleep_time` && touch b"]
395
396[[task]]
397id = 3
398command = ["touch", "c"]
399deps = [1, 2]
400 """
401 )
402 hq_env.command(["job", "submit-file", "job.toml"])
403 wait_for_task_state(hq_env, 1, [1, 2, 3], ["finished", "running", "waiting"])
404 hq_env.stop_server()
405 assert os.path.isfile("a")
406 assert not os.path.isfile("b")
407 assert not os.path.isfile("c")
408 os.unlink("a")
409
410 tmp_path.joinpath("sleep_time").write_text("0")
411
412 hq_env.start_server(args=["--journal", journal_path])
413 hq_env.start_worker()
414 wait_for_job_state(hq_env, 1, "FINISHED")
415
416 assert not os.path.isfile("a")
417 assert os.path.isfile("b")
418 assert os.path.isfile("c")
419
420
421def test_restore_dependencies2(hq_env: HqEnv, tmp_path):

Callers

nothing calls this directly

Calls 6

wait_for_task_stateFunction · 0.85
wait_for_job_stateFunction · 0.85
commandMethod · 0.80
start_serverMethod · 0.45
start_workerMethod · 0.45
stop_serverMethod · 0.45

Tested by

no test coverage detected