Esempio n. 1
0
def snapshot():
    return (
        SnapshotBuilder()
        .add_step(step_id="0", status="Unknown")
        .add_job(
            step_id="0",
            job_id="0",
            name="job0",
            data={},
            status="Unknown",
        )
        .add_job(
            step_id="0",
            job_id="1",
            name="job1",
            data={},
            status="Unknown",
        )
        .add_job(
            step_id="0",
            job_id="2",
            name="job2",
            data={},
            status="Unknown",
        )
        .add_job(
            step_id="0",
            job_id="3",
            name="job3",
            data={},
            status="Unknown",
        )
        .build(["0", "1", "3", "4", "5", "9"], status="Unknown")
    )
Esempio n. 2
0
def _create_snapshot():
    return (SnapshotBuilder().add_step(step_id="0", status="Unknown").add_job(
        step_id="0",
        job_id="0",
        name="job0",
        data={},
        status="Unknown",
    ).add_job(
        step_id="0",
        job_id="1",
        name="job1",
        data={},
        status="Unknown",
    ).add_job(
        step_id="0",
        job_id="2",
        name="job2",
        data={},
        status="Unknown",
    ).add_job(
        step_id="0",
        job_id="3",
        name="job3",
        data={},
        status="Unknown",
    ).build(_REALIZATION_INDEXES, status="Unknown"))
Esempio n. 3
0
def small_snapshot() -> Snapshot:
    builder = SnapshotBuilder().add_step(step_id="0", status=STEP_STATE_UNKNOWN)
    for i in range(0, 2):
        builder.add_job(
            step_id="0",
            job_id=str(i),
            name=f"job_{i}",
            data={ids.MAX_MEMORY_USAGE: 1000, ids.CURRENT_MEMORY_USAGE: 500},
            status=JOB_STATE_START,
            stdout=f"job_{i}.stdout",
            stderr=f"job_{i}.stderr",
            start_time=dt(1999, 1, 1).isoformat(),
            end_time=dt(2019, 1, 1).isoformat(),
        )
    real_ids = [str(i) for i in range(0, 5)]
    return builder.build(real_ids, REALIZATION_STATE_UNKNOWN)
def mock_ee_monitor(*args):
    reals_ids = ["0", "1"]
    events = [
        MockCloudEvent(
            {"type": ids.EVTYPE_EE_SNAPSHOT},
            SnapshotBuilder().add_stage(
                stage_id="0",
                status="Running",
                queue_state="JOB_QUEUE_RUNNING").add_step(
                    stage_id="0", step_id="0", status="Unknown").add_job(
                        stage_id="0",
                        step_id="0",
                        job_id="0",
                        name="job0",
                        data={},
                        status="Running",
                    ).add_metadata("iter", 0).build(reals_ids,
                                                    "Unknown").to_dict(),
        ),
        MockCloudEvent(
            {"type": ids.EVTYPE_EE_SNAPSHOT_UPDATE},
            SnapshotBuilder().add_stage(
                stage_id="0",
                status="Finished",
                queue_state="JOB_QUEUE_SUCCESS").add_step(
                    stage_id="0", step_id="0", status="Finished").add_metadata(
                        "iter", 0).build(reals_ids, "Unknown").to_dict(),
        ),
        MockCloudEvent({"type": ids.EVTYPE_EE_TERMINATED}, {}),
    ]

    def _track():
        while True:
            try:
                yield events.pop(0)
            except IndexError:
                return

    return MagicMock(track=MagicMock(side_effect=_track))
Esempio n. 5
0
def test_multiple_cloud_events_trigger_non_communicated_change():
    """In other words, though we say all steps are finished, we don't
    explicitly send an event that changes the realization status. It should
    happen by virtue of the steps being completed."""
    snapshot = (SnapshotBuilder().add_step(
        step_id="0", status="Unknown").build(["0"], status="Unknown"))
    partial = PartialSnapshot(snapshot)
    partial.from_cloudevent(
        CloudEvent({
            "id": "0",
            "type": ids.EVTYPE_FM_STEP_SUCCESS,
            "source": "/real/0/step/0",
        }))
    assert partial.to_dict(
    )["reals"]["0"]["status"] == state.REALIZATION_STATE_FINISHED
Esempio n. 6
0
    qtbot.mouseClick(widget.show_details_button, Qt.LeftButton)
    qtbot.waitUntil(lambda: widget._tab_widget.count() == 2, timeout=5000)


@pytest.mark.parametrize(
    "events,tab_widget_count",
    [
        pytest.param(
            [
                FullSnapshotEvent(
                    snapshot=(
                        SnapshotBuilder()
                        .add_step(step_id="0", status=state.STEP_STATE_UNKNOWN)
                        .add_job(
                            step_id="0",
                            job_id="0",
                            name="job_0",
                            data={},
                            status=state.JOB_STATE_START,
                        )
                        .build(["0"], state.REALIZATION_STATE_UNKNOWN)
                    ),
                    phase_name="Foo",
                    current_phase=0,
                    total_phases=1,
                    progress=0.25,
                    iteration=0,
                    indeterminate=False,
                ),
                SnapshotUpdateEvent(
                    partial_snapshot=PartialSnapshot(
                        SnapshotBuilder().build(
Esempio n. 7
0
def build_snapshot(real_list: List[str] = ["0"]):
    return (
        SnapshotBuilder()
        .add_step(step_id="0", status=state.STEP_STATE_UNKNOWN)
        .build(real_list, state.REALIZATION_STATE_UNKNOWN)
    )
Esempio n. 8
0
 def create_snapshot(ensemble):
     builder = SnapshotBuilder()
     realizations = ensemble.get_active_reals()
     if not realizations:
         raise ValueError(
             "An ensemble needs to have at least on realization to run.")
     real = realizations[0]
     for stage in real.get_stages():
         builder.add_stage(str(stage.get_id()), stage.get_status())
         for step in stage.get_steps():
             builder.add_step(str(stage.get_id()), str(step.get_id()),
                              "Unknown")
             for job in step.get_jobs():
                 builder.add_job(
                     str(stage.get_id()),
                     str(step.get_id()),
                     str(job.get_id()),
                     job.get_name(),
                     "Unknown",
                     {},
                 )
     for key, val in ensemble.get_metadata().items():
         builder.add_metadata(key, val)
     return builder.build(
         [str(real.get_iens()) for real in ensemble.get_active_reals()],
         "Unknown")