onecode 1.2.2__py3-none-any.whl → 1.3.0__py3-none-any.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.
- onecode/__init__.py +1 -1
- onecode/base/__init__.py +0 -1
- onecode/base/enums.py +21 -25
- onecode/base/logger.py +20 -28
- onecode/base/project.py +12 -18
- onecode/cli/add.py +0 -2
- onecode/cli/build.py +0 -3
- onecode/cli/create.py +0 -2
- onecode/cli/extract.py +0 -4
- onecode/cli/skeleton/main.py +1 -1
- onecode/cli/utils.py +7 -13
- onecode/cli/zip.py +0 -2
- onecode/elements/input/__init__.pyi +1 -1
- onecode/elements/input/checkbox.py +0 -3
- onecode/elements/input/csv_reader.py +133 -20
- onecode/elements/input/dropdown.py +0 -4
- onecode/elements/input/file_input.py +0 -4
- onecode/elements/input/number_input.py +0 -3
- onecode/elements/input/radio_button.py +0 -3
- onecode/elements/input/slider.py +0 -3
- onecode/elements/input/text_input.py +0 -3
- onecode/elements/input_element.py +13 -8
- onecode/elements/output/__init__.pyi +1 -1
- onecode/elements/output/file_output.py +0 -3
- onecode/elements/output_element.py +0 -2
- onecode/pycg/LICENCE +201 -0
- onecode/pycg/__init__.py +0 -0
- onecode/pycg/machinery/__init__.py +0 -0
- onecode/pycg/machinery/callgraph.py +68 -0
- onecode/pycg/machinery/classes.py +78 -0
- onecode/pycg/machinery/definitions.py +230 -0
- onecode/pycg/machinery/imports.py +235 -0
- onecode/pycg/machinery/modules.py +64 -0
- onecode/pycg/machinery/pointers.py +149 -0
- onecode/pycg/machinery/scopes.py +154 -0
- onecode/pycg/processing/__init__.py +0 -0
- onecode/pycg/processing/base.py +547 -0
- onecode/pycg/processing/cgprocessor.py +253 -0
- onecode/pycg/processing/postprocessor.py +342 -0
- onecode/pycg/processing/preprocessor.py +425 -0
- onecode/pycg/pycg.py +246 -0
- onecode/pycg/utils/__init__.py +22 -0
- onecode/pycg/utils/common.py +45 -0
- onecode/pycg/utils/constants.py +41 -0
- onecode/utils/import_input.py +0 -2
- onecode/utils/import_output.py +0 -2
- onecode/utils/module.py +5 -11
- onecode/utils/typing.py +18 -6
- {onecode-1.2.2.dist-info → onecode-1.3.0.dist-info}/METADATA +25 -24
- onecode-1.3.0.dist-info/RECORD +68 -0
- {onecode-1.2.2.dist-info → onecode-1.3.0.dist-info}/WHEEL +1 -1
- onecode/base/decorator.py +0 -31
- onecode-1.2.2.dist-info/RECORD +0 -50
- {onecode-1.2.2.dist-info → onecode-1.3.0.dist-info}/entry_points.txt +0 -0
- {onecode-1.2.2.dist-info → onecode-1.3.0.dist-info}/licenses/LICENSE +0 -0
onecode/__init__.py
CHANGED
onecode/base/__init__.py
CHANGED
onecode/base/enums.py
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# SPDX-FileCopyrightText: 2023-2024 DeepLime <contact@deeplime.io>
|
|
2
2
|
# SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
from strenum import StrEnum
|
|
4
|
+
from enum import StrEnum
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
class Env(StrEnum):
|
|
@@ -13,16 +12,13 @@ class Env(StrEnum):
|
|
|
13
12
|
:octicons-arrow-both-24: `"ONECODE_PROJECT_DATA"`
|
|
14
13
|
- `ONECODE_CONFIG_FILE`: name of the file containing OneCode project configurations
|
|
15
14
|
:octicons-arrow-both-24: `".onecode.json"`
|
|
16
|
-
- `ONECODE_DO_TYPECHECK`: set to 1 to force runtime type-checking with Pydantic
|
|
17
|
-
:octicons-arrow-both-24: `"ONECODE_DO_TYPECHECK"`
|
|
18
15
|
- `ONECODE_LOGGER_NAME`: base logger name to avoid logging conflict with other loggers
|
|
19
16
|
:octicons-arrow-both-24: `|OneCode|`
|
|
20
17
|
|
|
21
18
|
"""
|
|
22
|
-
ONECODE_PROJECT_DATA = "ONECODE_PROJECT_DATA" # noqa:
|
|
23
|
-
ONECODE_CONFIG_FILE = ".onecode.json" # noqa:
|
|
24
|
-
|
|
25
|
-
ONECODE_LOGGER_NAME = "|OneCode|" # noqa: E-221
|
|
19
|
+
ONECODE_PROJECT_DATA = "ONECODE_PROJECT_DATA" # noqa: E221
|
|
20
|
+
ONECODE_CONFIG_FILE = ".onecode.json" # noqa: E221
|
|
21
|
+
ONECODE_LOGGER_NAME = "|OneCode|" # noqa: E221
|
|
26
22
|
|
|
27
23
|
|
|
28
24
|
class ConfigOption(StrEnum):
|
|
@@ -39,11 +35,11 @@ class ConfigOption(StrEnum):
|
|
|
39
35
|
typically to handle code using display :octicons-arrow-both-24: `"CLOUD_ENV": False`
|
|
40
36
|
|
|
41
37
|
"""
|
|
42
|
-
FLUSH_STDOUT = "FLUSH_STDOUT" # noqa:
|
|
43
|
-
LOGGER_COLOR = "LOGGER_COLOR" # noqa:
|
|
44
|
-
LOGGER_TIMESTAMP = "LOGGER_TIMESTAMP" # noqa:
|
|
45
|
-
CHECK_MODULES = "CHECK_MODULES" # noqa:
|
|
46
|
-
CLOUD_ENV = "CLOUD_ENV" # noqa:
|
|
38
|
+
FLUSH_STDOUT = "FLUSH_STDOUT" # noqa: E221
|
|
39
|
+
LOGGER_COLOR = "LOGGER_COLOR" # noqa: E221
|
|
40
|
+
LOGGER_TIMESTAMP = "LOGGER_TIMESTAMP" # noqa: E221
|
|
41
|
+
CHECK_MODULES = "CHECK_MODULES" # noqa: E221
|
|
42
|
+
CLOUD_ENV = "CLOUD_ENV" # noqa: E221
|
|
47
43
|
|
|
48
44
|
|
|
49
45
|
class Mode(StrEnum):
|
|
@@ -91,12 +87,12 @@ class Mode(StrEnum):
|
|
|
91
87
|
```
|
|
92
88
|
|
|
93
89
|
"""
|
|
94
|
-
CONSOLE = "_console" # noqa:
|
|
95
|
-
EXECUTE = "_execute" # noqa:
|
|
96
|
-
LOAD_THEN_EXECUTE = "_load_then_execute" # noqa:
|
|
97
|
-
EXTRACT = "_extract" # noqa:
|
|
98
|
-
EXTRACT_ALL = "_extract_all" # noqa:
|
|
99
|
-
BUILD_GUI = "_build_gui" # noqa:
|
|
90
|
+
CONSOLE = "_console" # noqa: E221
|
|
91
|
+
EXECUTE = "_execute" # noqa: E221
|
|
92
|
+
LOAD_THEN_EXECUTE = "_load_then_execute" # noqa: E221
|
|
93
|
+
EXTRACT = "_extract" # noqa: E221
|
|
94
|
+
EXTRACT_ALL = "_extract_all" # noqa: E221
|
|
95
|
+
BUILD_GUI = "_build_gui" # noqa: E221
|
|
100
96
|
|
|
101
97
|
|
|
102
98
|
class ElementType(StrEnum):
|
|
@@ -108,8 +104,8 @@ class ElementType(StrEnum):
|
|
|
108
104
|
- `OUTPUT`: `OutputElement` Type :octicons-arrow-both-24: `"OUTPUT"`
|
|
109
105
|
|
|
110
106
|
"""
|
|
111
|
-
INPUT = "INPUT" # noqa:
|
|
112
|
-
OUTPUT = "OUTPUT" # noqa:
|
|
107
|
+
INPUT = "INPUT" # noqa: E221
|
|
108
|
+
OUTPUT = "OUTPUT" # noqa: E221
|
|
113
109
|
|
|
114
110
|
|
|
115
111
|
class FileFilter(tuple):
|
|
@@ -124,7 +120,7 @@ class FileFilter(tuple):
|
|
|
124
120
|
* `ZIP` :octicons-arrow-both-24: `("ZIP", ".zip .gz .tar.gz .7z")`
|
|
125
121
|
|
|
126
122
|
"""
|
|
127
|
-
CSV = ("CSV", ".csv") # noqa:
|
|
128
|
-
PYTHON = ("Python", ".py") # noqa:
|
|
129
|
-
IMAGE = ("Image", ".jpg .png .jpeg") # noqa:
|
|
130
|
-
ZIP = ("ZIP", ".zip .gz .tar.gz .7z") # noqa:
|
|
123
|
+
CSV = ("CSV", ".csv") # noqa: E221
|
|
124
|
+
PYTHON = ("Python", ".py") # noqa: E221
|
|
125
|
+
IMAGE = ("Image", ".jpg .png .jpeg") # noqa: E221
|
|
126
|
+
ZIP = ("ZIP", ".zip .gz .tar.gz .7z") # noqa: E221
|
onecode/base/logger.py
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
# SPDX-FileCopyrightText: 2023-2024 DeepLime <contact@deeplime.io>
|
|
2
2
|
# SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import ast
|
|
5
4
|
import inspect
|
|
6
5
|
import logging
|
|
7
6
|
import os
|
|
8
7
|
import sys
|
|
9
8
|
from typing import Any, Optional
|
|
10
9
|
|
|
11
|
-
from .decorator import check_type
|
|
12
10
|
from .enums import ConfigOption, Env
|
|
13
11
|
from .project import Project
|
|
14
12
|
from .singleton import Singleton
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
bool(ast.literal_eval(os.environ[Env.ONECODE_DO_TYPECHECK]))
|
|
19
|
-
)
|
|
20
|
-
_logger_stack_level = 6 if _do_type_check else 2
|
|
21
|
-
_stack_level = 4 if _do_type_check else 2
|
|
14
|
+
_logger_stack_level = 2
|
|
15
|
+
_stack_level = 2
|
|
22
16
|
|
|
23
17
|
|
|
24
18
|
class ColoredFormatter(logging.Formatter):
|
|
@@ -44,7 +38,6 @@ class ColoredFormatter(logging.Formatter):
|
|
|
44
38
|
BOLD_RED = "\x1b[31;1m"
|
|
45
39
|
RESET = "\x1b[0m"
|
|
46
40
|
|
|
47
|
-
@check_type
|
|
48
41
|
def __init__(
|
|
49
42
|
self,
|
|
50
43
|
color: bool = True
|
|
@@ -52,7 +45,6 @@ class ColoredFormatter(logging.Formatter):
|
|
|
52
45
|
super().__init__()
|
|
53
46
|
self._color = color
|
|
54
47
|
|
|
55
|
-
@check_type
|
|
56
48
|
def format(
|
|
57
49
|
self,
|
|
58
50
|
record: logging.LogRecord
|
|
@@ -90,14 +82,19 @@ class ColoredFormatter(logging.Formatter):
|
|
|
90
82
|
class Logger(metaclass=Singleton):
|
|
91
83
|
"""
|
|
92
84
|
Single Logger object to handle Python logging within OneCode projects.
|
|
93
|
-
The default logging level is INFO. See
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
[`
|
|
97
|
-
|
|
85
|
+
The default logging level is INFO. See
|
|
86
|
+
[`set_level()`][onecode.base.logger.Logger.set_level] to change it.
|
|
87
|
+
Use the static methods
|
|
88
|
+
[`debug()`][onecode.base.logger.Logger.debug],
|
|
89
|
+
[`info()`][onecode.base.logger.Logger.info],
|
|
90
|
+
[`warning()`][onecode.base.logger.Logger.warning],
|
|
91
|
+
[`error()`][onecode.base.logger.Logger.error], and
|
|
92
|
+
[`critical()`][onecode.base.logger.Logger.critical]
|
|
93
|
+
to conveniently log your messages with the corresponding logging level.
|
|
98
94
|
|
|
99
95
|
By default, the ColoredFormatter is used. You may add other logging handlers using
|
|
100
|
-
[`add_handler()`][onecode.Logger.add_handler],
|
|
96
|
+
[`add_handler()`][onecode.base.logger.Logger.add_handler],
|
|
97
|
+
for instance to redirect logs to a file.
|
|
101
98
|
|
|
102
99
|
!!! example
|
|
103
100
|
```py
|
|
@@ -150,7 +147,6 @@ class Logger(metaclass=Singleton):
|
|
|
150
147
|
base_logger.propagate = False
|
|
151
148
|
self.set_level(logging.INFO)
|
|
152
149
|
|
|
153
|
-
@check_type
|
|
154
150
|
def add_handler(
|
|
155
151
|
self,
|
|
156
152
|
handler: Optional[logging.Handler] = None,
|
|
@@ -182,7 +178,6 @@ class Logger(metaclass=Singleton):
|
|
|
182
178
|
namespace = Env.ONECODE_LOGGER_NAME if not root_logger else None
|
|
183
179
|
logging.getLogger(namespace).addHandler(handler)
|
|
184
180
|
|
|
185
|
-
@check_type
|
|
186
181
|
def set_level(
|
|
187
182
|
self,
|
|
188
183
|
level: int
|
|
@@ -198,16 +193,18 @@ class Logger(metaclass=Singleton):
|
|
|
198
193
|
"""
|
|
199
194
|
logging.getLogger(Env.ONECODE_LOGGER_NAME).setLevel(level)
|
|
200
195
|
|
|
201
|
-
@check_type
|
|
202
196
|
def logger(
|
|
203
197
|
self,
|
|
204
198
|
stacklevel: int = 1,
|
|
205
199
|
) -> logging.Logger:
|
|
206
200
|
"""
|
|
207
201
|
Get the Python Logger object corresponding to the given stack level. Preferentially use
|
|
208
|
-
convenience methods
|
|
209
|
-
[`
|
|
210
|
-
[`
|
|
202
|
+
convenience methods
|
|
203
|
+
[`debug()`][onecode.base.logger.Logger.debug],
|
|
204
|
+
[`info()`][onecode.base.logger.Logger.info],
|
|
205
|
+
[`warning()`][onecode.base.logger.Logger.warning],
|
|
206
|
+
[`error()`][onecode.base.logger.Logger.error], and
|
|
207
|
+
[`critical()`][onecode.base.logger.Logger.critical].
|
|
211
208
|
|
|
212
209
|
Args:
|
|
213
210
|
stacklevel: Number of hops back in the function call stack to tie the logger to.
|
|
@@ -225,14 +222,13 @@ class Logger(metaclass=Singleton):
|
|
|
225
222
|
def _flush() -> None:
|
|
226
223
|
"""
|
|
227
224
|
Force flush to stdout if `ConfigOption.FLUSH_STDOUT` is True. See
|
|
228
|
-
[Project.config][onecode.Project.config] for more information.
|
|
225
|
+
[Project.config][onecode.base.project.Project.config] for more information.
|
|
229
226
|
|
|
230
227
|
"""
|
|
231
228
|
if Project().get_config(ConfigOption.FLUSH_STDOUT):
|
|
232
229
|
sys.stdout.flush()
|
|
233
230
|
|
|
234
231
|
@staticmethod
|
|
235
|
-
@check_type
|
|
236
232
|
def debug(msg: Any) -> None:
|
|
237
233
|
"""
|
|
238
234
|
Convenience function to log a debug message.
|
|
@@ -245,7 +241,6 @@ class Logger(metaclass=Singleton):
|
|
|
245
241
|
Logger._flush()
|
|
246
242
|
|
|
247
243
|
@staticmethod
|
|
248
|
-
@check_type
|
|
249
244
|
def info(msg: Any) -> None:
|
|
250
245
|
"""
|
|
251
246
|
Convenience function to log an info message.
|
|
@@ -258,7 +253,6 @@ class Logger(metaclass=Singleton):
|
|
|
258
253
|
Logger._flush()
|
|
259
254
|
|
|
260
255
|
@staticmethod
|
|
261
|
-
@check_type
|
|
262
256
|
def warning(msg: Any) -> None:
|
|
263
257
|
"""
|
|
264
258
|
Convenience function to log a warning message.
|
|
@@ -271,7 +265,6 @@ class Logger(metaclass=Singleton):
|
|
|
271
265
|
Logger._flush()
|
|
272
266
|
|
|
273
267
|
@staticmethod
|
|
274
|
-
@check_type
|
|
275
268
|
def error(msg: Any) -> None:
|
|
276
269
|
"""
|
|
277
270
|
Convenience function to log an error message.
|
|
@@ -284,7 +277,6 @@ class Logger(metaclass=Singleton):
|
|
|
284
277
|
Logger._flush()
|
|
285
278
|
|
|
286
279
|
@staticmethod
|
|
287
|
-
@check_type
|
|
288
280
|
def critical(msg: Any) -> None:
|
|
289
281
|
"""
|
|
290
282
|
Convenience function to log a critical message.
|
onecode/base/project.py
CHANGED
|
@@ -8,9 +8,8 @@ import sys
|
|
|
8
8
|
from typing import Any, Dict, Optional, Set, Union
|
|
9
9
|
|
|
10
10
|
import pydash
|
|
11
|
-
from
|
|
11
|
+
from filelock import FileLock
|
|
12
12
|
|
|
13
|
-
from .decorator import check_type
|
|
14
13
|
from .enums import ConfigOption, Env, Mode
|
|
15
14
|
from .singleton import Singleton
|
|
16
15
|
|
|
@@ -21,7 +20,7 @@ class Project(metaclass=Singleton):
|
|
|
21
20
|
parameter values, registered elements, flow currently running, current running
|
|
22
21
|
mode, etc.
|
|
23
22
|
|
|
24
|
-
See [`reset()`][onecode.Project.reset] for Project default's initialization.
|
|
23
|
+
See [`reset()`][onecode.base.project.Project.reset] for Project default's initialization.
|
|
25
24
|
|
|
26
25
|
Attributes:
|
|
27
26
|
registered_elements: List of elements registered for processing.
|
|
@@ -108,7 +107,6 @@ class Project(metaclass=Singleton):
|
|
|
108
107
|
"""
|
|
109
108
|
return self._registered_elements
|
|
110
109
|
|
|
111
|
-
@check_type
|
|
112
110
|
def register_element(
|
|
113
111
|
self,
|
|
114
112
|
element_name: str
|
|
@@ -184,13 +182,13 @@ class Project(metaclass=Singleton):
|
|
|
184
182
|
@property
|
|
185
183
|
def data_root(self) -> str:
|
|
186
184
|
"""
|
|
187
|
-
Get the path to the root of the data folder. See
|
|
188
|
-
|
|
185
|
+
Get the path to the root of the data folder. See
|
|
186
|
+
[`reset()`][onecode.base.project.Project.reset]
|
|
187
|
+
to know how the data path is initialized.
|
|
189
188
|
|
|
190
189
|
"""
|
|
191
190
|
return self._data_root
|
|
192
191
|
|
|
193
|
-
@check_type
|
|
194
192
|
def _set_data_root(
|
|
195
193
|
self,
|
|
196
194
|
data_path: str
|
|
@@ -212,7 +210,6 @@ class Project(metaclass=Singleton):
|
|
|
212
210
|
|
|
213
211
|
self._data_root = data_path
|
|
214
212
|
|
|
215
|
-
@check_type
|
|
216
213
|
def get_input_path(
|
|
217
214
|
self,
|
|
218
215
|
filepath: str
|
|
@@ -232,7 +229,6 @@ class Project(metaclass=Singleton):
|
|
|
232
229
|
return filepath if not filepath or os.path.isabs(filepath) \
|
|
233
230
|
else os.path.join(self.data_root, filepath)
|
|
234
231
|
|
|
235
|
-
@check_type
|
|
236
232
|
def get_output_path(
|
|
237
233
|
self,
|
|
238
234
|
filepath: str
|
|
@@ -318,7 +314,6 @@ class Project(metaclass=Singleton):
|
|
|
318
314
|
"""
|
|
319
315
|
self._data = data
|
|
320
316
|
|
|
321
|
-
@check_type
|
|
322
317
|
def add_data(
|
|
323
318
|
self,
|
|
324
319
|
key: str,
|
|
@@ -343,7 +338,6 @@ class Project(metaclass=Singleton):
|
|
|
343
338
|
|
|
344
339
|
self._data[key] = value
|
|
345
340
|
|
|
346
|
-
@check_type
|
|
347
341
|
def set_config(
|
|
348
342
|
self,
|
|
349
343
|
key: Union[ConfigOption, str],
|
|
@@ -365,7 +359,6 @@ class Project(metaclass=Singleton):
|
|
|
365
359
|
|
|
366
360
|
self._config[key] = value
|
|
367
361
|
|
|
368
|
-
@check_type
|
|
369
362
|
def get_config(
|
|
370
363
|
self,
|
|
371
364
|
key: Union[ConfigOption, str]
|
|
@@ -385,7 +378,6 @@ class Project(metaclass=Singleton):
|
|
|
385
378
|
|
|
386
379
|
return self._config[key]
|
|
387
380
|
|
|
388
|
-
@check_type
|
|
389
381
|
def write_output(
|
|
390
382
|
self,
|
|
391
383
|
output: Dict
|
|
@@ -404,9 +396,11 @@ class Project(metaclass=Singleton):
|
|
|
404
396
|
output: Output data to write to the manifest file.
|
|
405
397
|
|
|
406
398
|
"""
|
|
407
|
-
|
|
399
|
+
manifest = self.get_output_manifest()
|
|
400
|
+
lock_path = os.path.join(os.path.dirname(manifest), '.locks', 'MANIFEST.lock')
|
|
408
401
|
|
|
409
|
-
#
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
402
|
+
# OS lock (fcntl on Unix, msvcrt on Windows). Released when the holder
|
|
403
|
+
# exits, so a slow process is not interrupted by a timeout.
|
|
404
|
+
with FileLock(lock_path, timeout=-1, preserve_lock_file=True):
|
|
405
|
+
with open(manifest, "a") as handle:
|
|
406
|
+
handle.write(f'{json.dumps(output)}\n')
|
onecode/cli/add.py
CHANGED
|
@@ -9,12 +9,10 @@ from InquirerPy.validator import PathValidator
|
|
|
9
9
|
from slugify import slugify
|
|
10
10
|
from yaspin import yaspin
|
|
11
11
|
|
|
12
|
-
from ..base.decorator import check_type
|
|
13
12
|
from ..base.enums import Env
|
|
14
13
|
from .utils import _add_flow, _get_flow_choices
|
|
15
14
|
|
|
16
15
|
|
|
17
|
-
@check_type
|
|
18
16
|
def add(
|
|
19
17
|
project_path: str,
|
|
20
18
|
name: str,
|
onecode/cli/build.py
CHANGED
|
@@ -9,14 +9,12 @@ from typing import Dict, List
|
|
|
9
9
|
|
|
10
10
|
import onecode # noqa
|
|
11
11
|
|
|
12
|
-
from ..base.decorator import check_type
|
|
13
12
|
from ..base.enums import * # noqa
|
|
14
13
|
from ..base.enums import ElementType, Mode
|
|
15
14
|
from ..base.project import Project
|
|
16
15
|
from .utils import process_call_graph
|
|
17
16
|
|
|
18
17
|
|
|
19
|
-
@check_type
|
|
20
18
|
def process(calls: List[Dict[str, str]]) -> Dict:
|
|
21
19
|
"""
|
|
22
20
|
Evaluate the given calls such as:
|
|
@@ -80,7 +78,6 @@ def process(calls: List[Dict[str, str]]) -> Dict:
|
|
|
80
78
|
return params
|
|
81
79
|
|
|
82
80
|
|
|
83
|
-
@check_type
|
|
84
81
|
def extract_gui(
|
|
85
82
|
project_path: str,
|
|
86
83
|
to_file: str,
|
onecode/cli/create.py
CHANGED
|
@@ -10,11 +10,9 @@ from InquirerPy.validator import PathValidator
|
|
|
10
10
|
from slugify import slugify
|
|
11
11
|
from yaspin import yaspin
|
|
12
12
|
|
|
13
|
-
from ..base.decorator import check_type
|
|
14
13
|
from .utils import _add_flow
|
|
15
14
|
|
|
16
15
|
|
|
17
|
-
@check_type
|
|
18
16
|
def create(
|
|
19
17
|
project_path: str,
|
|
20
18
|
name: str,
|
onecode/cli/extract.py
CHANGED
|
@@ -11,7 +11,6 @@ from yaspin import yaspin
|
|
|
11
11
|
|
|
12
12
|
import onecode # noqa
|
|
13
13
|
|
|
14
|
-
from ..base.decorator import check_type
|
|
15
14
|
from ..base.enums import * # noqa
|
|
16
15
|
from ..base.enums import ElementType, Mode
|
|
17
16
|
from ..base.project import Project
|
|
@@ -19,7 +18,6 @@ from ..utils.module import register_ext_module
|
|
|
19
18
|
from .utils import process_call_graph
|
|
20
19
|
|
|
21
20
|
|
|
22
|
-
@check_type
|
|
23
21
|
def process(calls: List[Dict[str, str]]) -> Dict:
|
|
24
22
|
"""
|
|
25
23
|
Evaluate the given calls such as:
|
|
@@ -83,7 +81,6 @@ def process(calls: List[Dict[str, str]]) -> Dict:
|
|
|
83
81
|
return params
|
|
84
82
|
|
|
85
83
|
|
|
86
|
-
@check_type
|
|
87
84
|
def extract_json(
|
|
88
85
|
project_path: str,
|
|
89
86
|
to_file: str,
|
|
@@ -113,7 +110,6 @@ def extract_json(
|
|
|
113
110
|
json.dump(parameters, out, indent=4)
|
|
114
111
|
|
|
115
112
|
|
|
116
|
-
@check_type
|
|
117
113
|
def main(cli: bool = True) -> None: # pragma: no cover
|
|
118
114
|
"""
|
|
119
115
|
```bash
|
onecode/cli/skeleton/main.py
CHANGED
onecode/cli/utils.py
CHANGED
|
@@ -9,17 +9,16 @@ from typing import Dict, List, Optional
|
|
|
9
9
|
|
|
10
10
|
import pydash
|
|
11
11
|
from InquirerPy.base.control import Choice
|
|
12
|
-
from pycg.pycg import CallGraphGenerator
|
|
13
|
-
from pycg.utils.constants import CALL_GRAPH_OP
|
|
14
12
|
from slugify import slugify
|
|
15
13
|
|
|
16
|
-
from
|
|
14
|
+
from onecode.pycg.pycg import CallGraphGenerator as _CallGraphGenerator
|
|
15
|
+
from onecode.pycg.utils.constants import CALL_GRAPH_OP as _CALL_GRAPH_OP
|
|
16
|
+
|
|
17
17
|
from ..base.enums import Env
|
|
18
18
|
from ..base.project import Project
|
|
19
19
|
from ..utils.module import get_call_graph_entry_files
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
@check_type
|
|
23
22
|
def get_flows(project_path: str) -> Dict:
|
|
24
23
|
"""
|
|
25
24
|
Get the flows configuration as stored at the OneCode project's root (filename is given by the
|
|
@@ -41,7 +40,6 @@ def get_flows(project_path: str) -> Dict:
|
|
|
41
40
|
return config
|
|
42
41
|
|
|
43
42
|
|
|
44
|
-
@check_type
|
|
45
43
|
def _get_flow_choices(project_path: str) -> List[Choice]: # pragma: no cover
|
|
46
44
|
"""
|
|
47
45
|
Internal function for CLI commands to get the existing OneCode project's flows as interactive
|
|
@@ -60,7 +58,6 @@ def _get_flow_choices(project_path: str) -> List[Choice]: # pragma: no cover
|
|
|
60
58
|
return choices
|
|
61
59
|
|
|
62
60
|
|
|
63
|
-
@check_type
|
|
64
61
|
def _add_flow(
|
|
65
62
|
project_path: str,
|
|
66
63
|
name: Optional[str],
|
|
@@ -164,7 +161,6 @@ def _resolve_graph_key(name: str, graph: Dict) -> str:
|
|
|
164
161
|
return name
|
|
165
162
|
|
|
166
163
|
|
|
167
|
-
# check_type decorator not compatible with recursive calls
|
|
168
164
|
def extract_calls(
|
|
169
165
|
entry_point: str,
|
|
170
166
|
graph: Dict,
|
|
@@ -179,9 +175,8 @@ def extract_calls(
|
|
|
179
175
|
Args:
|
|
180
176
|
entry_point: Call Graph function name from which to start the extraction from, e.g.
|
|
181
177
|
`flows.my_flow.run`.
|
|
182
|
-
graph:
|
|
183
|
-
|
|
184
|
-
https://github.com/deeplime-io/PyCG/tree/onecode
|
|
178
|
+
graph: Enriched call graph produced by the vendored generator in `onecode.pycg`
|
|
179
|
+
(Apache-2.0, derived from PyCG).
|
|
185
180
|
calls: List of calls as `{"func": <function_name>, "loc": <code_to_eval>}` where results
|
|
186
181
|
are aggregated. These `calls` are typically piped to the `process` functions for JSON
|
|
187
182
|
extraction.
|
|
@@ -219,7 +214,6 @@ def extract_calls(
|
|
|
219
214
|
extract_calls(next_point, graph, calls)
|
|
220
215
|
|
|
221
216
|
|
|
222
|
-
@check_type
|
|
223
217
|
def process_call_graph(
|
|
224
218
|
project_path: str = None,
|
|
225
219
|
verbose: bool = False
|
|
@@ -249,11 +243,11 @@ def process_call_graph(
|
|
|
249
243
|
statements = OrderedDict()
|
|
250
244
|
entry_files = get_call_graph_entry_files(project_path)
|
|
251
245
|
|
|
252
|
-
cg =
|
|
246
|
+
cg = _CallGraphGenerator(
|
|
253
247
|
entry_files,
|
|
254
248
|
project_path,
|
|
255
249
|
-1,
|
|
256
|
-
|
|
250
|
+
_CALL_GRAPH_OP
|
|
257
251
|
)
|
|
258
252
|
cg.analyze()
|
|
259
253
|
flow_graph = cg.output_enriched()
|
onecode/cli/zip.py
CHANGED
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
from typing import Any, List, Optional, Union
|
|
5
5
|
|
|
6
|
-
from ...base.decorator import check_type
|
|
7
6
|
from ..input_element import InputElement
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
class Checkbox(InputElement):
|
|
11
|
-
@check_type
|
|
12
10
|
def __init__(
|
|
13
11
|
self,
|
|
14
12
|
key: str,
|
|
@@ -76,7 +74,6 @@ class Checkbox(InputElement):
|
|
|
76
74
|
"""
|
|
77
75
|
return bool
|
|
78
76
|
|
|
79
|
-
@check_type
|
|
80
77
|
def _validate(
|
|
81
78
|
self,
|
|
82
79
|
value: bool
|