Skip to content

Commit

Permalink
pycodestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobinAV committed Dec 18, 2023
1 parent 4e8df90 commit d7029f5
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_execute_job_to_skip():

assert job.is_skipped()
mck_1.assert_not_called() # The job is expecting to be skipped, so it must not be dispatched
mck_2.assert_called_once_with(job.task) # this must be called to check if the job needs to run
mck_2.assert_called_once_with(job.task) # this must be called to check if the job needs to run
assert not scenario.dn.edit_in_progress # outputs must have been unlocked


Expand All @@ -107,7 +107,7 @@ def test_execute_job_skippable_with_force():
dispatcher = _JobDispatcher(_OrchestratorFactory._orchestrator)
dispatcher._execute_job(job)

mck_1.assert_called_once_with(job) # This should be called to dispatch the job
mck_1.assert_called_once_with(job) # This should be called to dispatch the job
mck_2.assert_not_called() # This should NOT be called since we force the execution anyway
assert job.is_running() # The job is not executed since the dispatch is mocked
assert scenario.dn.edit_in_progress # outputs must NOT have been unlocked because the disptach is mocked
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ def test_need_to_run_skippable_task_with_validity_period_on_output():

assert dispatcher._needs_to_run(task) # output data is not edited

output_edit_time = datetime.now() # edit time
output_edit_time = datetime.now() # edit time
with freezegun.freeze_time(output_edit_time):
task.output["output"].write("Hello world !") # output data is edited

with freezegun.freeze_time(output_edit_time + timedelta(minutes=30)): # 30 min after edit time
assert not dispatcher._needs_to_run(task) # output data is written and validity period not expired

with freezegun.freeze_time(output_edit_time + timedelta(days=1, seconds=1)): # 1 day and 1 second after edit time
with freezegun.freeze_time(output_edit_time + timedelta(days=1, seconds=1)): # 1 day and 1 second after edit time
assert dispatcher._needs_to_run(task) # output data is written but validity period expired

def test_need_to_run_skippable_task_but_input_edited_after_output():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def test_update_job_status_from_future():
dispatcher = _StandaloneJobDispatcher(orchestrator)
ft = Future()
ft.set_result(None)
dispatcher. _set_dispatched_processes(job.id, ft) # the job is dispatched to a process
dispatcher. _set_dispatched_processes(job.id, ft) # the job is dispatched to a process

dispatcher._update_job_status_from_future(job, ft)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ def assert_config_is_correct_after_serialization(n, m):
cfg_as_str = _TomlSerializer()._serialize(Config._applied_config)
res = _TaskFunctionWrapper("job_id", task_asserting_cfg_is_correct).execute(config_as_string=cfg_as_str)

assert len(res) == 0 # no exception raised so the asserts in the fct passed
assert len(res) == 0 # no exception raised so the asserts in the fct passed
1 change: 1 addition & 0 deletions tests/core/_orchestrator/test_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def test_submit_task_multithreading_multiple_task():
assert job_2.is_completed()
assert _SubmissionManager._get(job_2.submit_id).submission_status == SubmissionStatus.COMPLETED


def test_submit_submittable_multithreading_multiple_task():
Config.configure_job_executions(mode=JobConfig._STANDALONE_MODE, max_nb_of_workers=2)

Expand Down
1 change: 1 addition & 0 deletions tests/core/_orchestrator/test_orchestrator__cancel_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def test_cancel_completed_job():

assert job.is_completed()


def test_cancel_completed_job():
job = create_job(Status.SKIPPED)
orchestrator = _OrchestratorFactory._build_orchestrator()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from taipy.core.task._task_manager_factory import _TaskManagerFactory



def nothing(*args, **kwargs):
pass

Expand Down Expand Up @@ -87,6 +86,7 @@ def test_on_status_change_on_completed_job():
orchestrator.blocked_jobs.append(job_1_blocked)
orchestrator.blocked_jobs.append(job_2_to_be_unblocked)
orchestrator.blocked_jobs.append(job_3_blocked)

def mck_is_blocked(job):
if job.id == "to_be_unblocked":
return False
Expand Down Expand Up @@ -117,6 +117,7 @@ def test_on_status_change_on_skipped_job():
orchestrator.blocked_jobs.append(job_1_blocked)
orchestrator.blocked_jobs.append(job_2_to_be_unblocked)
orchestrator.blocked_jobs.append(job_3_blocked)

def mck_is_blocked(job):
if job.id == "to_be_unblocked":
return False
Expand Down
2 changes: 1 addition & 1 deletion tests/core/_orchestrator/test_orchestrator__submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_submit_scenario_development_mode_blocked_jobs():

s_time = datetime.now()
with freezegun.freeze_time(s_time):
jobs = orchestrator.submit(scenario) # first task is blocked because input is not ready
jobs = orchestrator.submit(scenario) # first task is blocked because input is not ready

# dn should be locked for edition
assert scenario.dn_2.edit_in_progress
Expand Down
2 changes: 1 addition & 1 deletion tests/core/_orchestrator/test_orchestrator__submit_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def test_submit_task_standalone_mode_blocked_job():
job = orchestrator.submit_task(sc.t2) # No dispatcher running. t2 is not executed in standalone mode.

# task output should NOT have been written
assert sc.dn_2.last_edit_date == None
assert sc.dn_2.last_edit_date is None

# task output should be locked for edition
assert sc.dn_2.edit_in_progress
Expand Down

0 comments on commit d7029f5

Please sign in to comment.