Skip to content

Commit

Permalink
style(pre-commit): fixing precommit warnings (#126)
Browse files Browse the repository at this point in the history
* style(pre-commit): fixing precommit warnings

* ci(ci.yml): removing types

* fix(renderers.py): fix precommit errors
  • Loading branch information
odarotto committed Sep 12, 2024
1 parent e3a269c commit 5105486
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ on:
pull_request:
branches:
- "**"
types:
- ready_for_review
- synchronize
# types:
# - ready_for_review
# - synchronize

jobs:
pre-commit:
Expand Down
18 changes: 10 additions & 8 deletions workflow/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,19 @@ def run(
)
else:
# Missing Logging config in Workspace
config.update({
"logging": {
"loki": {
"tags": {
# Assumes that there is only one bucket
"pipeline": buckets[0],
"site": site,
config.update(
{
"logging": {
"loki": {
"tags": {
# Assumes that there is only one bucket
"pipeline": buckets[0],
"site": site,
}
}
}
}
})
)
loki_status: bool = configure.loki(logger=logger, config=config)
logger.info(f"Loki Logs: {'✅' if loki_status else '❌'}")
http: HTTPContext = HTTPContext(backends=["buckets"])
Expand Down
2 changes: 1 addition & 1 deletion workflow/http/buckets.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def delete_many(
tags: Optional[List[str]] = None,
parent: Optional[str] = None,
force: bool = False,
limit: Optional[int] = 100
limit: Optional[int] = 100,
) -> bool:
"""Delete works belonging to a pipeline from the buckets backend.
Expand Down
1 change: 0 additions & 1 deletion workflow/http/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ def info(self) -> Dict[str, Any]:
server_info = response.json()
return {"client": client_info, "server": server_info}


@retry(
reraise=True, wait=wait_random(min=0.3, max=1.8), stop=(stop_after_delay(15))
)
Expand Down
6 changes: 4 additions & 2 deletions workflow/lifecycle/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ def defaults(func: Callable[..., Any], work: Work) -> Work:

if hasattr(parameter, "is_flag") and parameter.is_flag:
if parameter_default_value is True:
# Flags aren't assigned values, its CLI name is just included or not included
# Flags aren't assigned values
# its CLI name is just included or not included
options[name_in_cli] = None
else:
options[name_in_cli] = parameter_default_value
Expand All @@ -151,7 +152,8 @@ def defaults(func: Callable[..., Any], work: Work) -> Work:

if hasattr(parameter, "is_flag") and parameter.is_flag:
if parameter_given_value is True:
# Flags aren't assigned values, its CLI name is just included or not included
# Flags aren't assigned values
# its CLI name is just included or not included
options[name_in_cli] = None
else:
options[name_in_cli] = parameter_given_value
Expand Down
28 changes: 21 additions & 7 deletions workflow/utils/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,22 @@
from workflow.utils.variables import status_colors, status_symbols


def render_timestamp(timestamp: float):
timestamp = dt.datetime.fromtimestamp(timestamp)
timestamp = dt.datetime.strftime(timestamp, "%m-%d-%Y, %H:%M:%S")
return timestamp
def render_timestamp(timestamp: float) -> str:
"""Converts a timestamp into a readable string.
Parameters
----------
timestamp : float
Timestamp.
Returns
-------
str
Formatted timestamp.
"""
from_dt: dt.datetime = dt.datetime.fromtimestamp(timestamp)
formatted_dt: str = dt.datetime.strftime(from_dt, "%m-%d-%Y, %H:%M:%S")
return formatted_dt


def render_pipeline(payload: Dict[str, Any], history: bool = False) -> Text:
Expand All @@ -24,6 +36,8 @@ def render_pipeline(payload: Dict[str, Any], history: bool = False) -> Text:
----------
payload : Dict[str, Any]
Pipeline payload.
history : bool
If history field needs to be rendered.
Returns
-------
Expand All @@ -41,7 +55,7 @@ def render_pipeline(payload: Dict[str, Any], history: bool = False) -> Text:
continue
key_value_text = Text()
if k in time_fields and v:
v = render_timestamp(v)
v = render_timestamp(float(v))
if k == steps_field:
key_value_text = Text(f"{k}: \n", style="bright_blue")
for step in v:
Expand All @@ -50,7 +64,7 @@ def render_pipeline(payload: Dict[str, Any], history: bool = False) -> Text:
elif k == history_field:
key_value_text = Text(f"{k}: \n", style="bright_blue")
for timestamp in v.keys():
rendered = render_timestamp(int(timestamp))
rendered = render_timestamp(float(timestamp))
key_value_text.append(f" {rendered}:\n", style="bright_green")
for execution in v[timestamp].keys():
key_value_text.append(f"{' ' * 4}{execution}:\n")
Expand Down Expand Up @@ -96,7 +110,7 @@ def render_config(http: HTTPContext, payload: Dict[str, Any]) -> Text:
continue
key_value_text = Text()
if k in time_fields and v:
v = render_timestamp(v)
v = render_timestamp(float(v))
if k == "pipelines":
key_value_text.append(f"{k}: \n", style="bright_blue")
for status in pipelines_statuses:
Expand Down

0 comments on commit 5105486

Please sign in to comment.