diff --git a/.vscode/settings.json b/.vscode/settings.json index c117f5b..f4fac29 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,7 +16,10 @@ }, "editor.formatOnSave": true, "[python]": { - "editor.formatOnPaste": false, + "editor.codeActionsOnSave": { + "source.organizeImports": "always", + "source.fixAll": "always" + }, "editor.defaultFormatter": "charliermarsh.ruff" }, "python.languageServer": "Pylance", diff --git a/locust_swarm/swarm.py b/locust_swarm/swarm.py index f080125..a99e24b 100644 --- a/locust_swarm/swarm.py +++ b/locust_swarm/swarm.py @@ -7,17 +7,18 @@ import atexit import logging import os -import subprocess import signal +import socket +import subprocess import sys import time -import socket from datetime import datetime, timezone -import psutil + import configargparse import locust.util.timespan -from locust_swarm._version import version +import psutil +from locust_swarm._version import version logging.basicConfig( format="%(asctime)s,%(msecs)d %(levelname)-4s [%(filename)s:%(lineno)d] %(message)s", @@ -40,7 +41,7 @@ Example: swarm -f test.py --loadgen-list loadgen1.domain.com,loadgen2.domain.com --users 50""", epilog="""Any parameters not listed here are forwarded to locust master unmodified, so go ahead and use things like --users, --host, --run-time, ... - + Swarm config can also be set using config file (~/.locust.conf, locust.conf, ~/.swarm.conf or swarm.conf). Parameters specified on command line override env vars, which in turn override config files.""", add_config_file_help=False, @@ -317,7 +318,7 @@ def start_worker_process(server, port): "-R", f"{port}:localhost:{port}", "-R", - f"{port+1}:localhost:{port+1}", + f"{port + 1}:localhost:{port + 1}", ] ensure_remote_kill = ["& read; kill -9 $!"] nohup = [] @@ -335,31 +336,29 @@ def start_worker_process(server, port): if args.test_env: extra_env.append("LOCUST_TEST_ENV=" + args.test_env) - cmd = " ".join( - [ - "ssh", - "-q", - *port_forwarding_parameters, - server, - "'", - *extra_env, - *nohup, - "locust", - "--worker", - "--processes", - str(args.processes), - "--master-port", - str(port), - *master_parameters, - "--headless", - "--expect-workers-max-wait", - "30", - "-f", - "-", - *ensure_remote_kill, - "'", - ] - ) + cmd = " ".join([ + "ssh", + "-q", + *port_forwarding_parameters, + server, + "'", + *extra_env, + *nohup, + "locust", + "--worker", + "--processes", + str(args.processes), + "--master-port", + str(port), + *master_parameters, + "--headless", + "--expect-workers-max-wait", + "30", + "-f", + "-", + *ensure_remote_kill, + "'", + ]) logging.info("workers started " + cmd) procs.append( diff --git a/pyproject.toml b/pyproject.toml index eac7585..27ec108 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,8 @@ [tool.ruff] line-length = 120 - -extend-select = [ +lint.select = ["E", "F", "W", "UP", "FA102", "I"] +lint.extend-select = [ "D419", # empty-docstring - # "E501", # line-too-long "W291", # trailing-whitespace "PLC0414", # useless-import-alias "PLC2401", # non-ascii-name @@ -20,11 +19,14 @@ extend-select = [ "PLE0605", # invalid-all-format "PLE0704", # misplaced-bare-raise ] - -ignore = [ +lint.ignore = [ "PLR0912", # too-many-branches "PLR0913", # too-many-arguments "PLR0914", # too-many-locals "PLR0915", # too-many-statements "PLW0603", # global-statement + "E501", # line-too-long ] + +[tool.mypy] +ignore_missing_imports = true \ No newline at end of file diff --git a/setup.py b/setup.py index fc18752..a5c1910 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,11 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- import os import sys + from setuptools import find_packages, setup -from setuptools.command.install import install -from setuptools.command.egg_info import egg_info from setuptools.command.develop import develop +from setuptools.command.egg_info import egg_info +from setuptools.command.install import install def install_check(self, command): diff --git a/tox.ini b/tox.ini index ff6e744..f04b977 100644 --- a/tox.ini +++ b/tox.ini @@ -3,8 +3,10 @@ envlist = py{38,39,310,311,312} [testenv] deps = - ruff + ruff==0.2.2 + mypy==1.8.0 commands = ruff check --preview - ruff format --check + ruff format --preview --check + mypy . swarm --help