Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pre-commit hooks #406

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
exclude: '^docs/'
repos:
- repo: https://github.com/psf/black
rev: 22.6.0
rev: 23.1.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies:
Expand Down
1 change: 0 additions & 1 deletion ansible_rulebook/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ async def put(self, _data):

# FIXME(cutwater): Replace parsed_args with clear interface
async def run(parsed_args: argparse.ArgumentParser) -> None:

if parsed_args.worker and parsed_args.websocket_address and parsed_args.id:
logger.info("Starting worker mode")

Expand Down
6 changes: 0 additions & 6 deletions ansible_rulebook/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ async def run_playbook(
extra_vars: Optional[Dict] = None,
**kwargs,
):

logger.info("running Ansible playbook: %s", name)
temp_dir, playbook_name = await pre_process_runner(
event_log,
Expand Down Expand Up @@ -435,7 +434,6 @@ async def call_runner(
verbosity: int = 0,
json_mode: Optional[bool] = False,
):

host_limit = ",".join(hosts)
shutdown = False

Expand Down Expand Up @@ -503,7 +501,6 @@ def cancel_callback():


async def untar_project(output_dir, project_data_file):

cmd = [tar, "zxvf", project_data_file]
proc = await asyncio.create_subprocess_exec(
*cmd,
Expand Down Expand Up @@ -534,7 +531,6 @@ async def pre_process_runner(
extra_vars: Optional[Dict] = None,
**kwargs,
):

private_data_dir = tempfile.mkdtemp(prefix=action)
logger.debug("private data dir %s", private_data_dir)

Expand Down Expand Up @@ -600,7 +596,6 @@ async def post_process_runner(
set_facts: Optional[bool] = None,
post_events: Optional[bool] = None,
):

rc = int(_get_latest_artifact(private_data_dir, "rc"))
status = _get_latest_artifact(private_data_dir, "status")
logger.info("Playbook rc: %d, status: %s", rc, status)
Expand Down Expand Up @@ -662,7 +657,6 @@ async def run_job_template(
delay: Optional[int] = 0,
**kwargs,
):

logger.info(
"running job template: %s, organization: %s", name, organization
)
Expand Down
2 changes: 0 additions & 2 deletions ansible_rulebook/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ async def start_source(
queue: asyncio.Queue,
shutdown_delay: float = 60.0,
) -> None:

all_source_queues.append(queue)
try:
logger.info("load source")
Expand Down Expand Up @@ -189,7 +188,6 @@ async def run_rulesets(
parsed_args: argparse.ArgumentParser = None,
project_data_file: Optional[str] = None,
):

logger.info("run_ruleset")
rulesets_queue_plans = rule_generator.generate_rulesets(
ruleset_queues, variables, inventory
Expand Down
14 changes: 0 additions & 14 deletions ansible_rulebook/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,72 +24,58 @@ def __str__(self):


class RulenameEmptyException(Exception):

pass


class RulesetNameDuplicateException(Exception):

pass


class RulesetNameEmptyException(Exception):

pass


class RulenameDuplicateException(Exception):

pass


class ControllerApiException(Exception):

pass


class VarsKeyMissingException(Exception):

pass


class InvalidAssignmentException(Exception):

pass


class SelectattrOperatorException(Exception):

pass


class InvalidIdentifierException(Exception):

pass


class SelectOperatorException(Exception):

pass


class ConditionParsingException(Exception):

pass


class InvalidTypeException(Exception):

pass


class PlaybookStatusNotFoundException(Exception):

pass


class PlaybookNotFoundException(Exception):

pass


Expand Down
1 change: 0 additions & 1 deletion ansible_rulebook/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@


async def install_private_key(private_key):

"""
Install a private key into the ssh-agent.
"""
Expand Down
1 change: 0 additions & 1 deletion ansible_rulebook/rule_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def generate_rulesets(
variables: Dict,
inventory: str,
) -> List[EngineRuleSetQueuePlan]:

rulesets = []

for ansible_ruleset, source_queue in ruleset_queues:
Expand Down
1 change: 0 additions & 1 deletion ansible_rulebook/rule_set_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ async def _call_action(
hosts: List,
rules_engine_result,
) -> None:

logger.info("call_action %s", action)

result = None
Expand Down
1 change: 0 additions & 1 deletion ansible_rulebook/rule_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@


class EventSourceFilter(NamedTuple):

filter_name: str
filter_args: dict

Expand Down
1 change: 0 additions & 1 deletion ansible_rulebook/rules_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def parse_event_sources(sources: Dict) -> List[rt.EventSource]:


def parse_source_filter(source_filter: Dict) -> rt.EventSourceFilter:

source_filter_name = list(source_filter.keys())[0]
source_filter_args = source_filter[source_filter_name]

Expand Down
1 change: 0 additions & 1 deletion ansible_rulebook/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def substitute_variables(


def load_inventory(inventory_file: str) -> Any:

with open(inventory_file) as f:
inventory_data = f.read()
return inventory_data
Expand Down
13 changes: 7 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = Apache-2.0
keywords = ansible_rulebook
long_description = file: README.rst, HISTORY.rst
long_description_content_type = text/x-rst; charset=UTF-8
classifiers =
classifiers =
Development Status :: 2 - Pre-Alpha
Intended Audience :: Developers
License :: OSI Approved :: Apache Software License
Expand All @@ -23,7 +23,7 @@ zip_safe = False
include_package_data = True
packages = find:
python_requires = >=3.8
install_requires =
install_requires =
aiohttp
pyparsing >= 3.0
jsonschema
Expand All @@ -35,12 +35,12 @@ install_requires =
drools_jpy == 0.2.5

[options.packages.find]
include =
include =
ansible_rulebook
ansible_rulebook.*

[options.entry_points]
console_scripts =
console_scripts =
ansible-rulebook = ansible_rulebook.cli:main

[bumpversion:file:setup.cfg]
Expand All @@ -53,5 +53,6 @@ replace = __version__ = '{new_version}'

[flake8]
extend-exclude = docs, venv, .venv
extend-ignore =
E203, # Whitespace before ':' (false positive in slices, handled by black.
extend-ignore =
# Whitespace before ':' (false positive in slices, handled by black.
E203,
1 change: 0 additions & 1 deletion tests/sources/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def send_facts(queue, filename):


def main(queue, args):

files = [os.path.abspath(f) for f in args.get("files", [])]

if not files:
Expand Down
1 change: 0 additions & 1 deletion tests/sources/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@


async def main(queue: asyncio.Queue, args: Dict[str, Any]):

for i in range(int(args["limit"])):
await queue.put(dict(i=i, meta=dict(hosts="localhost")))

Expand Down
1 change: 0 additions & 1 deletion tests/sources/log_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@


def main(queue, args):

log_file_patterns = {
os.path.abspath(log_file): patterns
for log_file, patterns in args.get("log_file_patterns", {}).items()
Expand Down
3 changes: 0 additions & 3 deletions tests/sources/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@


def main(queue, args):

ips = args.get("ips", [])
delay = args.get("delay", 1)
timeout = str(args.get("timeout", 10))
Expand All @@ -26,9 +25,7 @@ def main(queue, args):
return

while True:

for ip in ips:

result = subprocess.call(["ping", "-c", "1", "-t", timeout, ip])
queue.put(
dict(ping=dict(ip=ip, timeout=result != 0, exit_code=result))
Expand Down
1 change: 0 additions & 1 deletion tests/sources/process_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@


def main(queue, args):

names = args.get("names", None)

original_processes = {p.pid: p.name() for p in psutil.process_iter()}
Expand Down
1 change: 0 additions & 1 deletion tests/sources/tick.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@


def main(queue, args):

for i in itertools.count(start=1):
queue.put(dict(time=dict(tick=i)))
time.sleep(1)
Expand Down
1 change: 0 additions & 1 deletion tests/sources/timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@


def main(queue, args):

while True:
queue.put(
dict(
Expand Down
2 changes: 0 additions & 2 deletions tests/sources/url_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@


def main(queue, args):

urls = args.get("urls", [])
delay = args.get("delay", 1)

if not urls:
return

while True:

for url in urls:
try:
response = requests.get(url, timeout=10, verify=False)
Expand Down
1 change: 0 additions & 1 deletion tests/test_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,6 @@ def test_null_type():
],
)
def test_generate_dict_ruleset(rulebook):

os.chdir(HERE)
with open(os.path.join("rules", rulebook)) as f:
data = yaml.safe_load(f.read())
Expand Down
1 change: 0 additions & 1 deletion tests/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ async def test_start_source():

@pytest.mark.asyncio
async def test_run_rulesets():

ruleset_queues, event_log = load_rulebook("rules/test_rules.yml")

queue = ruleset_queues[0][1]
Expand Down