source: orange/Orange/__init__.py @ 10889:a63021ee6a68

Revision 10889:a63021ee6a68, 4.5 KB checked in by Matija Polajnar <matija.polajnar@…>, 2 years ago (diff)

Move of reliability into an add-on.

Line 
1from __future__ import absolute_import
2
3# This is overwritten with version from version.py, which is generated by
4# setup.py automatically
5__version__ = "unknown"
6
7ADDONS_ENTRY_POINT = 'orange.addons'
8
9from . import orange
10
11# Definitely ugly, but I see no other workaround.
12# When, e.g. data.io executes "from orange import ExampleTable"
13# orange gets imported again since it is not in sys.modules
14# before this entire file is executed
15import sys
16sys.modules["orange"] = orange
17
18# Little trick so that legacy imports work automatically
19import Orange.orng
20sys.path = Orange.orng.__path__ + sys.path
21
22import warnings
23import pkg_resources
24
25alreadyWarned = False
26disabledMsg = "Some features will be disabled due to failing modules\n"
27def _import(name):
28    global alreadyWarned
29    try:
30        __import__(name, globals(), locals(), [], -1)
31    except ImportError, err:
32        warnings.warn("%sImporting '%s' failed: %s" %
33            (disabledMsg if not alreadyWarned else "", name, err),
34            UserWarning, 2)
35        alreadyWarned = True
36
37def _import_addons():
38    globals_dict = globals()
39    for entry_point in pkg_resources.iter_entry_points(ADDONS_ENTRY_POINT):
40        try:
41            module = entry_point.load()
42            if '.' not in entry_point.name:
43                globals_dict[entry_point.name] = module
44            sys.modules['Orange.%s' % (entry_point.name,)] = module
45        except ImportError, err:
46            warnings.warn("Importing add-on '%s' failed: %s" % (entry_point.name, err), UserWarning, 2)
47        except pkg_resources.DistributionNotFound, err:
48            warnings.warn("Loading add-on '%s' failed because of a missing dependency: '%s'" % (entry_point.name, err), UserWarning, 2)
49        except Exception, err:
50            warning.warn("An exception occurred during the loading of '%s':\n%r" %(entry_point.name, err), UserWarning, 2)
51
52
53_import("utils")
54
55_import("data")
56_import("data.io")
57_import("data.sample")
58_import("data.outliers")
59_import("data.preprocess")
60_import("data.preprocess.scaling")
61_import("data.utils")
62_import("data.discretization")
63_import("data.continuization")
64_import("data.filter")
65_import("data.imputation")
66
67_import("feature")
68_import("feature.construction")
69_import("feature.construction.functionDecomposition")
70_import("feature.construction.univariate")
71_import("feature.discretization")
72_import("feature.imputation")
73_import("feature.scoring")
74_import("feature.selection")
75
76_import("network")
77
78_import("stat")
79
80_import("statistics")
81_import("statistics.estimate")
82_import("statistics.contingency")
83_import("statistics.distribution")
84_import("statistics.basic")
85_import("statistics.evd")
86
87_import("classification")
88_import("classification.tree")
89
90_import("classification.rules")
91
92_import("classification.lookup")
93_import("classification.bayes")
94_import("classification.svm")
95_import("classification.logreg")
96_import("classification.knn")
97_import("classification.majority")
98
99_import("tuning")
100
101_import("projection")
102_import("projection.linear")
103_import("projection.mds")
104_import("projection.som")
105
106_import("ensemble")
107_import("ensemble.bagging")
108_import("ensemble.boosting")
109_import("ensemble.forest")
110_import("ensemble.stacking")
111
112_import("regression")
113_import("regression.base")
114_import("regression.earth")
115_import("regression.lasso")
116_import("regression.linear")
117_import("regression.mean")
118_import("regression.pls")
119_import("regression.tree")
120
121_import("multitarget")
122_import("multitarget.tree")
123
124_import("multilabel")
125_import("multilabel.multibase")
126_import("multilabel.br")
127_import("multilabel.lp")
128_import("multilabel.mlknn")
129_import("multilabel.brknn")
130_import("multilabel.mulan")
131
132_import("associate")
133
134_import("distance")
135
136_import("wrappers")
137
138_import("featureConstruction")
139_import("featureConstruction.univariate")
140_import("featureConstruction.functionDecomposition")
141
142_import("evaluation")
143_import("evaluation.scoring")
144_import("evaluation.testing")
145
146_import("clustering")
147_import("clustering.kmeans")
148_import("clustering.hierarchical")
149_import("clustering.consensus")
150
151_import("misc")
152
153_import("utils") #TODO hide utils from the user
154_import("utils.environ")
155_import("utils.counters")
156_import("utils.addons")
157_import("utils.render")
158_import("utils.serverfiles")
159
160_import_addons()
161
162try:
163    from . import version
164    # Always use short_version here (see PEP 386)
165    __version__ = version.short_version
166    __hg_revision__ = version.hg_revision
167except ImportError:
168    # Leave the default version defined at the top.
169    pass
170
171del _import
172del _import_addons
173del alreadyWarned
174del disabledMsg
Note: See TracBrowser for help on using the repository browser.