Skip to content

Commit

Permalink
Merge pull request #17 from SvenskaSpel/sort-imports-and-check-format…
Browse files Browse the repository at this point in the history
…ting

Sort imports and check formatting
  • Loading branch information
cyberw authored Feb 20, 2024
2 parents c93aad9 + 234eb36 commit d74ccea
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 42 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
61 changes: 30 additions & 31 deletions locust_swarm/swarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand Down Expand Up @@ -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 = []
Expand All @@ -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(
Expand Down
12 changes: 7 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d74ccea

Please sign in to comment.