Skip to content

Commit 1126453

Browse files
Merge pull request #931 from automl/improve_file_output
Add additional output to log files
2 parents a5481cb + 59c07f0 commit 1126453

File tree

12 files changed

+116
-22
lines changed

12 files changed

+116
-22
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ recursive-include autosklearn/metalearning/files *.txt
44
include autosklearn/util/logging.yaml
55
recursive-include autosklearn *.pyx
66
include requirements.txt
7+
include autosklearn/requirements.txt
78
recursive-include autosklearn/experimental/askl2_portfolios *.json
89
include autosklearn/experimental/askl2_training_data.json

autosklearn/__init__.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
# -*- encoding: utf-8 -*-
22
import os
3+
import pkg_resources
34
import sys
45

56
from autosklearn.util import dependencies
67
from autosklearn.__version__ import __version__ # noqa (imported but unused)
78

89

9-
__MANDATORY_PACKAGES__ = '''
10-
numpy>=1.9
11-
scikit-learn>=0.22.0,<0.23
12-
lockfile>=0.10
13-
smac>=0.12
14-
pyrfr>=0.6.1,<0.8
15-
ConfigSpace>=0.4.0,<0.5
16-
'''
10+
requirements = pkg_resources.resource_string('autosklearn', 'requirements.txt')
11+
requirements = requirements.decode('utf-8')
1712

18-
dependencies.verify_packages(__MANDATORY_PACKAGES__)
13+
dependencies.verify_packages(requirements)
1914

2015
if os.name != 'posix':
2116
raise ValueError(

autosklearn/automl.py

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
import io
33
import json
44
import multiprocessing
5+
import platform
56
import os
7+
import sys
68
from typing import Optional, List, Union
79
import unittest.mock
810
import warnings
@@ -11,6 +13,7 @@
1113
import numpy as np
1214
import numpy.ma as ma
1315
import pandas as pd
16+
import pkg_resources
1417
import scipy.stats
1518
from sklearn.base import BaseEstimator
1619
from sklearn.model_selection._split import _RepeatedSplits, \
@@ -33,14 +36,22 @@
3336
from autosklearn.metrics import calculate_score
3437
from autosklearn.util.stopwatch import StopWatch
3538
from autosklearn.util.logging_ import get_logger, setup_logger
36-
from autosklearn.util import pipeline
39+
from autosklearn.util import pipeline, RE_PATTERN
3740
from autosklearn.ensemble_builder import EnsembleBuilder
3841
from autosklearn.ensembles.singlebest_ensemble import SingleBest
3942
from autosklearn.smbo import AutoMLSMBO
4043
from autosklearn.util.hash import hash_array_or_matrix
4144
from autosklearn.metrics import f1_macro, accuracy, r2
4245
from autosklearn.constants import MULTILABEL_CLASSIFICATION, MULTICLASS_CLASSIFICATION, \
4346
REGRESSION_TASKS, REGRESSION, BINARY_CLASSIFICATION, MULTIOUTPUT_REGRESSION
47+
from autosklearn.pipeline.components.classification import ClassifierChoice
48+
from autosklearn.pipeline.components.regression import RegressorChoice
49+
from autosklearn.pipeline.components.feature_preprocessing import FeaturePreprocessorChoice
50+
from autosklearn.pipeline.components.data_preprocessing.categorical_encoding import OHEChoice
51+
from autosklearn.pipeline.components.data_preprocessing.minority_coalescense import (
52+
CoalescenseChoice
53+
)
54+
from autosklearn.pipeline.components.data_preprocessing.rescaling import RescalingChoice
4455

4556

4657
def _model_predict(model, X, batch_size, logger, task):
@@ -356,6 +367,80 @@ def fit(
356367
elif feat_type is None and self.InputValidator.feature_types:
357368
feat_type = self.InputValidator.feature_types
358369

370+
# Produce debug information to the logfile
371+
self._logger.debug('Starting to print environment information')
372+
self._logger.debug(' Python version: %s', sys.version.split('\n'))
373+
try:
374+
self._logger.debug(' Distribution: %s', platform.linux_distribution())
375+
except AttributeError:
376+
# platform.linux_distribution() was removed in Python3.8
377+
# We should move to the distro package as soon as it supports Windows and OSX
378+
pass
379+
self._logger.debug(' System: %s', platform.system())
380+
self._logger.debug(' Machine: %s', platform.machine())
381+
self._logger.debug(' Platform: %s', platform.platform())
382+
# UNAME appears to leak sensible information
383+
# self._logger.debug(' uname: %s', platform.uname())
384+
self._logger.debug(' Version: %s', platform.version())
385+
self._logger.debug(' Mac version: %s', platform.mac_ver())
386+
requirements = pkg_resources.resource_string('autosklearn', 'requirements.txt')
387+
requirements = requirements.decode('utf-8')
388+
requirements = [requirement for requirement in requirements.split('\n')]
389+
for requirement in requirements:
390+
if not requirement:
391+
continue
392+
match = RE_PATTERN.match(requirement)
393+
if match:
394+
name = match.group('name')
395+
module_dist = pkg_resources.get_distribution(name)
396+
self._logger.debug(' %s', module_dist)
397+
else:
398+
raise ValueError('Unable to read requirement: %s' % requirement)
399+
self._logger.debug('Done printing environment information')
400+
self._logger.debug('Starting to print arguments to auto-sklearn')
401+
self._logger.debug(' output_folder: %s', self._backend.context._output_directory)
402+
self._logger.debug(' tmp_folder: %s', self._backend.context._temporary_directory)
403+
self._logger.debug(' time_left_for_this_task: %f', self._time_for_task)
404+
self._logger.debug(' per_run_time_limit: %f', self._per_run_time_limit)
405+
self._logger.debug(
406+
' initial_configurations_via_metalearning: %d',
407+
self._initial_configurations_via_metalearning,
408+
)
409+
self._logger.debug(' ensemble_size: %d', self._ensemble_size)
410+
self._logger.debug(' ensemble_nbest: %f', self._ensemble_nbest)
411+
self._logger.debug(' max_models_on_disc: %d', self._max_models_on_disc)
412+
self._logger.debug(' ensemble_memory_limit: %d', self._ensemble_memory_limit)
413+
self._logger.debug(' seed: %d', self._seed)
414+
self._logger.debug(' ml_memory_limit: %d', self._ml_memory_limit)
415+
self._logger.debug(' metadata_directory: %s', self._metadata_directory)
416+
self._logger.debug(' debug_mode: %s', self._debug_mode)
417+
self._logger.debug(' include_estimators: %s', str(self._include_estimators))
418+
self._logger.debug(' exclude_estimators: %s', str(self._exclude_estimators))
419+
self._logger.debug(' include_preprocessors: %s', str(self._include_preprocessors))
420+
self._logger.debug(' exclude_preprocessors: %s', str(self._exclude_preprocessors))
421+
self._logger.debug(' resampling_strategy: %s', str(self._resampling_strategy))
422+
self._logger.debug(' resampling_strategy_arguments: %s',
423+
str(self._resampling_strategy_arguments))
424+
self._logger.debug(' shared_mode: %s', str(self._shared_mode))
425+
self._logger.debug(' precision: %s', str(self.precision))
426+
self._logger.debug(' disable_evaluator_output: %s', str(self._disable_evaluator_output))
427+
self._logger.debug(' get_smac_objective_callback: %s', str(self._get_smac_object_callback))
428+
self._logger.debug(' smac_scenario_args: %s', str(self._smac_scenario_args))
429+
self._logger.debug(' logging_config: %s', str(self.logging_config))
430+
self._logger.debug(' metric: %s', str(self._metric))
431+
self._logger.debug('Done printing arguments to auto-sklearn')
432+
self._logger.debug('Starting to print available components')
433+
for choice in (
434+
ClassifierChoice, RegressorChoice, FeaturePreprocessorChoice,
435+
OHEChoice, RescalingChoice, CoalescenseChoice,
436+
):
437+
self._logger.debug(
438+
'%s: %s',
439+
choice.__name__,
440+
choice.get_components(),
441+
)
442+
self._logger.debug('Done printing available components')
443+
359444
datamanager = XYDataManager(
360445
X, y,
361446
X_test=X_test,

autosklearn/pipeline/components/classification/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def add_classifier(classifier):
2121

2222
class ClassifierChoice(AutoSklearnChoice):
2323

24+
@classmethod
2425
def get_components(cls):
2526
components = OrderedDict()
2627
components.update(_classifiers)

autosklearn/pipeline/components/data_preprocessing/categorical_encoding/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ def add_ohe(ohe):
1717

1818

1919
class OHEChoice(AutoSklearnChoice):
20-
def get_components(self):
20+
21+
@classmethod
22+
def get_components(cls):
2123
components = OrderedDict()
2224
components.update(_ohes)
2325
components.update(_addons.components)

autosklearn/pipeline/components/data_preprocessing/minority_coalescense/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ def add_mc(mc):
1616

1717

1818
class CoalescenseChoice(AutoSklearnChoice):
19-
def get_components(self):
19+
20+
@classmethod
21+
def get_components(cls):
2022
components = OrderedDict()
2123
components.update(_mcs)
2224
components.update(_addons.components)

autosklearn/pipeline/components/data_preprocessing/rescaling/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ def add_rescaler(rescaler):
1818

1919

2020
class RescalingChoice(AutoSklearnChoice):
21-
def get_components(self):
21+
22+
@classmethod
23+
def get_components(cls):
2224
components = OrderedDict()
2325
components.update(_rescalers)
2426
components.update(_addons.components)

autosklearn/pipeline/components/feature_preprocessing/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ def add_preprocessor(preprocessor):
1919

2020
class FeaturePreprocessorChoice(AutoSklearnChoice):
2121

22-
def get_components(self):
22+
@classmethod
23+
def get_components(cls):
2324
components = OrderedDict()
2425
components.update(_preprocessors)
2526
components.update(_addons.components)

autosklearn/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../requirements.txt

autosklearn/util/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
# -*- encoding: utf-8 -*-
2+
import re
3+
4+
5+
SUBPATTERN = r'((?P<operation%d>==|>=|>|<)(?P<version%d>(\d+)?(\.[a-zA-Z0-9]+)?(\.\d+)?))'
6+
RE_PATTERN = re.compile(
7+
r'^(?P<name>[\w\-]+)%s?(,%s)?$' % (SUBPATTERN % (1, 1), SUBPATTERN % (2, 2)))

0 commit comments

Comments
 (0)