Skip to content

Commit

Permalink
Fix mypy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
keithralphs committed Jan 30, 2024
1 parent 04952b9 commit e212774
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ write_to = "src/blueapi/_version.py"

[tool.mypy]
ignore_missing_imports = true # Ignore missing stubs in imported modules
namespace_packages = false # rely only on __init__ files to determine fully qualified module names.
namespace_packages = true # rely only on __init__ files to determine fully qualified module names.

[tool.isort]
float_to_top = true
Expand Down
1 change: 1 addition & 0 deletions src/blueapi/tracing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
propagate_context_in_headers,
retrieve_context_from_headers,
get_trace_context,
Context,
)

__all__ = [
Expand Down
7 changes: 4 additions & 3 deletions src/blueapi/tracing/tracing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ def instrument_fastapi_app(app: FastAPI, name: str) -> None:
use the get_tracer_provider call to hook in to the apps OTEL infrastructure when creating
new SpanProcessors or setting up manual Span generation. '''
resource = Resource(attributes={"service.name": name})
set_tracer_provider(TracerProvider(resource=resource))
get_tracer_provider().add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))
provider = TracerProvider(resource=resource)
provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))
set_tracer_provider(provider)
FastAPIInstrumentor().instrument_app(app)


Expand All @@ -52,7 +53,7 @@ def get_header_from_frame(frame: Frame, key: str) -> dict:


def propagate_context_in_headers(
headers: dict[str, typing.Any], context: Context = None
headers: dict[str, typing.Any], context: Context = get_current()
) -> None:
PROPAGATOR.inject(headers, context)

Expand Down
5 changes: 4 additions & 1 deletion src/blueapi/worker/reworker.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
add_trace_attributes,
get_baggage,
get_trace_context,
Context,
get_tracer,
)

Expand Down Expand Up @@ -74,6 +75,8 @@ class RunEngineWorker(Worker[Task]):
_started: Event
_stopping: Event
_stopped: Event
_register_lock: RLock
_context_register: Dict[str, Context]

def __init__(
self,
Expand Down Expand Up @@ -150,7 +153,7 @@ def submit_task(self, task: Task) -> str:
)

trackable_task = TrackableTask(
task_id=task_id, request_id=get_baggage("correlation_id"), task=task
task_id=task_id, request_id=str(get_baggage("correlation_id")), task=task
)
self._pending_tasks[task_id] = trackable_task
return task_id
Expand Down
2 changes: 1 addition & 1 deletion src/blueapi/worker/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TrackableTask(BlueapiBaseModel, Generic[T]):
"""

task_id: str
request_id: str = None
request_id: str = ''
task: T
is_complete: bool = False
is_pending: bool = True
Expand Down

0 comments on commit e212774

Please sign in to comment.