Skip to content

Commit

Permalink
use setproctitle, if available to rename rf trainer process, so it's …
Browse files Browse the repository at this point in the history
…more easily identifiable in monitoring tools
  • Loading branch information
Bogdan Budescu committed Dec 18, 2024
1 parent 396d2f5 commit 4b30167
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
11 changes: 6 additions & 5 deletions smac/model/random_forest/multiproc_util/GrowingSharedArray.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import uuid
from typing import Optional

import math
from multiprocessing import Lock

import uuid
import numpy as np
from numpy import typing as npt

# from multiprocessing.shared_memory import SharedMemory
from .SharedMemory import SharedMemory as UntrackableSharedMemory
def SharedMemory(*args, **kwargs) -> UntrackableSharedMemory:
return UntrackableSharedMemory(*args, track=False, **kwargs)


import numpy as np
from numpy import typing as npt
def SharedMemory(*args, **kwargs) -> UntrackableSharedMemory:
return UntrackableSharedMemory(*args, track=False, **kwargs)


def dtypes_are_equal(dtype1: np.dtype, dtype2: np.dtype) -> bool:
Expand Down
10 changes: 10 additions & 0 deletions smac/model/random_forest/multiproc_util/RFTrainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@

from enum import Enum, auto, unique

try:
from setproctitle import setproctitle
except ImportError:
setproctitle = None
else:
import uuid


@unique
class Concurrency(Enum):
Expand Down Expand Up @@ -48,6 +55,9 @@ def rf_training_loop(
n_trees: int, bootstrapping: bool, max_features: int, min_samples_split: int, min_samples_leaf: int,
max_depth: int, eps_purity: float, max_nodes: int, n_points_per_tree: int
) -> None:
if setproctitle is not None:
setproctitle(f'rf_trainer_{uuid.uuid4().int}'[:15])

rf_opts = get_rf_opts(n_trees, bootstrapping, max_features, min_samples_split, min_samples_leaf, max_depth,
eps_purity, max_nodes, n_points_per_tree)

Expand Down

0 comments on commit 4b30167

Please sign in to comment.