Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kill child process using signals #83

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions alpha_automl/automl_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _search_pipelines(self, automl_hyperparams):

if result == 'DONE':
search_process.terminate()
search_process.join(30)
search_process.join(10)
logger.debug(f'Found {found_pipelines} pipelines')
logger.debug('Search done')
break
Expand All @@ -93,10 +93,10 @@ def _search_pipelines(self, automl_hyperparams):
yield {'pipeline': pipeline, 'message': 'SCORED'}

if time.time() > search_start_time + self.time_bound:
logger.debug('Reached search timeout')
search_process.terminate()
search_process.join(30)
search_process.join(10)
logger.debug(f'Found {found_pipelines} pipelines')
logger.debug('Reached search timeout')
break

def check_automl_hyperparams(self, automl_hyperparams):
Expand Down
27 changes: 11 additions & 16 deletions alpha_automl/pipeline_synthesis/setup_search.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import logging
import os
import sys
import signal
import logging
from os.path import join

from alpha_automl.grammar_loader import load_automatic_grammar, load_manual_grammar
from alpha_automl.pipeline import Pipeline
from alpha_automl.pipeline_search.Coach import Coach
Expand Down Expand Up @@ -41,22 +42,16 @@
}


def signal_handler(queue, signum):
logger.debug(f'Receiving signal {signum}, terminating process')
queue.put('DONE')
# TODO: Should it save the last status of the NN model?
sys.exit(0)


def search_pipelines(
X,
y,
scoring,
splitting_strategy,
task_name,
time_bound,
automl_hyperparams,
metadata,
output_folder,
verbose,
queue,
):

def search_pipelines(X, y, scoring, splitting_strategy, task_name, time_bound, automl_hyperparams, metadata,
output_folder, verbose, queue):
signal.signal(signal.SIGTERM, lambda signum, frame: signal_handler(queue, signum))
hide_logs(verbose) # Hide logs here too, since multiprocessing has some issues with loggers

builder = BaseBuilder(metadata, automl_hyperparams)
Expand Down