Skip to content

Commit

Permalink
Merge pull request #15 from qua-platform/stop_route
Browse files Browse the repository at this point in the history
Stop running item api
  • Loading branch information
maxim-v4s authored Sep 2, 2024
2 parents ec0cc81 + c32eb2e commit f2f1c0e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 7 additions & 0 deletions qualibrate_runner/api/routes/others.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ def check_running(
return state.is_running


@others_router.post("/stop")
def stop_running(state: Annotated[State, Depends(get_state)]) -> bool:
if state.run_item is None:
return False
return bool(state.run_item.stop())


@others_router.post(
"/record_state_update",
description=(
Expand Down
10 changes: 8 additions & 2 deletions qualibrate_runner/core/run_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ def validate_input_parameters(
)


def get_active_library_or_error() -> QualibrationLibrary:
if QualibrationLibrary.active_library is None:
raise RuntimeError("Qualibration library is not exist")
return QualibrationLibrary.active_library


def run_node(
node: QualibrationNode,
passed_input_parameters: Mapping[str, Any],
Expand All @@ -38,7 +44,7 @@ def run_node(
started_at=datetime.now(),
)
try:
library = QualibrationLibrary.active_library
library = get_active_library_or_error()
node = library.nodes[node.name]
result = library.run_node(
node.name, node.parameters_class(**passed_input_parameters)
Expand Down Expand Up @@ -85,7 +91,7 @@ def run_workflow(
)
state.run_item = workflow
try:
library = QualibrationLibrary.active_library
library = get_active_library_or_error()
workflow = library.graphs[workflow.name]
result = library.run_graph(
workflow.name,
Expand Down

0 comments on commit f2f1c0e

Please sign in to comment.