Skip to content

Commit

Permalink
Fix some linting warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
lc525 committed Jul 7, 2023
1 parent f6efc4a commit f928e90
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion mlserver/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ async def _unload_model(self, model: MLModel):
self._clear_default()

model.ready = not await model.unload()

sys_tracer.tp_model_unload(model.name, model.version)

def _find_model(self, version: Optional[str] = None) -> Optional[MLModel]:
Expand Down
2 changes: 1 addition & 1 deletion mlserver/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class TracepointSettings(BaseSettings):

configured_tracepoints: Optional[List[Tracepoint]] = Tracepoint.all()
"""
When tracing is enabled (via `enable_tracepoints`), this controls the
When tracing is enabled (via `enable_tracepoints`), this controls the
list of tracepoints exposed by MLServer
"""

Expand Down
24 changes: 12 additions & 12 deletions mlserver/sys_tracing/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
functions) whenever application-specific events take place, such as starting to
process an inference request, loading/unloading a model, etc:
```
```
sys_trace = SystemTracingProvider()
sys_trace.generate_native_sdt_tracepoints(settings.tracepoint_settings)
...
sys_trace.generate_native_sdt_tracepoints(settings.tracepoint_settings)
...
# A new model gets loaded
ext_trace.tp_model_load_begin(...)
model.ready = await model.load()
ext_trace.tp_model_load_end(...)
sys_trace.tp_model_load_begin(...)
model.ready = await model.load()
sys_trace.tp_model_load_end(...)
```
Sometimes, the arguments that we want to pass to a tracepoint are obtained by
Expand All @@ -25,18 +25,18 @@
first call the `is_active` member function, which only returns true if the
passed tracepoint has an external probe attached:
```
```
if sys_trace.is_active(Tracepoint.inference_begin):
# compute arguments
# compute arguments
pipeline = parse_headers(...)
# fire tracepoint
# fire tracepoint
sys_trace.tp_inference_begin(..., pipeline, ...)
```
Each tp_* function calls into a native shared library that is generated on the
fly and dynamically loaded inside the process when calling
`ext_trace.generate_native_sdt_tracepoints(...)`. In the shared library, a
`sys_trace.generate_native_sdt_tracepoints(...)`. In the shared library, a
tracepoint is just a hook function (a series of nop instructions followed by a
ret). The code of this hook can be modified at runtime to jump into code
provided from outside the process (e.g. SystemTap or BPF probes running in
Expand Down Expand Up @@ -95,7 +95,7 @@ def create_native_sdt_tracepoints(self, tracepoint_settings: TracepointSettings)
# native ELF library containing the tracepoint functions to
# which external probes can be attached to.
import stapsdt
except:
except Exception:
logger.warning(
"Could not enable tracing. Ensure python-stapsdt and libstapsdt.so are installed"
)
Expand All @@ -110,7 +110,7 @@ def create_native_sdt_tracepoints(self, tracepoint_settings: TracepointSettings)
# provider, while disabled ones remain as stubs
for tp in self._configured_tracepoints:
arg_types, status = tp.get_arg_types()
if arg_types != None:
if arg_types is not None:
self._num_native_tracepoints += 1
self._tracepoint_definition[tp] = self._provider.add_probe(
tp.name, *arg_types
Expand Down
1 change: 0 additions & 1 deletion mlserver/system_tracing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from .logging import logger
from .settings import TracepointSettings
from .sys_tracing import SystemTracingProvider

Expand Down
4 changes: 2 additions & 2 deletions mlserver/types/tracepoints.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
A tracepoint is a statically defined marker placed in code to identify
application-level events.
application-level events.
From the perspective of the python application, each tracepoint acts like a
normal function call. When a tracepoint is initialized by the tracing provider,
Expand All @@ -15,7 +15,7 @@
`ArgTypeMap._prototypes`.
The subset of tracepoints visible to external tracing users can be restricted in
the MLServer settings, via the `tracepoint_settings.configured_tracepoints`
the MLServer settings, via the `tracepoint_settings.configured_tracepoints`
option.
See `system_tracing.provider` for more details about the actual tracepoint
Expand Down

0 comments on commit f928e90

Please sign in to comment.