MDANSE icon indicating copy to clipboard operation
MDANSE copied to clipboard

Rework job status

Open oerc0122 opened this issue 10 months ago • 4 comments

Description of work Rework Job status information to remove redundancy and duplication and unify approaches between script-based and GUI-based running.

Fixes

  • Fixes #733
  • Turn JobState from an arbitrary dict to an actual constructed class (JobInfo) allowing reuse wherever job information is handled (GUI or script)
  • Replace multiple implementations of JobState (MDANSE.Framework.Jobs.JobStatus, MDANSE_GUI.Subprocess.JobState) with single Enum to unify GUI and scripts.

To test GUI should run and operate normally.

oerc0122 avatar Apr 23 '25 12:04 oerc0122

The code definitely looks better this way.

One problem so far seems to be this recurring error message when running jobs:

2025-04-25 08:31:55,232 - INFO - process[7394] - JobHolder 206 - Item received on_started: 100001 total steps
2025-04-25 08:31:55,231 - INFO - process[7823] - JobStatusProcess 134 - JobStatusProcess PID: 7394 started 'start_status'
2025-04-25 08:31:55,232 - INFO - process[7823] - IJob 262 - Single-core run: expects 100001 steps
2025-04-25 08:31:57,618 - ERROR - process[7394] - main 35 - EXCEPTION:
<class 'ValueError'>
too many values to unpack (expected 2)
<traceback object at 0x3616f4900>
Traceback (most recent call last):
  File "MDANSE_GUI/Src/MDANSE_GUI/Tabs/Visualisers/JobLogInfo.py", line 27, in update_panel
    msgs, levels = incoming
    ^^^^^^^^^^^^
ValueError: too many values to unpack (expected 2)
2025-04-25 08:32:04,993 - INFO - process[7394] - RunTable 131 - QMessageBox result = 16384
2025-04-25 08:32:06,345 - INFO - process[7394] - JobStatusProcess 62 - Communication with the subprocess is now False
2025-04-25 08:32:06,345 - INFO - process[7394] - JobStatusProcess 76 - JobCommunicator PID: 7394 started 'terminate_the_process'
2025-04-25 08:32:06,832 - ERROR - process[7394] - main 35 - EXCEPTION:
<class 'ValueError'>
not enough values to unpack (expected 2, got 0)
<traceback object at 0x3616f62c0>
Traceback (most recent call last):
  File "MDANSE_GUI/Src/MDANSE_GUI/Tabs/Visualisers/JobLogInfo.py", line 27, in update_panel
    msgs, levels = incoming
    ^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 0)

MBartkowiakSTFC avatar Apr 25 '25 07:04 MBartkowiakSTFC

Issue occurs when selecting item from RunTable tab, due to JobLogInfo being a subclass of TextInfo and thus type() is checking exact types, but isinstance checking subclasses.

oerc0122 avatar Apr 25 '25 13:04 oerc0122

One side problem is that the changes here will make the unit tests fail: MDANSE_GUI/Tests/UnitTests/test_JobState.py It is not a problem for now, but it will come back when #704 is ready.

Would you prefer to fix it now, or in #704? BTW, it may be enough to replace the current tests in test_JobState.py with

def test_start(temporary_jobentry: JobEntry):
    temporary_jobentry.start_job()
    assert temporary_jobentry.job.state is JobStates.RUNNING

def test_fail(temporary_jobentry: JobEntry):
    temporary_jobentry.fail_job()
    assert temporary_jobentry.job.state is JobStates.FAILED

MBartkowiakSTFC avatar May 19 '25 09:05 MBartkowiakSTFC

One side problem is that the changes here will make the unit tests fail: MDANSE_GUI/Tests/UnitTests/test_JobState.py It is not a problem for now, but it will come back when #704 is ready.

Would you prefer to fix it now, or in #704? BTW, it may be enough to replace the current tests in test_JobState.py with

def test_start(temporary_jobentry: JobEntry):
    temporary_jobentry.start_job()
    assert temporary_jobentry.job.state is JobStates.RUNNING

def test_fail(temporary_jobentry: JobEntry):
    temporary_jobentry.fail_job()
    assert temporary_jobentry.job.state is JobStates.FAILED

Those are the updated tests checking against the Enum.

oerc0122 avatar May 20 '25 12:05 oerc0122

Everything looks fine. Only the GUI unit tests still seem to have a problem when I run them.

test_FileObject.py .                                                                                                     [  6%]
test_GeneralModel.py ...                                                                                                 [ 25%]
test_JobState.py FF                                                                                                      [ 37%]
test_PlottingContext.py .......                                                                                          [ 81%]
test_SettingsFile.py ..                                                                                                  [ 93%]
test_hdf5wrapper.py .                                                                                                    [100%]

=========================================================== FAILURES ===========================================================
__________________________________________________________ test_start __________________________________________________________

temporary_jobentry = <MDANSE_GUI.Tabs.Models.JobHolder.JobEntry object at 0x17753a320>

    def test_start(temporary_jobentry: JobEntry):
>       temporary_jobentry.job.state.start()
E       AttributeError: 'JobStates' object has no attribute 'start'

test_JobState.py:13: AttributeError
__________________________________________________________ test_fail ___________________________________________________________

temporary_jobentry = <MDANSE_GUI.Tabs.Models.JobHolder.JobEntry object at 0x17753a320>

    def test_fail(temporary_jobentry: JobEntry):
>       temporary_jobentry.job.state.fail()
E       AttributeError: 'JobStates' object has no attribute 'fail'

test_JobState.py:18: AttributeError
=================================================== short test summary info ====================================================
FAILED test_JobState.py::test_start - AttributeError: 'JobStates' object has no attribute 'start'
FAILED test_JobState.py::test_fail - AttributeError: 'JobStates' object has no attribute 'fail'

MBartkowiakSTFC avatar Jun 03 '25 09:06 MBartkowiakSTFC