Skip to content

Commit

Permalink
Simplify openpbs job states
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindjahren committed Jul 25, 2024
1 parent a51790c commit 38220a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/ert/scheduler/openpbs_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
Type,
Union,
cast,
get_args,
get_type_hints,
)

Expand All @@ -30,7 +29,7 @@
logger = logging.getLogger(__name__)

_POLL_PERIOD = 2.0 # seconds
JobState = Literal[
JOB_STATES = [
"B", # Begun
"E", # Exiting with or without errors
"F", # Finished (completed, failed or deleted)
Expand Down Expand Up @@ -119,7 +118,7 @@ def parse_qstat(qstat_output: str) -> Dict[str, Dict[str, str]]:
continue
tokens = line.split(maxsplit=6)
if len(tokens) >= 5 and tokens[0] and tokens[5]:
if tokens[4] not in get_args(JobState):
if tokens[4] not in JOB_STATES:
logger.error(
f"Unknown state {tokens[4]} obtained from "
f"PBS for jobid {tokens[0]}, ignored."
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/scheduler/test_openpbs_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

from ert.scheduler import OpenPBSDriver
from ert.scheduler.openpbs_driver import (
JOB_STATES,
QDEL_JOB_HAS_FINISHED,
QDEL_REQUEST_INVALID,
QSUB_CONNECTION_REFUSED,
QSUB_INVALID_CREDENTIAL,
QSUB_PREMATURE_END_OF_MESSAGE,
FinishedEvent,
FinishedJob,
JobState,
QueuedJob,
RunningJob,
StartedEvent,
Expand All @@ -32,7 +32,7 @@
)


@given(st.lists(st.sampled_from(JobState.__args__)))
@given(st.lists(st.sampled_from(JOB_STATES)))
async def test_events_produced_from_jobstate_updates(jobstate_sequence: List[str]):
# Determine what to expect from the sequence:
started = False
Expand Down

0 comments on commit 38220a4

Please sign in to comment.