actableai.utils.resources.profile package

Submodules

actableai.utils.resources.profile.base module

class actableai.utils.resources.profile.base.ResourceProfiler(resource_profiled: actableai.utils.resources.profile.ResourceProfilerType)

Bases: abc.ABC

Abstract class representing a resource profiler

shutdown()

Function called after using the profiler, it is assumed that the __call__ function cannot be called once shutdown is called

actableai.utils.resources.profile.gpu_memory module

class actableai.utils.resources.profile.gpu_memory.GPUMemoryProfiler(resource_profiled: actableai.utils.resources.profile.ResourceProfilerType)

Bases: actableai.utils.resources.profile.base.ResourceProfiler

GPU Memory profiler

shutdown()

Function called after using the profiler, in that case shutdowns the NVML library

actableai.utils.resources.profile.memory module

class actableai.utils.resources.profile.memory.MemoryProfiler(resource_profiled: actableai.utils.resources.profile.ResourceProfilerType)

Bases: actableai.utils.resources.profile.base.ResourceProfiler

Memory profiler profiles the following resources: - RSS_MEMORY - VMS_MEMORY - SHARED_MEMORY - USS_MEMORY - PSS_MEMORY - SWAP_MEMORY

Module contents

class actableai.utils.resources.profile.ResourceProfilerResults(df_profiling_results: pandas.core.frame.DataFrame)

Bases: object

Class representing the results returned by the profiling of a function

get_max_profiled(resource_profiled: actableai.utils.resources.profile.ResourceProfilerType) float

Return the maximum profiled value of a specific resource

Parameters
resource_profiled – The resource type to get the maximum value from
Return type
The maximum profiled value, 0 if not profiled
class actableai.utils.resources.profile.ResourceProfilerType(value)

Bases: enum.IntFlag

Enum representing the different resource that can be profiled

GPU_MEMORY = 64
MEMORY = 63
PSS_MEMORY = 16
RSS_MEMORY = 1
SHARED_MEMORY = 4
SWAP_MEMORY = 32
USS_MEMORY = 8
VMS_MEMORY = 2
actableai.utils.resources.profile.profile_function(resource_profiled: actableai.utils.resources.profile.ResourceProfilerType, include_children: bool, function: Callable, *args, **kwargs) Tuple[actableai.utils.resources.profile.ResourceProfilerResults, Any]

Profile a function

Will call the function and start a new thread that will profile different resources of the function

Parameters
  • resource_profiled – The resources to profile
  • include_children – If True will also profile the children (if any) created when calling the function
  • function – The function to profile
  • args – The arguments to call the function with
  • kwargs – The named arguments to call the function with
Returns

  • dataframe – DataFrame containing the profiling information of the function over time (in bytes)
  • result – The return value of the function