Skip to content

Commit

Permalink
Move duplicate ev_types to ert/event_type_constants.py
Browse files Browse the repository at this point in the history
This commit moves duplicate event type constants found in `job_queue/queue.py` and `ensemble_evaluator/identifiers.py` into a common module `ert/event_type_constants.py`
  • Loading branch information
jonathan-eq committed Apr 17, 2024
1 parent 5ba5b09 commit 29d0fe4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 23 deletions.
26 changes: 14 additions & 12 deletions src/ert/ensemble_evaluator/identifiers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
from ert.event_type_constants import (
EVTYPE_ENSEMBLE_CANCELLED,
EVTYPE_ENSEMBLE_FAILED,
EVTYPE_ENSEMBLE_STARTED,
EVTYPE_ENSEMBLE_STOPPED,
EVTYPE_REALIZATION_FAILURE,
EVTYPE_REALIZATION_PENDING,
EVTYPE_REALIZATION_RUNNING,
EVTYPE_REALIZATION_SUCCESS,
EVTYPE_REALIZATION_TIMEOUT,
EVTYPE_REALIZATION_UNKNOWN,
EVTYPE_REALIZATION_WAITING,
)

ACTIVE = "active"
CURRENT_MEMORY_USAGE = "current_memory_usage"
DATA = "data"
Expand All @@ -17,14 +31,6 @@
STDOUT = "stdout"
STEPS = "steps"

EVTYPE_REALIZATION_FAILURE = "com.equinor.ert.realization.failure"
EVTYPE_REALIZATION_PENDING = "com.equinor.ert.realization.pending"
EVTYPE_REALIZATION_RUNNING = "com.equinor.ert.realization.running"
EVTYPE_REALIZATION_SUCCESS = "com.equinor.ert.realization.success"
EVTYPE_REALIZATION_UNKNOWN = "com.equinor.ert.realization.unknown"
EVTYPE_REALIZATION_WAITING = "com.equinor.ert.realization.waiting"
EVTYPE_REALIZATION_TIMEOUT = "com.equinor.ert.realization.timeout"

EVTYPE_FORWARD_MODEL_START = "com.equinor.ert.forward_model_job.start"
EVTYPE_FORWARD_MODEL_RUNNING = "com.equinor.ert.forward_model_job.running"
EVTYPE_FORWARD_MODEL_SUCCESS = "com.equinor.ert.forward_model_job.success"
Expand Down Expand Up @@ -56,10 +62,6 @@
EVTYPE_EE_USER_CANCEL = "com.equinor.ert.ee.user_cancel"
EVTYPE_EE_USER_DONE = "com.equinor.ert.ee.user_done"

EVTYPE_ENSEMBLE_STARTED = "com.equinor.ert.ensemble.started"
EVTYPE_ENSEMBLE_STOPPED = "com.equinor.ert.ensemble.stopped"
EVTYPE_ENSEMBLE_CANCELLED = "com.equinor.ert.ensemble.cancelled"
EVTYPE_ENSEMBLE_FAILED = "com.equinor.ert.ensemble.failed"

EVGROUP_ENSEMBLE = {
EVTYPE_ENSEMBLE_STARTED,
Expand Down
12 changes: 12 additions & 0 deletions src/ert/event_type_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
EVTYPE_REALIZATION_FAILURE = "com.equinor.ert.realization.failure"
EVTYPE_REALIZATION_PENDING = "com.equinor.ert.realization.pending"
EVTYPE_REALIZATION_RUNNING = "com.equinor.ert.realization.running"
EVTYPE_REALIZATION_SUCCESS = "com.equinor.ert.realization.success"
EVTYPE_REALIZATION_UNKNOWN = "com.equinor.ert.realization.unknown"
EVTYPE_REALIZATION_WAITING = "com.equinor.ert.realization.waiting"
EVTYPE_REALIZATION_TIMEOUT = "com.equinor.ert.realization.timeout"

EVTYPE_ENSEMBLE_STARTED = "com.equinor.ert.ensemble.started"
EVTYPE_ENSEMBLE_STOPPED = "com.equinor.ert.ensemble.stopped"
EVTYPE_ENSEMBLE_CANCELLED = "com.equinor.ert.ensemble.cancelled"
EVTYPE_ENSEMBLE_FAILED = "com.equinor.ert.ensemble.failed"
22 changes: 11 additions & 11 deletions src/ert/job_queue/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@

from ert.config import QueueConfig
from ert.constant_filenames import CERT_FILE, JOBS_FILE
from ert.event_type_constants import (
EVTYPE_ENSEMBLE_CANCELLED,
EVTYPE_ENSEMBLE_FAILED,
EVTYPE_ENSEMBLE_STOPPED,
EVTYPE_REALIZATION_FAILURE,
EVTYPE_REALIZATION_PENDING,
EVTYPE_REALIZATION_RUNNING,
EVTYPE_REALIZATION_SUCCESS,
EVTYPE_REALIZATION_UNKNOWN,
EVTYPE_REALIZATION_WAITING,
)
from ert.job_queue.job_queue_node import JobQueueNode
from ert.job_queue.job_status import JobStatus
from ert.job_queue.queue_differ import QueueDiffer
Expand All @@ -45,17 +56,6 @@
"""How many realizations allowed to be concurrently internalized using
threads."""

EVTYPE_REALIZATION_FAILURE = "com.equinor.ert.realization.failure"
EVTYPE_REALIZATION_PENDING = "com.equinor.ert.realization.pending"
EVTYPE_REALIZATION_RUNNING = "com.equinor.ert.realization.running"
EVTYPE_REALIZATION_SUCCESS = "com.equinor.ert.realization.success"
EVTYPE_REALIZATION_UNKNOWN = "com.equinor.ert.realization.unknown"
EVTYPE_REALIZATION_WAITING = "com.equinor.ert.realization.waiting"
EVTYPE_REALIZATION_TIMEOUT = "com.equinor.ert.realization.timeout"
EVTYPE_ENSEMBLE_STARTED = "com.equinor.ert.ensemble.started"
EVTYPE_ENSEMBLE_STOPPED = "com.equinor.ert.ensemble.stopped"
EVTYPE_ENSEMBLE_CANCELLED = "com.equinor.ert.ensemble.cancelled"
EVTYPE_ENSEMBLE_FAILED = "com.equinor.ert.ensemble.failed"

_queue_state_to_event_type_map = {
"NOT_ACTIVE": EVTYPE_REALIZATION_WAITING,
Expand Down

0 comments on commit 29d0fe4

Please sign in to comment.