onecode 1.2.1__tar.gz → 1.3.0__tar.gz
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-1.2.1 → onecode-1.3.0}/PKG-INFO +25 -24
- {onecode-1.2.1 → onecode-1.3.0}/README.md +7 -0
- {onecode-1.2.1 → onecode-1.3.0}/onecode/__init__.py +1 -1
- {onecode-1.2.1 → onecode-1.3.0}/onecode/base/__init__.py +0 -1
- {onecode-1.2.1 → onecode-1.3.0}/onecode/base/enums.py +21 -25
- {onecode-1.2.1 → onecode-1.3.0}/onecode/base/logger.py +20 -28
- {onecode-1.2.1 → onecode-1.3.0}/onecode/base/project.py +12 -18
- {onecode-1.2.1 → onecode-1.3.0}/onecode/cli/add.py +0 -2
- {onecode-1.2.1 → onecode-1.3.0}/onecode/cli/build.py +0 -3
- {onecode-1.2.1 → onecode-1.3.0}/onecode/cli/create.py +0 -2
- {onecode-1.2.1 → onecode-1.3.0}/onecode/cli/extract.py +0 -4
- {onecode-1.2.1 → onecode-1.3.0}/onecode/cli/skeleton/main.py +1 -1
- {onecode-1.2.1 → onecode-1.3.0}/onecode/cli/utils.py +47 -29
- {onecode-1.2.1 → onecode-1.3.0}/onecode/cli/zip.py +0 -2
- {onecode-1.2.1 → onecode-1.3.0}/onecode/elements/input/__init__.pyi +1 -1
- {onecode-1.2.1 → onecode-1.3.0}/onecode/elements/input/checkbox.py +0 -3
- onecode-1.3.0/onecode/elements/input/csv_reader.py +275 -0
- {onecode-1.2.1 → onecode-1.3.0}/onecode/elements/input/dropdown.py +0 -4
- {onecode-1.2.1 → onecode-1.3.0}/onecode/elements/input/file_input.py +0 -4
- {onecode-1.2.1 → onecode-1.3.0}/onecode/elements/input/number_input.py +0 -3
- {onecode-1.2.1 → onecode-1.3.0}/onecode/elements/input/radio_button.py +0 -3
- {onecode-1.2.1 → onecode-1.3.0}/onecode/elements/input/slider.py +0 -3
- {onecode-1.2.1 → onecode-1.3.0}/onecode/elements/input/text_input.py +0 -3
- {onecode-1.2.1 → onecode-1.3.0}/onecode/elements/input_element.py +13 -8
- {onecode-1.2.1 → onecode-1.3.0}/onecode/elements/output/__init__.pyi +1 -1
- {onecode-1.2.1 → onecode-1.3.0}/onecode/elements/output/file_output.py +0 -3
- {onecode-1.2.1 → onecode-1.3.0}/onecode/elements/output_element.py +0 -2
- onecode-1.3.0/onecode/pycg/LICENCE +201 -0
- onecode-1.3.0/onecode/pycg/__init__.py +0 -0
- onecode-1.3.0/onecode/pycg/machinery/__init__.py +0 -0
- onecode-1.3.0/onecode/pycg/machinery/callgraph.py +68 -0
- onecode-1.3.0/onecode/pycg/machinery/classes.py +78 -0
- onecode-1.3.0/onecode/pycg/machinery/definitions.py +230 -0
- onecode-1.3.0/onecode/pycg/machinery/imports.py +235 -0
- onecode-1.3.0/onecode/pycg/machinery/modules.py +64 -0
- onecode-1.3.0/onecode/pycg/machinery/pointers.py +149 -0
- onecode-1.3.0/onecode/pycg/machinery/scopes.py +154 -0
- onecode-1.3.0/onecode/pycg/processing/__init__.py +0 -0
- onecode-1.3.0/onecode/pycg/processing/base.py +547 -0
- onecode-1.3.0/onecode/pycg/processing/cgprocessor.py +253 -0
- onecode-1.3.0/onecode/pycg/processing/postprocessor.py +342 -0
- onecode-1.3.0/onecode/pycg/processing/preprocessor.py +425 -0
- onecode-1.3.0/onecode/pycg/pycg.py +246 -0
- onecode-1.3.0/onecode/pycg/utils/__init__.py +22 -0
- onecode-1.3.0/onecode/pycg/utils/common.py +45 -0
- onecode-1.3.0/onecode/pycg/utils/constants.py +41 -0
- {onecode-1.2.1 → onecode-1.3.0}/onecode/utils/import_input.py +0 -2
- {onecode-1.2.1 → onecode-1.3.0}/onecode/utils/import_output.py +0 -2
- {onecode-1.2.1 → onecode-1.3.0}/onecode/utils/module.py +103 -12
- {onecode-1.2.1 → onecode-1.3.0}/onecode/utils/typing.py +18 -6
- {onecode-1.2.1 → onecode-1.3.0}/pyproject.toml +49 -25
- onecode-1.2.1/onecode/base/decorator.py +0 -31
- onecode-1.2.1/onecode/elements/input/csv_reader.py +0 -162
- {onecode-1.2.1 → onecode-1.3.0}/LICENSE +0 -0
- {onecode-1.2.1 → onecode-1.3.0}/onecode/base/singleton.py +0 -0
- {onecode-1.2.1 → onecode-1.3.0}/onecode/cli/__init__.py +0 -0
- {onecode-1.2.1 → onecode-1.3.0}/onecode/cli/check.py +0 -0
- {onecode-1.2.1 → onecode-1.3.0}/onecode/cli/require.py +0 -0
- {onecode-1.2.1 → onecode-1.3.0}/onecode/cli/skeleton/.gitignore +0 -0
- {onecode-1.2.1 → onecode-1.3.0}/onecode/cli/skeleton/LICENSE +0 -0
- {onecode-1.2.1 → onecode-1.3.0}/onecode/cli/skeleton/README.md +0 -0
- {onecode-1.2.1 → onecode-1.3.0}/onecode/cli/skeleton/data/README.md +0 -0
- {onecode-1.2.1 → onecode-1.3.0}/onecode/cli/skeleton/flows/README.md +0 -0
- {onecode-1.2.1 → onecode-1.3.0}/onecode/cli/skeleton/requirements.txt +0 -0
- {onecode-1.2.1 → onecode-1.3.0}/onecode/cli/start.py +0 -0
- {onecode-1.2.1 → onecode-1.3.0}/onecode/elements/__init__.py +0 -0
- {onecode-1.2.1 → onecode-1.3.0}/onecode/elements/input/__init__.py +0 -0
- {onecode-1.2.1 → onecode-1.3.0}/onecode/elements/output/__init__.py +0 -0
- {onecode-1.2.1 → onecode-1.3.0}/onecode/utils/__init__.py +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: onecode
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: Python skeleton and library for OneCode projects
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
7
7
|
Keywords: onecode,share,deploy,cloud
|
|
8
8
|
Author: DeepLime
|
|
9
9
|
Author-email: contact@deeplime.io
|
|
10
|
-
Requires-Python: >=3.
|
|
10
|
+
Requires-Python: >=3.11,<3.15
|
|
11
11
|
Classifier: Development Status :: 5 - Production/Stable
|
|
12
12
|
Classifier: Intended Audience :: Developers
|
|
13
13
|
Classifier: Intended Audience :: End Users/Desktop
|
|
@@ -17,9 +17,6 @@ Classifier: Operating System :: Microsoft :: Windows
|
|
|
17
17
|
Classifier: Operating System :: Unix
|
|
18
18
|
Classifier: Programming Language :: Python
|
|
19
19
|
Classifier: Programming Language :: Python :: 3
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
23
20
|
Classifier: Programming Language :: Python :: 3.11
|
|
24
21
|
Classifier: Programming Language :: Python :: 3.12
|
|
25
22
|
Classifier: Programming Language :: Python :: 3.13
|
|
@@ -29,30 +26,27 @@ Classifier: Topic :: Software Development :: Code Generators
|
|
|
29
26
|
Provides-Extra: developer
|
|
30
27
|
Provides-Extra: docs
|
|
31
28
|
Requires-Dist: datatest (>=0.11.1,<1) ; extra == "developer"
|
|
32
|
-
Requires-Dist:
|
|
33
|
-
Requires-Dist: griffe (>=
|
|
29
|
+
Requires-Dist: filelock (>=3.30,<5)
|
|
30
|
+
Requires-Dist: griffe (>=2,<3) ; extra == "docs"
|
|
34
31
|
Requires-Dist: inquirerpy (>=0.3.3,<1)
|
|
35
|
-
Requires-Dist: mike (>=
|
|
36
|
-
Requires-Dist: mkdocs (>=1.
|
|
37
|
-
Requires-Dist: mkdocs-material (>=9.
|
|
38
|
-
Requires-Dist: mkdocstrings (>=
|
|
39
|
-
Requires-Dist: mkdocstrings-python (>=
|
|
40
|
-
Requires-Dist:
|
|
41
|
-
Requires-Dist:
|
|
42
|
-
Requires-Dist:
|
|
43
|
-
Requires-Dist:
|
|
44
|
-
Requires-Dist: pytest (>=
|
|
45
|
-
Requires-Dist: pytest-
|
|
46
|
-
Requires-Dist:
|
|
47
|
-
Requires-Dist: python-slugify (>=6.1.2,<9)
|
|
32
|
+
Requires-Dist: mike (>=2,<3) ; extra == "docs"
|
|
33
|
+
Requires-Dist: mkdocs (>=1.6,<2) ; extra == "docs"
|
|
34
|
+
Requires-Dist: mkdocs-material (>=9.7.7,<10) ; extra == "docs"
|
|
35
|
+
Requires-Dist: mkdocstrings (>=1,<2) ; extra == "docs"
|
|
36
|
+
Requires-Dist: mkdocstrings-python (>=2,<3) ; extra == "docs"
|
|
37
|
+
Requires-Dist: pandas (>=2.3,<4)
|
|
38
|
+
Requires-Dist: pyarrow (>=22,<26)
|
|
39
|
+
Requires-Dist: pydash (>=7,<9)
|
|
40
|
+
Requires-Dist: pytest (>=9.0.3,<10) ; extra == "developer"
|
|
41
|
+
Requires-Dist: pytest-cov (>=6,<8) ; extra == "developer"
|
|
42
|
+
Requires-Dist: pytest-xdist (>=3.6,<4) ; extra == "developer"
|
|
43
|
+
Requires-Dist: python-slugify (>=8,<10)
|
|
48
44
|
Requires-Dist: requirements-parser (>=0.10.2,<1)
|
|
49
|
-
Requires-Dist:
|
|
50
|
-
Requires-Dist: toml (>=0.10.2,<1) ; extra == "developer"
|
|
51
|
-
Requires-Dist: typeguard (>=3,<5)
|
|
52
|
-
Requires-Dist: yaspin (>=2.1.0,<4)
|
|
45
|
+
Requires-Dist: yaspin (>=3,<4)
|
|
53
46
|
Project-URL: Documentation, https://deeplime-io.github.io/onecode
|
|
54
47
|
Project-URL: Homepage, https://github.com/deeplime-io/onecode
|
|
55
48
|
Project-URL: Repository, https://github.com/deeplime-io/onecode
|
|
49
|
+
Project-URL: SBOM, https://github.com/deeplime-io/onecode/releases/latest
|
|
56
50
|
Description-Content-Type: text/markdown
|
|
57
51
|
|
|
58
52
|

|
|
@@ -69,6 +63,9 @@ Description-Content-Type: text/markdown
|
|
|
69
63
|
|
|
70
64
|
---
|
|
71
65
|
|
|
66
|
+
> **1.x is in maintenance.** 1.3.0 is the last 1.x feature release and the last one for the legacy OneCode Cloud.
|
|
67
|
+
> The 1.3.x line receives security fixes only, until 30 June 2027. See [SECURITY.md](https://github.com/deeplime-io/onecode/security/policy).
|
|
68
|
+
|
|
72
69
|
OneCode, your gateway to Python application deployment on the Cloud!
|
|
73
70
|
Pssst, if you're not into rolling out your App but simply using them, check out the [OneCode Cloud user doc](https://deeplime-io.github.io/onecode/1.0.0/user_doc).
|
|
74
71
|
|
|
@@ -274,6 +271,10 @@ for your patience on that one.
|
|
|
274
271
|
|
|
275
272
|
## :wave: Getting Help
|
|
276
273
|
|
|
274
|
+
Security reports go through [private vulnerability reporting](https://github.com/deeplime-io/onecode/security/advisories/new). See [SECURITY.md](https://github.com/deeplime-io/onecode/security/policy). Security fixes are published for the 1.3.x line until 30 June 2027.
|
|
275
|
+
|
|
276
|
+
Issues labeled [`cra-vulnerability`](https://github.com/deeplime-io/onecode/issues?q=is%3Aissue+is%3Aopen+label%3Acra-vulnerability) come from the dependency scan. They are not the place to disclose a new flaw.
|
|
277
|
+
|
|
277
278
|
If you are a OneCode customer, you may directly email our support team.
|
|
278
279
|
Feel free as well to browse the [GitHub Issues](https://github.com/deeplime-io/onecode/issues)
|
|
279
280
|
and reach out to the community by posting bug reports, questions and suggestions.
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
+
> **1.x is in maintenance.** 1.3.0 is the last 1.x feature release and the last one for the legacy OneCode Cloud.
|
|
16
|
+
> The 1.3.x line receives security fixes only, until 30 June 2027. See [SECURITY.md](https://github.com/deeplime-io/onecode/security/policy).
|
|
17
|
+
|
|
15
18
|
OneCode, your gateway to Python application deployment on the Cloud!
|
|
16
19
|
Pssst, if you're not into rolling out your App but simply using them, check out the [OneCode Cloud user doc](https://deeplime-io.github.io/onecode/1.0.0/user_doc).
|
|
17
20
|
|
|
@@ -217,6 +220,10 @@ for your patience on that one.
|
|
|
217
220
|
|
|
218
221
|
## :wave: Getting Help
|
|
219
222
|
|
|
223
|
+
Security reports go through [private vulnerability reporting](https://github.com/deeplime-io/onecode/security/advisories/new). See [SECURITY.md](https://github.com/deeplime-io/onecode/security/policy). Security fixes are published for the 1.3.x line until 30 June 2027.
|
|
224
|
+
|
|
225
|
+
Issues labeled [`cra-vulnerability`](https://github.com/deeplime-io/onecode/issues?q=is%3Aissue+is%3Aopen+label%3Acra-vulnerability) come from the dependency scan. They are not the place to disclose a new flaw.
|
|
226
|
+
|
|
220
227
|
If you are a OneCode customer, you may directly email our support team.
|
|
221
228
|
Feel free as well to browse the [GitHub Issues](https://github.com/deeplime-io/onecode/issues)
|
|
222
229
|
and reach out to the community by posting bug reports, questions and suggestions.
|
|
@@ -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
|
|
@@ -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.
|
|
@@ -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')
|
|
@@ -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,
|
|
@@ -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,
|
|
@@ -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,
|
|
@@ -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
|