Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test utils to mark a run successful or failed #25791

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion python_modules/dagster/dagster/_core/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
from dagster._core.definitions.source_asset import SourceAsset
from dagster._core.definitions.unresolved_asset_job_definition import define_asset_job
from dagster._core.errors import DagsterUserCodeUnreachableError
from dagster._core.events import DagsterEvent
from dagster._core.events import DagsterEvent, DagsterEventType
from dagster._core.events.log import EventLogEntry
from dagster._core.instance import DagsterInstance

# test utils from separate light weight file since are exported top level
Expand Down Expand Up @@ -216,6 +217,38 @@ def register_managed_run_for_test(
)


def mark_run_successful(instance: DagsterInstance, run: DagsterRun) -> None:
instance.handle_new_event(
EventLogEntry(
error_info=None,
level="debug",
user_message="",
run_id=run.run_id,
timestamp=time.time(),
dagster_event=DagsterEvent(
event_type_value=DagsterEventType.RUN_SUCCESS.value,
job_name=run.job_name,
),
)
)


def mark_run_failed(instance: DagsterInstance, run: DagsterRun) -> None:
instance.handle_new_event(
EventLogEntry(
error_info=None,
level="debug",
user_message="",
run_id=run.run_id,
timestamp=time.time(),
dagster_event=DagsterEvent(
event_type_value=DagsterEventType.RUN_FAILURE.value,
job_name=run.job_name,
),
)
)


def wait_for_runs_to_finish(
instance: DagsterInstance, timeout: float = 20, run_tags: Optional[Mapping[str, str]] = None
) -> None:
Expand Down