PipeGraphPy 2.0.6__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- PipeGraphPy/__init__.py +10 -0
- PipeGraphPy/common.py +4 -0
- PipeGraphPy/config/__init__.py +276 -0
- PipeGraphPy/config/custom.py +6 -0
- PipeGraphPy/config/default_settings.py +125 -0
- PipeGraphPy/constants.py +421 -0
- PipeGraphPy/core/__init__.py +2 -0
- PipeGraphPy/core/anchor.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/edge.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/graph.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/graph_base.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/__init__.py +3 -0
- PipeGraphPy/core/modcls/base.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/branchselect.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/classifier.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/cluster.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/datacharts.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/deeplearning.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/endscript.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/ensemble.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/evaluate.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/exportdata.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/handlescript.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/importdata.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/merge.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/mergescript.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/metrics.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/postprocessor.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/preprocessor.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/pythonscript.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/regressor.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/selector.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/selectscript.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/special.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/split.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/splitscript.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/startscript.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modcls/transformer.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/module.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/modules/__init__.py +65 -0
- PipeGraphPy/core/modules/classifier/__init__.py +2 -0
- PipeGraphPy/core/modules/cluster/__init__.py +0 -0
- PipeGraphPy/core/modules/custom/__init__.py +0 -0
- PipeGraphPy/core/modules/custom/classifier/__init__.py +0 -0
- PipeGraphPy/core/modules/datacharts/__init__.py +5 -0
- PipeGraphPy/core/modules/datacharts/dataview.py +28 -0
- PipeGraphPy/core/modules/deeplearning/__init__.py +0 -0
- PipeGraphPy/core/modules/ensemble/__init__.py +0 -0
- PipeGraphPy/core/modules/evaluate/__init__.py +0 -0
- PipeGraphPy/core/modules/exportdata/__init__.py +0 -0
- PipeGraphPy/core/modules/importdata/__init__.py +0 -0
- PipeGraphPy/core/modules/merge/__init__.py +0 -0
- PipeGraphPy/core/modules/model_selector/__init__.py +3 -0
- PipeGraphPy/core/modules/postprocessor/__init__.py +0 -0
- PipeGraphPy/core/modules/preprocessor/__init__.py +0 -0
- PipeGraphPy/core/modules/pythonscript/__init__.py +0 -0
- PipeGraphPy/core/modules/regressor/__init__.py +0 -0
- PipeGraphPy/core/modules/selector/__init__.py +0 -0
- PipeGraphPy/core/modules/special/__init__.py +0 -0
- PipeGraphPy/core/modules/split/__init__.py +0 -0
- PipeGraphPy/core/modules/transformer/__init__.py +0 -0
- PipeGraphPy/core/node.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/core/pipegraph.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/db/__init__.py +2 -0
- PipeGraphPy/db/models.cp39-win_amd64.pyd +0 -0
- PipeGraphPy/db/utils.py +106 -0
- PipeGraphPy/decorators.py +42 -0
- PipeGraphPy/logger.py +170 -0
- PipeGraphPy/plot/__init__.py +0 -0
- PipeGraphPy/plot/draw.py +424 -0
- PipeGraphPy/storage/__init__.py +10 -0
- PipeGraphPy/storage/base.py +2 -0
- PipeGraphPy/storage/dict_backend.py +102 -0
- PipeGraphPy/storage/file_backend.py +342 -0
- PipeGraphPy/storage/redis_backend.py +183 -0
- PipeGraphPy/tools.py +388 -0
- PipeGraphPy/utils/__init__.py +1 -0
- PipeGraphPy/utils/check.py +179 -0
- PipeGraphPy/utils/core.py +295 -0
- PipeGraphPy/utils/examine.py +259 -0
- PipeGraphPy/utils/file_operate.py +101 -0
- PipeGraphPy/utils/format.py +303 -0
- PipeGraphPy/utils/functional.py +422 -0
- PipeGraphPy/utils/handle_graph.py +31 -0
- PipeGraphPy/utils/lock.py +1 -0
- PipeGraphPy/utils/mq.py +54 -0
- PipeGraphPy/utils/osutil.py +29 -0
- PipeGraphPy/utils/redis_operate.py +195 -0
- PipeGraphPy/utils/str_handle.py +122 -0
- PipeGraphPy/utils/version.py +108 -0
- PipeGraphPy-2.0.6.dist-info/METADATA +17 -0
- PipeGraphPy-2.0.6.dist-info/RECORD +94 -0
- PipeGraphPy-2.0.6.dist-info/WHEEL +5 -0
- PipeGraphPy-2.0.6.dist-info/top_level.txt +1 -0
PipeGraphPy/__init__.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# coding:utf-8
|
|
2
|
+
|
|
3
|
+
__version__ = "2.0.6"
|
|
4
|
+
|
|
5
|
+
from PipeGraphPy.core.graph import Graph, graph_predict, graph_evaluate, online_graph_evaluate, online_graph_predict, graph_run, graph_backtest
|
|
6
|
+
from PipeGraphPy.core.module import Module
|
|
7
|
+
from PipeGraphPy.core.node import Node
|
|
8
|
+
|
|
9
|
+
__all__ = ['Node', 'Module', 'Graph', 'graph_predict', 'graph_evaluate',
|
|
10
|
+
'online_graph_evaluate', 'online_graph_predict', 'graph_run', 'graph_backtest']
|
PipeGraphPy/common.py
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
# coding:utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Settings and configuration for PGP.
|
|
5
|
+
|
|
6
|
+
Read values from the module specified by the PGP_SETTINGS_MODULE environment
|
|
7
|
+
variable, and then from PipeGraphPy.conf.default_settings; see the default_settings.py
|
|
8
|
+
for a list of all possible variables.
|
|
9
|
+
|
|
10
|
+
"""
|
|
11
|
+
import importlib
|
|
12
|
+
import os
|
|
13
|
+
import traceback
|
|
14
|
+
import PipeGraphPy
|
|
15
|
+
from PipeGraphPy.config import default_settings
|
|
16
|
+
from PipeGraphPy.utils.functional import LazyObject, empty
|
|
17
|
+
from dbpoolpy import settings as dbsettings
|
|
18
|
+
|
|
19
|
+
os.environ['PGP_SETTINGS_MODULE'] = 'PipeGraphPy.config.custom'
|
|
20
|
+
|
|
21
|
+
ENVIRONMENT_VARIABLE = "PGP_SETTINGS_MODULE"
|
|
22
|
+
|
|
23
|
+
PASSWORD_RESET_TIMEOUT_DAYS_DEPRECATED_MSG = (
|
|
24
|
+
'The PASSWORD_RESET_TIMEOUT_DAYS setting is deprecated. Use '
|
|
25
|
+
'PASSWORD_RESET_TIMEOUT instead.'
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
DEFAULT_HASHING_ALGORITHM_DEPRECATED_MSG = (
|
|
29
|
+
'The DEFAULT_HASHING_ALGORITHM transitional setting is deprecated. '
|
|
30
|
+
'Support for it and tokens, cookies, sessions, and signatures that use '
|
|
31
|
+
'SHA-1 hashing algorithm will be removed in PGP 4.0.'
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class SettingsReference(str):
|
|
36
|
+
"""
|
|
37
|
+
String subclass which references a current settings value. It's treated as
|
|
38
|
+
the value in memory but serializes to a settings.NAME attribute reference.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
def __new__(self, value, setting_name):
|
|
42
|
+
return str.__new__(self, value)
|
|
43
|
+
|
|
44
|
+
def __init__(self, value, setting_name):
|
|
45
|
+
self.setting_name = setting_name
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class LazySettings(LazyObject):
|
|
49
|
+
"""
|
|
50
|
+
A lazy proxy for either global PGP settings or a custom settings object.
|
|
51
|
+
The user can manually configure settings prior to using them. Otherwise,
|
|
52
|
+
PGP uses the settings module pointed to by PGP_SETTINGS_MODULE.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
def _setup(self, name=None):
|
|
56
|
+
"""
|
|
57
|
+
Load the settings module pointed to by the environment variable. This
|
|
58
|
+
is used the first time settings are needed, if the user hasn't
|
|
59
|
+
configured settings manually.
|
|
60
|
+
"""
|
|
61
|
+
settings_module = os.environ.get(ENVIRONMENT_VARIABLE)
|
|
62
|
+
if not settings_module:
|
|
63
|
+
desc = ("setting %s" % name) if name else "settings"
|
|
64
|
+
raise Exception(
|
|
65
|
+
"Requested %s, but settings are not configured. "
|
|
66
|
+
"You must either define the environment variable %s "
|
|
67
|
+
"or call settings.configure() before accessing settings."
|
|
68
|
+
% (desc, ENVIRONMENT_VARIABLE))
|
|
69
|
+
|
|
70
|
+
self._wrapped = Settings(settings_module)
|
|
71
|
+
|
|
72
|
+
def __repr__(self):
|
|
73
|
+
# Hardcode the class name as otherwise it yields 'Settings'.
|
|
74
|
+
if self._wrapped is empty:
|
|
75
|
+
return '<LazySettings [Unevaluated]>'
|
|
76
|
+
return '<LazySettings "%(settings_module)s">' % {
|
|
77
|
+
'settings_module': self._wrapped.SETTINGS_MODULE,
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
def __getattr__(self, name):
|
|
81
|
+
"""Return the value of a setting and cache it in self.__dict__."""
|
|
82
|
+
if self._wrapped is empty:
|
|
83
|
+
self._setup(name)
|
|
84
|
+
val = getattr(self._wrapped, name)
|
|
85
|
+
|
|
86
|
+
# Special case some settings which require further modification.
|
|
87
|
+
# This is done here for performance reasons so the
|
|
88
|
+
# modified value is cached.
|
|
89
|
+
|
|
90
|
+
# if name in {'MEDIA_URL', 'STATIC_URL'} and val is not None:
|
|
91
|
+
# val = self._add_script_prefix(val)
|
|
92
|
+
# elif name == 'SECRET_KEY' and not val:
|
|
93
|
+
# raise Exception(
|
|
94
|
+
# "The SECRET_KEY setting must not be empty.")
|
|
95
|
+
|
|
96
|
+
self.__dict__[name] = val
|
|
97
|
+
return val
|
|
98
|
+
|
|
99
|
+
def __setattr__(self, name, value):
|
|
100
|
+
"""
|
|
101
|
+
Set the value of setting. Clear all cached values if _wrapped changes
|
|
102
|
+
(@override_settings does this) or clear single values when set.
|
|
103
|
+
"""
|
|
104
|
+
if name == '_wrapped':
|
|
105
|
+
self.__dict__.clear()
|
|
106
|
+
else:
|
|
107
|
+
self.__dict__.pop(name, None)
|
|
108
|
+
if name == 'DEBUG':
|
|
109
|
+
dbsettings.DEBUG = value
|
|
110
|
+
super().__setattr__(name, value)
|
|
111
|
+
|
|
112
|
+
def __delattr__(self, name):
|
|
113
|
+
"""Delete a setting and clear it from cache if needed."""
|
|
114
|
+
super().__delattr__(name)
|
|
115
|
+
self.__dict__.pop(name, None)
|
|
116
|
+
|
|
117
|
+
def configure(self, default_settings=default_settings, **options):
|
|
118
|
+
"""
|
|
119
|
+
Called to manually configure the settings. The 'default_settings'
|
|
120
|
+
parameter sets where to retrieve any unspecified values from (its
|
|
121
|
+
argument must support attribute access (__getattr__)).
|
|
122
|
+
"""
|
|
123
|
+
if self._wrapped is not empty:
|
|
124
|
+
raise RuntimeError('Settings already configured.')
|
|
125
|
+
holder = UserSettingsHolder(default_settings)
|
|
126
|
+
for name, value in options.items():
|
|
127
|
+
if not name.isupper():
|
|
128
|
+
raise TypeError('Setting %r must be uppercase.' % name)
|
|
129
|
+
setattr(holder, name, value)
|
|
130
|
+
self._wrapped = holder
|
|
131
|
+
|
|
132
|
+
# @staticmethod
|
|
133
|
+
# def _add_script_prefix(value):
|
|
134
|
+
# """
|
|
135
|
+
# Add SCRIPT_NAME prefix to relative paths.
|
|
136
|
+
|
|
137
|
+
# Useful when the app is being served at a subpath and manually prefixing
|
|
138
|
+
# subpath to STATIC_URL and MEDIA_URL in settings is inconvenient.
|
|
139
|
+
# """
|
|
140
|
+
# # Don't apply prefix to absolute paths and URLs.
|
|
141
|
+
# if value.startswith(('http://', 'https://', '/')):
|
|
142
|
+
# return value
|
|
143
|
+
# from PipeGraphPy.urls import get_script_prefix
|
|
144
|
+
# return '%s%s' % (get_script_prefix(), value)
|
|
145
|
+
|
|
146
|
+
@property
|
|
147
|
+
def configured(self):
|
|
148
|
+
"""Return True if the settings have already been configured."""
|
|
149
|
+
return self._wrapped is not empty
|
|
150
|
+
|
|
151
|
+
@property
|
|
152
|
+
def PASSWORD_RESET_TIMEOUT_DAYS(self):
|
|
153
|
+
stack = traceback.extract_stack()
|
|
154
|
+
# Show a warning if the setting is used outside of PGP.
|
|
155
|
+
# Stack index: -1 this line, -2 the caller.
|
|
156
|
+
filename, _, _, _ = stack[-2]
|
|
157
|
+
if not filename.startswith(os.path.dirname(PipeGraphPy.__file__)):
|
|
158
|
+
pass
|
|
159
|
+
# warnings.warn(
|
|
160
|
+
# PASSWORD_RESET_TIMEOUT_DAYS_DEPRECATED_MSG,
|
|
161
|
+
# RemovedInPGP40Warning,
|
|
162
|
+
# stacklevel=2,
|
|
163
|
+
# )
|
|
164
|
+
return self.__getattr__('PASSWORD_RESET_TIMEOUT_DAYS')
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
class Settings:
|
|
168
|
+
def __init__(self, settings_module):
|
|
169
|
+
# update this dict from global
|
|
170
|
+
# settings (but only for ALL_CAPS settings)
|
|
171
|
+
for setting in dir(default_settings):
|
|
172
|
+
if setting.isupper():
|
|
173
|
+
setattr(self, setting, getattr(default_settings, setting))
|
|
174
|
+
|
|
175
|
+
# store the settings module in case someone later cares
|
|
176
|
+
self.SETTINGS_MODULE = settings_module
|
|
177
|
+
|
|
178
|
+
mod = importlib.import_module(self.SETTINGS_MODULE)
|
|
179
|
+
|
|
180
|
+
tuple_settings = (
|
|
181
|
+
"INSTALLED_APPS",
|
|
182
|
+
"TEMPLATE_DIRS",
|
|
183
|
+
"LOCALE_PATHS",
|
|
184
|
+
)
|
|
185
|
+
self._explicit_settings = set()
|
|
186
|
+
for setting in dir(mod):
|
|
187
|
+
if setting.isupper():
|
|
188
|
+
setting_value = getattr(mod, setting)
|
|
189
|
+
|
|
190
|
+
if (setting in tuple_settings and
|
|
191
|
+
not isinstance(setting_value, (list, tuple))):
|
|
192
|
+
raise Exception(
|
|
193
|
+
"The %s setting must be a list or a tuple. " % setting)
|
|
194
|
+
setattr(self, setting, setting_value)
|
|
195
|
+
self._explicit_settings.add(setting)
|
|
196
|
+
|
|
197
|
+
if self.is_overridden('PASSWORD_RESET_TIMEOUT_DAYS'):
|
|
198
|
+
if self.is_overridden('PASSWORD_RESET_TIMEOUT'):
|
|
199
|
+
raise Exception(
|
|
200
|
+
'PASSWORD_RESET_TIMEOUT_DAYS/PASSWORD_RESET_TIMEOUT are '
|
|
201
|
+
'mutually exclusive.'
|
|
202
|
+
)
|
|
203
|
+
setattr(self, 'PASSWORD_RESET_TIMEOUT',
|
|
204
|
+
self.PASSWORD_RESET_TIMEOUT_DAYS * 60 * 60 * 24)
|
|
205
|
+
# warnings.warn(PASSWORD_RESET_TIMEOUT_DAYS_DEPRECATED_MSG,
|
|
206
|
+
# RemovedInPGP40Warning)
|
|
207
|
+
|
|
208
|
+
# if self.is_overridden('DEFAULT_HASHING_ALGORITHM'):
|
|
209
|
+
# warnings.warn(DEFAULT_HASHING_ALGORITHM_DEPRECATED_MSG,
|
|
210
|
+
# RemovedInPGP40Warning)
|
|
211
|
+
|
|
212
|
+
def is_overridden(self, setting):
|
|
213
|
+
return setting in self._explicit_settings
|
|
214
|
+
|
|
215
|
+
def __repr__(self):
|
|
216
|
+
return '<%(cls)s "%(settings_module)s">' % {
|
|
217
|
+
'cls': self.__class__.__name__,
|
|
218
|
+
'settings_module': self.SETTINGS_MODULE,
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
class UserSettingsHolder:
|
|
223
|
+
"""Holder for user configured settings."""
|
|
224
|
+
# SETTINGS_MODULE doesn't make much sense in the manually configured
|
|
225
|
+
# (standalone) case.
|
|
226
|
+
SETTINGS_MODULE = None
|
|
227
|
+
|
|
228
|
+
def __init__(self, default_settings):
|
|
229
|
+
"""
|
|
230
|
+
Requests for configuration variables not in this class are satisfied
|
|
231
|
+
from the module specified in default_settings (if possible).
|
|
232
|
+
"""
|
|
233
|
+
self.__dict__['_deleted'] = set()
|
|
234
|
+
self.default_settings = default_settings
|
|
235
|
+
|
|
236
|
+
def __getattr__(self, name):
|
|
237
|
+
if not name.isupper() or name in self._deleted:
|
|
238
|
+
raise AttributeError
|
|
239
|
+
return getattr(self.default_settings, name)
|
|
240
|
+
|
|
241
|
+
def __setattr__(self, name, value):
|
|
242
|
+
self._deleted.discard(name)
|
|
243
|
+
# if name == 'PASSWORD_RESET_TIMEOUT_DAYS':
|
|
244
|
+
# setattr(self, 'PASSWORD_RESET_TIMEOUT', value * 60 * 60 * 24)
|
|
245
|
+
# warnings.warn(PASSWORD_RESET_TIMEOUT_DAYS_DEPRECATED_MSG,
|
|
246
|
+
# RemovedInPGP40Warning)
|
|
247
|
+
# if name == 'DEFAULT_HASHING_ALGORITHM':
|
|
248
|
+
# warnings.warn(DEFAULT_HASHING_ALGORITHM_DEPRECATED_MSG,
|
|
249
|
+
# RemovedInPGP40Warning)
|
|
250
|
+
super().__setattr__(name, value)
|
|
251
|
+
|
|
252
|
+
def __delattr__(self, name):
|
|
253
|
+
self._deleted.add(name)
|
|
254
|
+
if hasattr(self, name):
|
|
255
|
+
super().__delattr__(name)
|
|
256
|
+
|
|
257
|
+
def __dir__(self):
|
|
258
|
+
return sorted(
|
|
259
|
+
s for s in [*self.__dict__, *dir(self.default_settings)]
|
|
260
|
+
if s not in self._deleted
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
def is_overridden(self, setting):
|
|
264
|
+
deleted = (setting in self._deleted)
|
|
265
|
+
set_locally = (setting in self.__dict__)
|
|
266
|
+
set_on_default = getattr(
|
|
267
|
+
self.default_settings, 'is_overridden', lambda s: False)(setting)
|
|
268
|
+
return deleted or set_locally or set_on_default
|
|
269
|
+
|
|
270
|
+
def __repr__(self):
|
|
271
|
+
return '<%(cls)s>' % {
|
|
272
|
+
'cls': self.__class__.__name__,
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
settings = LazySettings()
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Default PGP settings.
|
|
6
|
+
"""
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
# from pyecharts.globals import NotebookType
|
|
10
|
+
|
|
11
|
+
class PGP_ENV:
|
|
12
|
+
DEV = "dev" # 本地开发
|
|
13
|
+
DEBUG = "debug" # 本地测试
|
|
14
|
+
RPC = "rpc" # rpc
|
|
15
|
+
RUN_WORKER = "run_worker" # 训练worker
|
|
16
|
+
PREDICT_WORKER = "predict_worker" # 预测worker
|
|
17
|
+
SDK = "sdk" # sdk
|
|
18
|
+
NONE = "none" # 非执行训练和预测环境
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
DEBUG = False if str(os.environ.get("PGP_NOT_DEBUG")) == "1" else True
|
|
22
|
+
ISDEV = False if str(os.environ.get("PGP_NOT_DEV")) == "1" else True
|
|
23
|
+
ISJUPYTER = True if str(os.environ.get("PGP_JUPYTER")) == "1" else False
|
|
24
|
+
RUN_PERMISSION = True if str(os.environ.get("PGP_RUN_PERMISSION")) == "1" else False
|
|
25
|
+
RUN_MODEL_SAVE_PATH = os.environ.get("PGP_RUN_MODEL_SAVE_PATH", "")
|
|
26
|
+
SDK_MODEL_SAVE_PATH = os.environ.get("PGP_SDK_MODEL_SAVE_PATH", "")
|
|
27
|
+
PREDICT_MODEL_SAVE_PATH = os.environ.get("PGP_PREDICT_MODEL_SAVE_PATH", '')
|
|
28
|
+
PREDICT_RESULT_SAVE_PATH = os.environ.get("PGP_PREDICT_RESULT_SAVE_PATH", '')
|
|
29
|
+
BACKTEST_RESULT_SAVE_PATH = os.environ.get("PGP_BACKTEST_RESULT_SAVE_PATH", '')
|
|
30
|
+
RUN_RESULT_SAVE_PATH = os.environ.get("PGP_RUN_RESULT_SAVE_PATH", '')
|
|
31
|
+
EVALUATE_RESULT_SAVE_PATH = os.environ.get("PGP_EVALUATE_RESULT_SAVE_PATH", '')
|
|
32
|
+
TEMP_SAVE_PATH = os.environ.get("PGP_TEMP_SAVE_PATH", "")
|
|
33
|
+
MODULES_CACHE_PATH = os.environ.get("PGP_MODULES_CACHE_PATH", '')
|
|
34
|
+
REDIS_HOST = os.environ.get("REDIS_HOST", '39.105.185.60')
|
|
35
|
+
REDIS_PORT = int(os.environ.get("REDIS_PORT", '6371'))
|
|
36
|
+
PGP_DB_HOST = os.environ.get("PGP_DB_HOST", '39.105.185.60')
|
|
37
|
+
PGP_DB_PORT = int(os.environ.get("PGP_DB_PORT", '33061'))
|
|
38
|
+
AMQP_URL = os.environ.get("PGP_AMQP_URL", 'amqp://mlf:mlfadmin@47.94.251.175:6296/mlf_vhost')
|
|
39
|
+
RUN_TIMEOUT = int(os.environ.get("RUN_TIMEOUT", 60 * 60 * 6)) # 训练超时2小时
|
|
40
|
+
PREDICT_TIMEOUT = int(os.environ.get("PREDICT_TIMEOUT", 60 * 10)) # 预测超时5分钟
|
|
41
|
+
RT_DB_CONNECTOR = os.environ.get("RT_DB_CONNECTOR", '')
|
|
42
|
+
ISONLINE = True if str(os.environ.get("PGP_IS_ONLINE")) == "1" else False
|
|
43
|
+
DEPLOYMENT_ENV = os.environ.get("PGP_DEPLOYMENT_ENV", "none")
|
|
44
|
+
RUN_ENV = os.environ.get("PGP_RUN_ENV", 'test') # 运行环境, test, online, dev, sdk, image
|
|
45
|
+
DBPOOL_SERVER_NAME = os.environ.get("PGP_DBPOOL_SERVER_NAME", 'mlf')
|
|
46
|
+
PGP_PDB_PORT = int(os.environ.get("PGP_PDB_PORT", '6688'))
|
|
47
|
+
|
|
48
|
+
# 模型保存配置
|
|
49
|
+
if DEPLOYMENT_ENV == PGP_ENV.SDK:
|
|
50
|
+
HOME_CACHE_PATH = os.path.join(os.path.expanduser('~'), '.cache', 'PipeGraphPy','sdk')
|
|
51
|
+
if not SDK_MODEL_SAVE_PATH:
|
|
52
|
+
SDK_MODEL_SAVE_PATH = os.path.join(HOME_CACHE_PATH, "sdk")
|
|
53
|
+
if not os.path.exists(SDK_MODEL_SAVE_PATH):
|
|
54
|
+
os.makedirs(SDK_MODEL_SAVE_PATH)
|
|
55
|
+
else:
|
|
56
|
+
HOME_CACHE_PATH = os.path.join(os.path.expanduser('~'), '.cache', 'PipeGraphPy')
|
|
57
|
+
if not RUN_MODEL_SAVE_PATH:
|
|
58
|
+
RUN_MODEL_SAVE_PATH = os.path.join(HOME_CACHE_PATH, "models")
|
|
59
|
+
if not PREDICT_MODEL_SAVE_PATH:
|
|
60
|
+
PREDICT_MODEL_SAVE_PATH = os.path.join(HOME_CACHE_PATH, "models")
|
|
61
|
+
if not PREDICT_RESULT_SAVE_PATH:
|
|
62
|
+
PREDICT_RESULT_SAVE_PATH = os.path.join(HOME_CACHE_PATH, "predict_result")
|
|
63
|
+
if not BACKTEST_RESULT_SAVE_PATH:
|
|
64
|
+
BACKTEST_RESULT_SAVE_PATH = os.path.join(HOME_CACHE_PATH, "backtest_result")
|
|
65
|
+
if not RUN_RESULT_SAVE_PATH:
|
|
66
|
+
RUN_RESULT_SAVE_PATH = os.path.join(HOME_CACHE_PATH, "run_result")
|
|
67
|
+
if not EVALUATE_RESULT_SAVE_PATH:
|
|
68
|
+
EVALUATE_RESULT_SAVE_PATH = os.path.join(HOME_CACHE_PATH, "evaluate_result")
|
|
69
|
+
if not TEMP_SAVE_PATH:
|
|
70
|
+
TEMP_SAVE_PATH = os.path.join(HOME_CACHE_PATH, "temp")
|
|
71
|
+
if not MODULES_CACHE_PATH:
|
|
72
|
+
MODULES_CACHE_PATH = os.path.join(HOME_CACHE_PATH, "modules")
|
|
73
|
+
if not os.path.exists(MODULES_CACHE_PATH):
|
|
74
|
+
os.makedirs(MODULES_CACHE_PATH)
|
|
75
|
+
_init_file = os.path.join(MODULES_CACHE_PATH, "__init__.py")
|
|
76
|
+
with open(_init_file, "w") as f:
|
|
77
|
+
f.write("#")
|
|
78
|
+
sys.path.append(os.path.dirname(MODULES_CACHE_PATH))
|
|
79
|
+
MODEL_SAVE_NAME = "graph_model_{graph_id}_{object_id}"
|
|
80
|
+
ALGO_MODEL_SAVE_NAME = "algo_model_{graph_id}_{node_id}_{algo_mod_type}_{idx}"
|
|
81
|
+
|
|
82
|
+
# 运行模式 1: 包引用 2:grpc
|
|
83
|
+
RUN_PATTERN = 1
|
|
84
|
+
|
|
85
|
+
# redis设置
|
|
86
|
+
REDIS_DB = 3 if str(os.environ.get("PGP_NOT_DEV")) == "1" else 4
|
|
87
|
+
REDIS_KEY_TTL = 7 * 24 * 60 * 60 # 过期时间,默认7天
|
|
88
|
+
|
|
89
|
+
# celery 存储设置
|
|
90
|
+
CELERY_REDIS_HOST = None
|
|
91
|
+
CELERY_REDIS_PORT = None
|
|
92
|
+
CELERY_REDIS_DB = None
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
# 时间格式
|
|
96
|
+
DATETIME_FORMAT = "%H:%M:%S"
|
|
97
|
+
DATETIME_TOTAL_FORMAT = "%Y-%m-%d %H:%M:%S"
|
|
98
|
+
DATETIME_INPUT_FORMATS = [
|
|
99
|
+
"%Y-%m-%d %H:%M:%S",
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
# 计算存储引擎
|
|
103
|
+
STORAGE_ENGINE = "file"
|
|
104
|
+
|
|
105
|
+
# 结构数据库配置
|
|
106
|
+
DATABASES = {
|
|
107
|
+
"ENGINE": "sqlite3",
|
|
108
|
+
"NAME": "PipeGraphPy",
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
# 数据库配置
|
|
112
|
+
DATABASES_POOL = None
|
|
113
|
+
# 数据库名称
|
|
114
|
+
DATABASE_NAME = None
|
|
115
|
+
DATABASE_SERVER_NAME = None
|
|
116
|
+
DATABASE_DB_NAME = None
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
# jupyter_type
|
|
120
|
+
# JUPYTER_TYPE = NotebookType.JUPYTER_LAB
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
# SDK是否显示log日志
|
|
124
|
+
SDK_SHOW_LOG = False
|
|
125
|
+
|