Skip to content

Commit

Permalink
build: add py.typed
Browse files Browse the repository at this point in the history
  • Loading branch information
maxim-v4s committed Oct 3, 2024
1 parent a92077a commit e24ac2b
Show file tree
Hide file tree
Showing 6 changed files with 1,033 additions and 927 deletions.
1,926 changes: 1,016 additions & 910 deletions poetry.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ click = "^8.1.7"
tomli = { version = "^2.0.1", python = "<3.11" }
tomli-w = "^1.0.0"
jsonpatch = "^1.33"
qualibrate-core = {path = "../qualibrate-core", optional = true}
#qualibrate-core = {git = "https://github.com/qua-platform/qualibrate-core", rev = "v0.2.0", optional = true}
qualibrate-core = {path = "../qualibrate-core", optional = true, develop = true}

[tool.poetry.extras]
qualibrary = ["qualibrate-core"]
Expand All @@ -32,7 +33,7 @@ strict = true
warn_return_any = true

[[tool.mypy.overrides]]
module = ["jsonpatch", "jsonpointer", "qualibrate.*", "qualibrate_app.*"]
module = ["jsonpatch", "jsonpointer"]
ignore_missing_imports = true

[tool.ruff]
Expand Down
6 changes: 3 additions & 3 deletions qualibrate_runner/api/dependencies.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from functools import cache
from typing import Annotated, Mapping, cast
from typing import Annotated, Mapping

from fastapi import Depends, HTTPException
from qualibrate.qualibration_graph import QualibrationGraph
Expand Down Expand Up @@ -39,13 +39,13 @@ def get_library(
def get_nodes(
library: Annotated[QualibrationLibrary, Depends(get_library)],
) -> Mapping[str, QualibrationNode]:
return cast(Mapping[str, QualibrationNode], library.get_nodes())
return library.get_nodes()


def get_graphs(
library: Annotated[QualibrationLibrary, Depends(get_library)],
) -> Mapping[str, QualibrationGraph]:
return cast(Mapping[str, QualibrationGraph], library.get_graphs())
return library.get_graphs()


def get_node(
Expand Down
11 changes: 4 additions & 7 deletions qualibrate_runner/api/routes/get_runnables.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Annotated, Any, Mapping, Sequence, cast
from typing import Annotated, Any, Mapping, Sequence

from fastapi import APIRouter, Depends
from qualibrate.qualibration_graph import QualibrationGraph
Expand Down Expand Up @@ -42,22 +42,19 @@ def get_graphs(
def get_node(
node: Annotated[QualibrationNode, Depends(get_qnode)],
) -> Mapping[str, Any]:
return cast(Mapping[str, Any], node.serialize())
return node.serialize()


@get_runnables_router.get("/get_graph")
def get_graph(
graph: Annotated[QualibrationGraph, Depends(get_qgraph)],
cytoscape: bool = False,
) -> Mapping[str, Any]:
return cast(Mapping[str, Any], graph.serialize(cytoscape=cytoscape))
return graph.serialize(cytoscape=cytoscape)


@get_runnables_router.get("/get_graph/cytoscape")
def get_graph_cytoscape(
graph: Annotated[QualibrationGraph, Depends(get_qgraph)],
) -> Sequence[Mapping[str, Any]]:
return cast(
Sequence[Mapping[str, Any]],
graph.cytoscape_representation(graph.serialize()),
)
return graph.cytoscape_representation(graph.serialize())
12 changes: 7 additions & 5 deletions qualibrate_runner/core/run_job.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import traceback
from datetime import datetime
from typing import Any, Mapping, Type
from typing import Any, Mapping, Optional, Type, cast

from fastapi import HTTPException, status
from pydantic import BaseModel, ValidationError
from qualibrate.models.run_summary.graph import GraphRunSummary
from qualibrate.models.run_summary.node import NodeRunSummary
from qualibrate.qualibration_graph import QualibrationGraph
from qualibrate.qualibration_library import QualibrationLibrary
from qualibrate.qualibration_node import QualibrationNode
Expand Down Expand Up @@ -64,15 +66,15 @@ def run_node(
run_status = RunStatus.ERROR
raise
else:
idx = node.snapshot_idx if hasattr(node, "snapshot_idx") else -1
idx = idx if idx is not None else -1
_idx = node.snapshot_idx if hasattr(node, "snapshot_idx") else -1
idx = idx if _idx is not None else -1
run_status = RunStatus.FINISHED
finally:
state.last_run = LastRun(
name=state.last_run.name,
status=run_status,
idx=idx,
run_result=node.run_summary,
run_result=cast(Optional[NodeRunSummary], node.run_summary),
runnable_type=state.last_run.runnable_type,
passed_parameters=passed_input_parameters,
started_at=state.last_run.started_at,
Expand Down Expand Up @@ -126,7 +128,7 @@ def run_workflow(
name=state.last_run.name,
status=run_status,
idx=idx,
run_result=workflow.run_summary,
run_result=cast(Optional[GraphRunSummary], workflow.run_summary),
started_at=state.last_run.started_at,
completed_at=datetime.now(),
runnable_type=state.last_run.runnable_type,
Expand Down
Empty file added qualibrate_runner/py.typed
Empty file.

0 comments on commit e24ac2b

Please sign in to comment.