hcs-core 0.1.318__tar.gz → 0.1.320__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.
- {hcs_core-0.1.318 → hcs_core-0.1.320}/PKG-INFO +4 -4
- {hcs_core-0.1.318 → hcs_core-0.1.320}/README.md +0 -1
- hcs_core-0.1.320/hcs_core/__init__.py +1 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/_init.py +4 -19
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/cli_options.py +12 -1
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/cli_processor.py +0 -1
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/context.py +1 -2
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/data_util.py +0 -2
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/dispatcher.py +5 -4
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/fstore.py +0 -1
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/profile.py +0 -1
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/task_schd.py +2 -1
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/telemetry.py +0 -1
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/util.py +29 -9
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/plan/core.py +4 -3
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/plan/provider/dev/fibonacci.py +6 -4
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/sglib/client_util.py +1 -1
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/sglib/utils.py +0 -1
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/util/duration.py +0 -1
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/util/pki_util.py +0 -1
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/util/query_util.py +3 -3
- {hcs_core-0.1.318 → hcs_core-0.1.320}/pyproject.toml +5 -10
- hcs_core-0.1.318/hcs_core/__init__.py +0 -1
- {hcs_core-0.1.318 → hcs_core-0.1.320}/.gitignore +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/__init__.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/built_in_cmds/__init__.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/built_in_cmds/_ut.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/built_in_cmds/context.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/built_in_cmds/profile.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/cmd_util.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/config.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/duration.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/extension.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/fn_util.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/jsondot.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/logger.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/profile_store.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/recent.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/state.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/template_util.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/timeutil.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/ctxp/var_template.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/plan/__init__.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/plan/actions.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/plan/base_provider.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/plan/context.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/plan/dag.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/plan/helper.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/plan/kop.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/plan/provider/__init__.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/plan/provider/dev/__init__.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/plan/provider/dev/_prepare.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/plan/provider/dev/dummy.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/sglib/__init__.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/sglib/auth.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/sglib/cli_options.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/sglib/csp.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/sglib/ez_client.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/sglib/hcs_client.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/sglib/init.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/sglib/login_support.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/sglib/payload_util.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/sglib/requtil.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/util/__init__.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/util/check_license.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/util/exit.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/util/hcs_constants.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/util/job_view.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/util/scheduler.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/util/ssl_util.py +0 -0
- {hcs_core-0.1.318 → hcs_core-0.1.320}/hcs_core/util/versions.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hcs-core
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.320
|
|
4
4
|
Summary: Horizon Cloud Service CLI module.
|
|
5
5
|
Project-URL: Homepage, https://github.com/euc-eng/hcs-cli
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/euc-eng/hcs-cli/issues
|
|
@@ -35,10 +35,9 @@ Requires-Dist: rich>=14.0.0
|
|
|
35
35
|
Requires-Dist: schedule>=1.1.0
|
|
36
36
|
Requires-Dist: tabulate>=0.9.0
|
|
37
37
|
Requires-Dist: websocket-client>=1.2.3
|
|
38
|
-
Requires-Dist: yumako>=0.1.
|
|
38
|
+
Requires-Dist: yumako>=0.1.37
|
|
39
39
|
Provides-Extra: dev
|
|
40
40
|
Requires-Dist: bandit; extra == 'dev'
|
|
41
|
-
Requires-Dist: black; extra == 'dev'
|
|
42
41
|
Requires-Dist: build; extra == 'dev'
|
|
43
42
|
Requires-Dist: flake8; extra == 'dev'
|
|
44
43
|
Requires-Dist: hatch; extra == 'dev'
|
|
@@ -47,8 +46,9 @@ Requires-Dist: pylint; extra == 'dev'
|
|
|
47
46
|
Requires-Dist: pytest; extra == 'dev'
|
|
48
47
|
Requires-Dist: ruff; extra == 'dev'
|
|
49
48
|
Requires-Dist: twine; extra == 'dev'
|
|
49
|
+
Requires-Dist: vulture; extra == 'dev'
|
|
50
50
|
Requires-Dist: wheel; extra == 'dev'
|
|
51
|
+
Requires-Dist: yamlfix; extra == 'dev'
|
|
51
52
|
Description-Content-Type: text/markdown
|
|
52
53
|
|
|
53
54
|
hcs-cli core component.
|
|
54
|
-
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.320"
|
|
@@ -20,6 +20,7 @@ from pathlib import Path
|
|
|
20
20
|
import click
|
|
21
21
|
|
|
22
22
|
from . import cli_processor, config, profile, state, telemetry
|
|
23
|
+
from .util import is_program_error
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
def _get_store_path():
|
|
@@ -55,7 +56,7 @@ def init(app_name: str, store_path: str = user_home, config_path: str = "./confi
|
|
|
55
56
|
|
|
56
57
|
except Exception as e:
|
|
57
58
|
# critical errors, must print stack trace.
|
|
58
|
-
if
|
|
59
|
+
if is_program_error(e):
|
|
59
60
|
raise e
|
|
60
61
|
else:
|
|
61
62
|
# Other errors, no stack.
|
|
@@ -86,26 +87,10 @@ def init_cli(main_cli: click.Group, commands_dir: str = "./cmds"):
|
|
|
86
87
|
return ret
|
|
87
88
|
except BaseException as e:
|
|
88
89
|
telemetry.end(error=e)
|
|
89
|
-
|
|
90
|
+
|
|
91
|
+
if is_program_error(e):
|
|
90
92
|
raise e
|
|
91
93
|
else:
|
|
92
94
|
from .util import panic
|
|
93
95
|
|
|
94
96
|
panic(e)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
def _need_stack_trace(e) -> bool:
|
|
98
|
-
program_errors = [
|
|
99
|
-
LookupError,
|
|
100
|
-
TypeError,
|
|
101
|
-
ValueError,
|
|
102
|
-
ArithmeticError,
|
|
103
|
-
NameError,
|
|
104
|
-
SyntaxError,
|
|
105
|
-
KeyError,
|
|
106
|
-
AttributeError,
|
|
107
|
-
]
|
|
108
|
-
for t in program_errors:
|
|
109
|
-
if isinstance(e, t):
|
|
110
|
-
return True
|
|
111
|
-
return False
|
|
@@ -76,7 +76,18 @@ sort = click.option(
|
|
|
76
76
|
help="Ascending/Descending. Format is property,{asc|desc} and default is ascending",
|
|
77
77
|
)
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
|
|
80
|
+
def limit(func=None, *, default=100):
|
|
81
|
+
decorator = click.option(
|
|
82
|
+
"--limit", "-l", type=int, required=False, default=default, help="Optionally, specify the number of records to fetch."
|
|
83
|
+
)
|
|
84
|
+
if func is not None:
|
|
85
|
+
# Called as @limit (without parentheses)
|
|
86
|
+
return decorator(func)
|
|
87
|
+
else:
|
|
88
|
+
# Called as @limit() or @limit(default=...)
|
|
89
|
+
return decorator
|
|
90
|
+
|
|
80
91
|
|
|
81
92
|
ids = click.option(
|
|
82
93
|
"--ids",
|
|
@@ -167,7 +167,6 @@ def _import_cmd_file(mod_path: Path, parent: click.core.Group):
|
|
|
167
167
|
|
|
168
168
|
# Create a new decorator that combines the individual decorators
|
|
169
169
|
def _default_io(cmd: click.Command):
|
|
170
|
-
|
|
171
170
|
from .cli_options import exclude_field, field, first, ids, output
|
|
172
171
|
|
|
173
172
|
cmd = output(cmd)
|
|
@@ -81,8 +81,7 @@ class Context:
|
|
|
81
81
|
self._store.save(key=self.name, data=self.data)
|
|
82
82
|
return False
|
|
83
83
|
|
|
84
|
-
def apply_variables(self, object:
|
|
85
|
-
|
|
84
|
+
def apply_variables(self, object: Any, additional_vars: dict = None):
|
|
86
85
|
mapping = self._data.copy()
|
|
87
86
|
if additional_vars:
|
|
88
87
|
mapping.update(additional_vars)
|
|
@@ -16,7 +16,6 @@ def load_data(file_name: str, class_type: str):
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
def load_data_file(file, default=None, format="auto"):
|
|
19
|
-
|
|
20
19
|
if isinstance(file, TextIOWrapper):
|
|
21
20
|
text = file.read(-1)
|
|
22
21
|
text = text.strip()
|
|
@@ -259,7 +258,6 @@ def process_variables(obj: dict, fn_get_var=None, use_env: bool = True):
|
|
|
259
258
|
fn_get_var = _fn_get_var
|
|
260
259
|
|
|
261
260
|
if use_env:
|
|
262
|
-
|
|
263
261
|
prev_fn_get_var = fn_get_var
|
|
264
262
|
|
|
265
263
|
def _fn_get_var_from_env(name: str):
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import logging
|
|
2
|
+
from typing import Callable
|
|
2
3
|
from weakref import WeakSet
|
|
3
4
|
|
|
4
5
|
log = logging.getLogger(__name__)
|
|
@@ -7,7 +8,7 @@ log = logging.getLogger(__name__)
|
|
|
7
8
|
class Dispatcher:
|
|
8
9
|
_registry: dict = {}
|
|
9
10
|
|
|
10
|
-
def register(self, key: str, fn:
|
|
11
|
+
def register(self, key: str, fn: Callable):
|
|
11
12
|
listeners = self._registry.get(key)
|
|
12
13
|
if not listeners:
|
|
13
14
|
listeners = WeakSet()
|
|
@@ -20,7 +21,7 @@ class Dispatcher:
|
|
|
20
21
|
self.register(k, v)
|
|
21
22
|
return self
|
|
22
23
|
|
|
23
|
-
def unregister(self, key: str, fn:
|
|
24
|
+
def unregister(self, key: str, fn: Callable):
|
|
24
25
|
listeners = self._registry.get(key)
|
|
25
26
|
if listeners:
|
|
26
27
|
listeners.remove(fn)
|
|
@@ -52,7 +53,7 @@ class StrictDispatcher:
|
|
|
52
53
|
self._impl = impl
|
|
53
54
|
self._events = events
|
|
54
55
|
|
|
55
|
-
def register(self, key: str, fn:
|
|
56
|
+
def register(self, key: str, fn: Callable):
|
|
56
57
|
self._validate(key)
|
|
57
58
|
self._impl.register(key, fn)
|
|
58
59
|
return self
|
|
@@ -62,7 +63,7 @@ class StrictDispatcher:
|
|
|
62
63
|
self.register(k, v)
|
|
63
64
|
return self
|
|
64
65
|
|
|
65
|
-
def unregister(self, key: str, fn:
|
|
66
|
+
def unregister(self, key: str, fn: Callable):
|
|
66
67
|
self._validate(key)
|
|
67
68
|
self._impl.unregister(key, fn)
|
|
68
69
|
return self
|
|
@@ -3,6 +3,7 @@ import threading
|
|
|
3
3
|
from copy import deepcopy
|
|
4
4
|
from dataclasses import dataclass
|
|
5
5
|
from time import sleep, time
|
|
6
|
+
from typing import Callable
|
|
6
7
|
|
|
7
8
|
import schedule
|
|
8
9
|
|
|
@@ -78,7 +79,7 @@ def _task_wrapper_once(fn_impl, kwargs):
|
|
|
78
79
|
return schedule.CancelJob
|
|
79
80
|
|
|
80
81
|
|
|
81
|
-
def submit(fn_task:
|
|
82
|
+
def submit(fn_task: Callable, initial_delay: str = None, repeat_interval: str = None, **kwargs):
|
|
82
83
|
if initial_delay:
|
|
83
84
|
initial_delay_seconds = duration.to_seconds(initial_delay)
|
|
84
85
|
else:
|
|
@@ -21,7 +21,7 @@ import subprocess
|
|
|
21
21
|
import sys
|
|
22
22
|
import traceback
|
|
23
23
|
import types
|
|
24
|
-
from typing import Any, Callable
|
|
24
|
+
from typing import Any, Callable, Union
|
|
25
25
|
|
|
26
26
|
import click
|
|
27
27
|
import httpx
|
|
@@ -34,7 +34,7 @@ class CtxpException(Exception):
|
|
|
34
34
|
pass
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
def error(reason:
|
|
37
|
+
def error(reason: Any, return_code: int = 1) -> tuple[CtxpException, int]:
|
|
38
38
|
# Shortcut if the reason is an Exception already
|
|
39
39
|
if isinstance(reason, Exception):
|
|
40
40
|
return reason, return_code
|
|
@@ -49,7 +49,7 @@ def error(reason: any, return_code: int = 1) -> tuple[CtxpException, int]:
|
|
|
49
49
|
return CtxpException(reason), return_code
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
def validate_error_return(reason, return_code):
|
|
52
|
+
def validate_error_return(reason: Any, return_code: int):
|
|
53
53
|
if return_code == 0:
|
|
54
54
|
raise CtxpException("Invalid return code. return_code must not be 0 (success) in error situation.")
|
|
55
55
|
if not isinstance(return_code, int):
|
|
@@ -128,12 +128,30 @@ def print_output(data: Any, args: dict, file=sys.stdout):
|
|
|
128
128
|
print(text, end="", file=file, flush=True)
|
|
129
129
|
|
|
130
130
|
|
|
131
|
+
def is_program_error(e: Exception) -> bool:
|
|
132
|
+
program_errors = [
|
|
133
|
+
ArithmeticError,
|
|
134
|
+
IndexError,
|
|
135
|
+
NameError,
|
|
136
|
+
SyntaxError,
|
|
137
|
+
LookupError,
|
|
138
|
+
KeyError,
|
|
139
|
+
TypeError,
|
|
140
|
+
AttributeError,
|
|
141
|
+
ValueError,
|
|
142
|
+
IndentationError,
|
|
143
|
+
ImportError,
|
|
144
|
+
AssertionError,
|
|
145
|
+
]
|
|
146
|
+
for ex in program_errors:
|
|
147
|
+
if isinstance(e, ex):
|
|
148
|
+
return True
|
|
149
|
+
return False
|
|
150
|
+
|
|
151
|
+
|
|
131
152
|
def print_error(error):
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if isinstance(error, ex):
|
|
135
|
-
traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)
|
|
136
|
-
break
|
|
153
|
+
if is_program_error(error):
|
|
154
|
+
traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)
|
|
137
155
|
msg = error_details(error)
|
|
138
156
|
print(msg, file=sys.stderr, flush=True)
|
|
139
157
|
|
|
@@ -391,7 +409,7 @@ def format_table(data: list, fields_mapping: dict, columns_to_sum: list = None):
|
|
|
391
409
|
return tabulate(table, headers=headers) + "\n"
|
|
392
410
|
|
|
393
411
|
|
|
394
|
-
def colorize(data: dict, name: str, mapping: dict):
|
|
412
|
+
def colorize(data: dict, name: str, mapping: Union[dict, str, Callable]):
|
|
395
413
|
if os.environ.get("TERM_COLOR") == "0":
|
|
396
414
|
return
|
|
397
415
|
|
|
@@ -413,6 +431,8 @@ def colorize(data: dict, name: str, mapping: dict):
|
|
|
413
431
|
c = mapping(s)
|
|
414
432
|
if c:
|
|
415
433
|
data[name] = click.style(s, fg=c)
|
|
434
|
+
elif isinstance(mapping, str):
|
|
435
|
+
data[name] = click.style(s, fg=mapping)
|
|
416
436
|
else:
|
|
417
437
|
raise Exception(f"Unexpected mapping type: {type(mapping)} {mapping}")
|
|
418
438
|
|
|
@@ -242,7 +242,8 @@ def _get_res_text(handler, res_state: dict) -> str:
|
|
|
242
242
|
def _deploy_res(name, res, state):
|
|
243
243
|
def fn_deploy1(handler, res_data: dict, res_state: dict, fn_set_state: typing.Callable, kop: KOP):
|
|
244
244
|
if _is_runtime(res):
|
|
245
|
-
|
|
245
|
+
eta = res.get("eta") or handler.eta(actions.create, res_data, state)
|
|
246
|
+
kop.start(KOP.MODE.create, eta)
|
|
246
247
|
new_state = handler.process(res_data, deepcopy(state))
|
|
247
248
|
if new_state:
|
|
248
249
|
fn_set_state(new_state)
|
|
@@ -266,7 +267,8 @@ def _deploy_res(name, res, state):
|
|
|
266
267
|
|
|
267
268
|
new_state = None
|
|
268
269
|
if action == actions.create or action is None:
|
|
269
|
-
|
|
270
|
+
eta = res.get("eta") or handler.eta(actions.create, res_data, state)
|
|
271
|
+
kop.start(KOP.MODE.create, eta)
|
|
270
272
|
if _has_save_state(handler.deploy):
|
|
271
273
|
|
|
272
274
|
def _hook_set_state(data):
|
|
@@ -415,7 +417,6 @@ def _handle_resource(name, res, state, for_deploy: bool, fn_process: typing.Call
|
|
|
415
417
|
|
|
416
418
|
kop_mode = KOP.MODE.create if for_deploy else KOP.MODE.delete
|
|
417
419
|
with KOP(state, kind, name, kop_mode) as kop:
|
|
418
|
-
|
|
419
420
|
conditions = res.get("conditions")
|
|
420
421
|
if conditions:
|
|
421
422
|
conditions = deepcopy(conditions)
|
|
@@ -13,13 +13,15 @@ See the License for the specific language governing permissions and
|
|
|
13
13
|
limitations under the License.
|
|
14
14
|
"""
|
|
15
15
|
|
|
16
|
+
from typing import Any, Optional
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
|
|
19
|
+
def process(data: dict, state: dict) -> Any:
|
|
18
20
|
n = data["n"]
|
|
19
21
|
return _fibonacci(n)
|
|
20
22
|
|
|
21
23
|
|
|
22
|
-
def _fibonacci(n: int):
|
|
24
|
+
def _fibonacci(n: int) -> int:
|
|
23
25
|
if n <= 0:
|
|
24
26
|
raise ValueError("n must be a positive integer.")
|
|
25
27
|
if n == 1:
|
|
@@ -33,9 +35,9 @@ def _fibonacci(n: int):
|
|
|
33
35
|
return curr
|
|
34
36
|
|
|
35
37
|
|
|
36
|
-
def destroy(data: dict, state: dict, force: bool) -> dict:
|
|
38
|
+
def destroy(data: dict, state: dict, force: bool) -> Optional[dict]:
|
|
37
39
|
return None
|
|
38
40
|
|
|
39
41
|
|
|
40
|
-
def eta(action: str, data: dict, state: dict):
|
|
42
|
+
def eta(action: str, data: dict, state: dict) -> str:
|
|
41
43
|
return "10s"
|
|
@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
|
|
|
13
13
|
limitations under the License.
|
|
14
14
|
"""
|
|
15
15
|
|
|
16
|
-
from typing import Any, Callable, Iterator, Tuple
|
|
16
|
+
from typing import Any, Callable, Iterator, Optional, Tuple
|
|
17
17
|
from urllib.parse import urlencode
|
|
18
18
|
|
|
19
19
|
|
|
@@ -38,7 +38,7 @@ def with_query(url: str, **kwargs: Any) -> str:
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
class PageRequest:
|
|
41
|
-
def __init__(self, fn_get_page: Callable, fn_filter: Callable = None, **kwargs):
|
|
41
|
+
def __init__(self, fn_get_page: Callable, fn_filter: Optional[Callable] = None, **kwargs):
|
|
42
42
|
limit = kwargs.get("limit")
|
|
43
43
|
if limit is None or limit == "":
|
|
44
44
|
limit = 10
|
|
@@ -52,7 +52,7 @@ class PageRequest:
|
|
|
52
52
|
self.query["size"] = 20
|
|
53
53
|
|
|
54
54
|
def get_page(self, page: int, size: int) -> list:
|
|
55
|
-
content, _ = self.
|
|
55
|
+
content, _ = self._get_page(page, size)
|
|
56
56
|
return content
|
|
57
57
|
|
|
58
58
|
def _get_page(self, page: int, size: int) -> Tuple[list, bool]:
|
|
@@ -42,7 +42,7 @@ dependencies = [
|
|
|
42
42
|
"websocket_client>=1.2.3",
|
|
43
43
|
"psutil>=7.0.0",
|
|
44
44
|
"schedule>=1.1.0",
|
|
45
|
-
"yumako>=0.1.
|
|
45
|
+
"yumako>=0.1.37",
|
|
46
46
|
"pydantic>=2.11.7",
|
|
47
47
|
"python-dotenv>=1.1.1",
|
|
48
48
|
]
|
|
@@ -50,7 +50,6 @@ dependencies = [
|
|
|
50
50
|
[project.optional-dependencies]
|
|
51
51
|
dev = [
|
|
52
52
|
"build",
|
|
53
|
-
"black",
|
|
54
53
|
"mypy",
|
|
55
54
|
"bandit",
|
|
56
55
|
"wheel",
|
|
@@ -60,6 +59,8 @@ dev = [
|
|
|
60
59
|
"ruff",
|
|
61
60
|
"flake8",
|
|
62
61
|
"hatch",
|
|
62
|
+
"vulture",
|
|
63
|
+
"yamlfix",
|
|
63
64
|
]
|
|
64
65
|
|
|
65
66
|
[project.urls]
|
|
@@ -79,15 +80,9 @@ exclude = [
|
|
|
79
80
|
"tests/**",
|
|
80
81
|
]
|
|
81
82
|
|
|
82
|
-
[tool.
|
|
83
|
+
[tool.ruff]
|
|
83
84
|
line-length = 140
|
|
84
|
-
target-version =
|
|
85
|
-
include = '\.pyi?$'
|
|
86
|
-
extend-exclude = '''
|
|
87
|
-
# A regex preceded with ^/ will apply only to files and directories
|
|
88
|
-
# in the root of the project.
|
|
89
|
-
^/foo.py # exclude a file named foo.py in the root of the project (in addition to the defaults)
|
|
90
|
-
'''
|
|
85
|
+
target-version = "py39"
|
|
91
86
|
|
|
92
87
|
[tool.hatch.version]
|
|
93
88
|
path = "hcs_core/__init__.py"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.318"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|