-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #276 from chkware/feat/module-workflow
Feature: Workflow module implementation
- Loading branch information
Showing
67 changed files
with
3,640 additions
and
1,599 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
""" | ||
Console service module | ||
""" | ||
|
||
from typing import Any | ||
|
||
import click | ||
|
||
from chk.infrastructure.file_loader import FileLoader | ||
from chk.infrastructure.logging import LoggingManager | ||
from chk.infrastructure.typing_extras import JsonDecodingError | ||
|
||
|
||
def load_variables_as_dict(json_str: str, **kwargs: Any) -> dict: | ||
"""Reads a json string and converts and returns the dict while doing validation""" | ||
|
||
if json_str: | ||
try: | ||
return FileLoader.load_json_from_str(json_str) | ||
except JsonDecodingError as err: | ||
message = kwargs.get("except_msg") or "JSON loading error." | ||
raise click.UsageError(str(message)) from err | ||
|
||
return {} | ||
|
||
|
||
def combine_initial_variables(external_vars: str, **kwargs: Any) -> dict: | ||
"""Reads a json string and converts to dict, and combines with env and dotenv | ||
variables""" | ||
|
||
return load_variables_as_dict(external_vars, **kwargs) | ||
|
||
|
||
def after_hook(*args: list, **kwargs: dict) -> Any: | ||
"""Run any function after implementation. Default pass""" | ||
|
||
|
||
def setup_logger(should_log: bool) -> None: | ||
"""setup_logger""" | ||
|
||
LoggingManager.remove_loguru() | ||
|
||
if should_log: | ||
log_file = LoggingManager.create_new_log_file() | ||
LoggingManager.setup_loguru(log_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.