Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
luismedel committed Dec 7, 2024
1 parent 77ad8ed commit e4f74c2
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 62 deletions.
16 changes: 6 additions & 10 deletions src/bluish/actions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import bluish.nodes.step
import bluish.process
from bluish.nodes import Definition, log_dict
from bluish.logging import debug
from bluish.nodes import Definition, log_dict
from bluish.schemas import Validator


Expand All @@ -19,23 +19,19 @@ class Action:
INPUTS_SCHEMA: Validator | None = None
SENSITIVE_INPUTS: Sequence[str] = tuple()

def run(
self, step: bluish.nodes.step.Step
) -> bluish.process.ProcessResult:
def run(self, step: bluish.nodes.step.Step) -> bluish.process.ProcessResult:
raise NotImplementedError()

def execute(
self, step: bluish.nodes.step.Step
) -> bluish.process.ProcessResult:
def execute(self, step: bluish.nodes.step.Step) -> bluish.process.ProcessResult:
if self.SCHEMA:
self.SCHEMA.validate(step.attrs.as_dict())
if self.INPUTS_SCHEMA and step.attrs._with:
self.INPUTS_SCHEMA.validate(step.attrs._with)
if self.INPUTS_SCHEMA and step.inputs:
self.INPUTS_SCHEMA.validate(step.inputs)

step.sensitive_inputs.update(self.SENSITIVE_INPUTS)

log_dict(
step.attrs._with,
step.inputs,
header="with",
ctx=step,
sensitive_keys=self.SENSITIVE_INPUTS,
Expand Down
16 changes: 4 additions & 12 deletions src/bluish/actions/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ class RunCommand(bluish.actions.base.Action):
}
)

def run(
self, step: bluish.nodes.step.Step
) -> bluish.process.ProcessResult:
def run(self, step: bluish.nodes.step.Step) -> bluish.process.ProcessResult:
env = ChainMap(step.env, step.parent.env, step.parent.parent.env) # type: ignore

bluish.nodes.log_dict(
Expand Down Expand Up @@ -57,9 +55,7 @@ class ExpandTemplate(bluish.actions.base.Action):
}
)

def run(
self, step: bluish.nodes.step.Step
) -> bluish.process.ProcessResult:
def run(self, step: bluish.nodes.step.Step) -> bluish.process.ProcessResult:
inputs = step.inputs

job = cast(bluish.nodes.job.Job, step.parent)
Expand Down Expand Up @@ -99,9 +95,7 @@ class UploadFile(bluish.actions.base.Action):
}
)

def run(
self, step: bluish.nodes.step.Step
) -> bluish.process.ProcessResult:
def run(self, step: bluish.nodes.step.Step) -> bluish.process.ProcessResult:
inputs = step.inputs

contents: str
Expand Down Expand Up @@ -149,9 +143,7 @@ class DownloadFile(bluish.actions.base.Action):
}
)

def run(
self, step: bluish.nodes.step.Step
) -> bluish.process.ProcessResult:
def run(self, step: bluish.nodes.step.Step) -> bluish.process.ProcessResult:
inputs = step.inputs

source_file = inputs["source_file"]
Expand Down
32 changes: 8 additions & 24 deletions src/bluish/actions/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ class Login(bluish.actions.base.Action):

SENSITIVE_INPUTS: tuple[str, ...] = ("password",)

def run(
self, step: bluish.nodes.step.Step
) -> bluish.process.ProcessResult:
def run(self, step: bluish.nodes.step.Step) -> bluish.process.ProcessResult:
inputs = step.inputs

username = inputs["username"]
Expand All @@ -89,9 +87,7 @@ def run(
class Logout(bluish.actions.base.Action):
FQN: str = "docker/logout"

def run(
self, step: bluish.nodes.step.Step
) -> bluish.process.ProcessResult:
def run(self, step: bluish.nodes.step.Step) -> bluish.process.ProcessResult:
command = "docker logout"
if step.get_inherited_attr("echo_commands", True):
info("Logging out of Docker...")
Expand All @@ -110,9 +106,7 @@ class Build(bluish.actions.base.Action):
}
)

def run(
self, step: bluish.nodes.step.Step
) -> bluish.process.ProcessResult:
def run(self, step: bluish.nodes.step.Step) -> bluish.process.ProcessResult:
inputs = step.inputs

dockerfile = inputs.get("dockerfile", "Dockerfile")
Expand Down Expand Up @@ -141,9 +135,7 @@ class GetPid(bluish.actions.base.Action):
}
)

def run(
self, step: bluish.nodes.step.Step
) -> bluish.process.ProcessResult:
def run(self, step: bluish.nodes.step.Step) -> bluish.process.ProcessResult:
name = step.inputs["name"]

ps_result = docker_ps(step, name=name)
Expand Down Expand Up @@ -184,9 +176,7 @@ class Run(bluish.actions.base.Action):
}
)

def run(
self, step: bluish.nodes.step.Step
) -> bluish.process.ProcessResult:
def run(self, step: bluish.nodes.step.Step) -> bluish.process.ProcessResult:
inputs = step.inputs

image = inputs["image"]
Expand Down Expand Up @@ -253,9 +243,7 @@ class Stop(bluish.actions.base.Action):
}
)

def run(
self, step: bluish.nodes.step.Step
) -> bluish.process.ProcessResult:
def run(self, step: bluish.nodes.step.Step) -> bluish.process.ProcessResult:
inputs = step.inputs

name = inputs.get("name")
Expand Down Expand Up @@ -333,9 +321,7 @@ class Exec(bluish.actions.base.Action):
}
)

def run(
self, step: bluish.nodes.step.Step
) -> bluish.process.ProcessResult:
def run(self, step: bluish.nodes.step.Step) -> bluish.process.ProcessResult:
inputs = step.inputs

name = inputs.get("name")
Expand Down Expand Up @@ -416,9 +402,7 @@ class CreateNetwork(bluish.actions.base.Action):
}
)

def run(
self, step: bluish.nodes.step.Step
) -> bluish.process.ProcessResult:
def run(self, step: bluish.nodes.step.Step) -> bluish.process.ProcessResult:
inputs = step.inputs

name = inputs["name"]
Expand Down
8 changes: 2 additions & 6 deletions src/bluish/actions/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ def run_git_command(
return job.exec(f"{preamble} {command}", step)


def prepare_environment(
step: bluish.nodes.step.Step
) -> bluish.process.ProcessResult:
def prepare_environment(step: bluish.nodes.step.Step) -> bluish.process.ProcessResult:
REQUIRED = {
"git": "git",
"openssh-client": "ssh",
Expand Down Expand Up @@ -69,9 +67,7 @@ class Checkout(bluish.actions.base.Action):
def fqn(self) -> str:
return "git/checkout"

def run(
self, step: bluish.nodes.step.Step
) -> bluish.process.ProcessResult:
def run(self, step: bluish.nodes.step.Step) -> bluish.process.ProcessResult:
try:
inputs = step.inputs

Expand Down
4 changes: 1 addition & 3 deletions src/bluish/actions/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ class InstallPackages(bluish.actions.base.Action):
}
)

def run(
self, step: bluish.nodes.step.Step
) -> bluish.process.ProcessResult:
def run(self, step: bluish.nodes.step.Step) -> bluish.process.ProcessResult:
package_str = " ".join(step.inputs["packages"])
flavor = step.inputs.get("flavor", "auto")

Expand Down
6 changes: 3 additions & 3 deletions src/bluish/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
from flask import Flask, abort, jsonify, request

from bluish.__main__ import PROJECT_VERSION
from bluish.nodes import WorkflowDefinition
from bluish.nodes.job import Job
from bluish.nodes.workflow import Workflow
from bluish.core import (
init_commands,
)
from bluish.nodes import WorkflowDefinition
from bluish.nodes.job import Job
from bluish.nodes.workflow import Workflow


class LogFormatter(logging.Formatter):
Expand Down
2 changes: 1 addition & 1 deletion src/bluish/nodes/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from typing import Any
from uuid import uuid4

import bluish.nodes
import bluish.core
import bluish.nodes
import bluish.process
from bluish.logging import debug, error, info, warning
from bluish.utils import decorate_for_log
Expand Down
2 changes: 1 addition & 1 deletion src/bluish/nodes/step.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import bluish.actions
import bluish.nodes as nodes
import bluish.core
import bluish.nodes as nodes
import bluish.process
from bluish.logging import info

Expand Down
2 changes: 1 addition & 1 deletion src/bluish/nodes/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

from dotenv import dotenv_values

import bluish.core
import bluish.nodes
import bluish.nodes.job
import bluish.core
import bluish.process
from bluish.logging import debug, error, info

Expand Down
2 changes: 1 addition & 1 deletion test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from test.utils import create_workflow

import pytest
from bluish.nodes import CircularDependencyError
from bluish.core import (
ExecutionStatus,
init_commands,
)
from bluish.nodes import CircularDependencyError
from bluish.process import run
from bluish.schemas import RequiredAttributeError

Expand Down

0 comments on commit e4f74c2

Please sign in to comment.