Skip to content

Commit

Permalink
[fix] fix venv_dev and multiprocess lib usage
Browse files Browse the repository at this point in the history
Many functions and members of `multiprocess` lib are exposed
dynamically. For this reason pylint is not able to tell what
members this lib has (e.g. `multiprocess.Value()`. So these
pylint reports have been suppressed.

Another purpose of this commit is to make "superset" relationship
for venv_dev: if a CodeChecker developer installs venv_dev, then
the content of venv should always be installed. venv_dev just
extends them. `multiprocess` was a counterexample for this relationship:
it was installed only by `venv` and not `venv_dev`. Such a
mistake in the organization of requirements.txt files results
missing libraries for developers.
  • Loading branch information
bruntib committed Nov 24, 2023
1 parent 83e8b6f commit d3466b8
Show file tree
Hide file tree
Showing 28 changed files with 39 additions and 67 deletions.
1 change: 1 addition & 0 deletions analyzer/codechecker_analyzer/analysis_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ def start_workers(actions_map, actions, analyzer_config_map,
Start the workers in the process pool.
For every build action there is worker which makes the analysis.
"""
# pylint: disable=no-member multiprocess module members.

# Handle SIGINT to stop this script running.
def signal_handler(signum, frame):
Expand Down
1 change: 1 addition & 0 deletions analyzer/codechecker_analyzer/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def perform_analysis(args, skip_handlers, actions, metadata_tool,
in the given analysis context for the supplied build actions.
Additionally, insert statistical information into the metadata dict.
"""
# pylint: disable=no-member multiprocess module members.

context = analyzer_context.get_context()

Expand Down
1 change: 1 addition & 0 deletions analyzer/codechecker_analyzer/cmd/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def add_arguments_to_parser(parser):
type=int,
dest="jobs",
required=False,
# pylint: disable=no-member
default=multiprocess.cpu_count(),
help="Number of threads to use in analysis. More "
"threads mean faster analysis at the cost of "
Expand Down
1 change: 1 addition & 0 deletions analyzer/codechecker_analyzer/cmd/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def add_arguments_to_parser(parser):
type=int,
dest="jobs",
required=False,
# pylint: disable=no-member
default=multiprocess.cpu_count(),
help="Number of threads to use in analysis. "
"More threads mean faster analysis at "
Expand Down
1 change: 1 addition & 0 deletions analyzer/codechecker_analyzer/pre_analysis_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def run_pre_analysis(actions, clangsa_config,
"""
Run multiple pre analysis jobs before the actual analysis.
"""
# pylint: disable=no-member multiprocess module members.
LOG.info('Pre-analysis started.')
if ctu_data:
LOG.info("Collecting data for ctu analysis.")
Expand Down
2 changes: 1 addition & 1 deletion analyzer/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ lxml==4.9.2
portalocker==2.2.1
psutil==5.8.0
PyYAML==6.0.1
types-PyYAML==6.0.12.12
sarif-tools==1.0.0
mypy_extensions==0.4.3
multiprocess==0.70.15
8 changes: 2 additions & 6 deletions analyzer/requirements_py/dev/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
lxml==4.9.2
pytest==7.3.1
pycodestyle==2.7.0
psutil==5.8.0
portalocker==2.2.1
pylint==2.8.2
mkdocs==1.5.3
PyYAML==6.0.1
mypy_extensions==0.4.3
coverage==5.5.0
sarif-tools==1.0.0

-r ../../requirements.txt
7 changes: 2 additions & 5 deletions analyzer/requirements_py/osx/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
lxml==4.9.2
portalocker==2.2.1
psutil==5.8.0
scan-build==2.0.19
PyYAML==6.0.1
mypy_extensions==0.4.3

-r ../../requirements.txt
4 changes: 2 additions & 2 deletions codechecker_common/requirements_py/dev/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
portalocker==2.2.1
coverage==5.5.0
mypy==0.812
mypy_extensions==0.4.3
mypy==1.7.1
PyYAML==6.0.1
types-PyYAML==6.0.12.12
14 changes: 0 additions & 14 deletions codechecker_common/skiplist_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,6 @@ def should_skip(self, source):
return sign == '-'
return False

def __call__(self, source_file_path: str) -> bool:
"""
Check if the given source should be skipped.
"""
return self.should_skip(source_file_path)


class SkipListHandlers(list):
def should_skip(self, file_path: str):
Expand All @@ -117,11 +111,3 @@ def should_skip(self, file_path: str):
handler.
"""
return any(handler.should_skip(file_path) for handler in self)

# FIXME: eliminate this function and use should_skip instead of this.
# Do the same in the SkipListHandler class above.
def __call__(self, file_path: str) -> bool:
"""
Check if the given source should be skipped.
"""
return self.should_skip(file_path)
3 changes: 1 addition & 2 deletions tools/bazel/requirements_py/dev/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pytest==7.3.1
pycodestyle==2.7.0
pylint==2.8.2
mypy==0.812
mypy_extensions==0.4.3
mypy==1.7.1
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
import logging
import os

from typing import Callable, Dict, List, Optional, Set
from typing import Callable, Dict, List, Optional, Protocol, Set

from .. import util


LOG = logging.getLogger('report-converter')


SkipListHandlers = Callable[[str], bool]
class SkipListHandlers(Protocol):
should_skip: Callable[[str], bool]


InvalidFileContentMsg: str = \
Expand Down Expand Up @@ -473,7 +474,7 @@ def skip(self, skip_handlers: Optional[SkipListHandlers]) -> bool:
if not skip_handlers:
return False

return skip_handlers(self.file.original_path)
return skip_handlers.should_skip(self.file.original_path)

def to_json(self) -> Dict:
""" Creates a JSON dictionary. """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#
# -------------------------------------------------------------------------

from typing import Any, Callable, List, Optional, Union
from typing import Callable, List, Optional, Union


class CheckerLabels:
severity: Callable[[Any, str], str]
severity: Callable[[str], str]
label_of_checker: Callable[
[Any, str, str, Optional[str]], Union[str, List[str]]]
[str, str, Optional[str]], Union[str, List[str]]]
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import logging

from typing import Any, Callable, Iterable, List, Optional, Set
from typing import Callable, Iterable, List, Optional, Set

from codechecker_report_converter.report import Report, SkipListHandlers
from codechecker_report_converter.report.hash import get_report_path_hash
Expand All @@ -17,8 +17,8 @@


class GenericSuppressHandler:
get_suppressed: Callable[[Any, Report], bool]
store_suppress_bug_id: Callable[[Any, str, str, str, str], bool]
get_suppressed: Callable[[Report], bool]
store_suppress_bug_id: Callable[[str, str, str, str], bool]


def get_mentioned_original_files(reports: List[Report]) -> Set[str]:
Expand Down
3 changes: 1 addition & 2 deletions tools/report-converter/requirements_py/dev/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ sarif-tools==1.0.0
pycodestyle==2.7.0
pylint==2.8.2
portalocker==2.2.1
mypy==0.812
mypy_extensions==0.4.3
mypy==1.7.1
3 changes: 1 addition & 2 deletions tools/tu_collector/requirements_py/dev/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pytest==7.3.1
pycodestyle==2.7.0
pylint==2.8.2
mypy==0.812
mypy_extensions==0.4.3
mypy==1.7.1
2 changes: 1 addition & 1 deletion web/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ sqlalchemy==1.3.23
alembic==1.5.5
portalocker==2.2.1
psutil==5.8.0
mypy_extensions==0.4.3
multiprocess==0.70.15
thrift==0.13.0
gitpython==3.1.37
PyYAML==6.0.1
types-PyYAML==6.0.12.12
sarif-tools==1.0.0

./api/py/codechecker_api/dist/codechecker_api.tar.gz
Expand Down
12 changes: 1 addition & 11 deletions web/requirements_py/dev/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
lxml==4.9.2
sqlalchemy==1.3.23
pycodestyle==2.7.0
alembic==1.5.5
psycopg2-binary==2.8.6
pg8000==1.15.2
psutil==5.8.0
portalocker==2.2.1
pylint==2.8.2
pytest==7.3.1
mkdocs==1.5.3
mypy_extensions==0.4.3
coverage==5.5.0
thrift==0.13.0
gitpython==3.1.37
sarif-tools==1.0.0

./api/py/codechecker_api/dist/codechecker_api.tar.gz
./api/py/codechecker_api_shared/dist/codechecker_api_shared.tar.gz
-r ../../requirements.txt

# publish packages to pypi
twine
Expand Down
11 changes: 1 addition & 10 deletions web/requirements_py/osx/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
lxml==4.9.2
alembic==1.5.5
portalocker==2.2.1
psutil==5.8.0
sqlalchemy==1.3.23
mypy_extensions==0.4.3
thrift==0.13.0

./api/py/codechecker_api/dist/codechecker_api.tar.gz
./api/py/codechecker_api_shared/dist/codechecker_api_shared.tar.gz
-r ../../requirements.txt
5 changes: 3 additions & 2 deletions web/server/codechecker_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

from http.server import HTTPServer, BaseHTTPRequestHandler, \
SimpleHTTPRequestHandler
from multiprocess import Process
import multiprocess

from sqlalchemy.orm import sessionmaker
from sqlalchemy.sql.expression import func
Expand Down Expand Up @@ -1116,7 +1116,8 @@ def unregister_handler(pid):
atexit.register(unregister_handler, os.getpid())

for _ in range(manager.worker_processes - 1):
p = Process(target=http_server.serve_forever)
# pylint: disable=no-member multiprocess module members.
p = multiprocess.Process(target=http_server.serve_forever)
processes.append(p)
p.start()

Expand Down
1 change: 1 addition & 0 deletions web/tests/functional/authentication/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from libtest import env
import multiprocess

# pylint: disable=no-member multiprocess module members.
# Stopping event for CodeChecker server.
__STOP_SERVER = multiprocess.Event()

Expand Down
1 change: 1 addition & 0 deletions web/tests/functional/cli_config/test_server_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@


class TestServerConfig(unittest.TestCase):
# pylint: disable=no-member multiprocess module members.
_ccClient = None

def setup_class(self):
Expand Down
1 change: 1 addition & 0 deletions web/tests/functional/db_cleanup/test_db_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def __check_serverity_of_reports(self, run_name):
severity_id)

def test_garbage_file_collection(self):
# pylint: disable=no-member multiprocess module members.
event = multiprocess.Event()
event.clear()

Expand Down
1 change: 1 addition & 0 deletions web/tests/functional/instance_manager/test_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from libtest.codechecker import start_server
import multiprocess

# pylint: disable=no-member multiprocess module members.
# Stopping events for CodeChecker servers.
EVENT_1 = multiprocess.Event()
EVENT_2 = multiprocess.Event()
Expand Down
1 change: 1 addition & 0 deletions web/tests/functional/products/test_config_db_share.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from libtest import env
import multiprocess

# pylint: disable=no-member multiprocess module members.
# Stopping events for CodeChecker server.
EVENT = multiprocess.Event()

Expand Down
1 change: 1 addition & 0 deletions web/tests/functional/ssl/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def setup_class(self):

# Stopping event for CodeChecker server.
global __STOP_SERVER
# pylint: disable=no-member multiprocess module members.
__STOP_SERVER = multiprocess.Event()

global TEST_WORKSPACE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def setup_class(self):

# Stopping event for CodeChecker server.
global EVENT_1
# pylint: disable=no-member multiprocess module members.
EVENT_1 = multiprocess.Event()

global TEST_WORKSPACE
Expand Down
1 change: 1 addition & 0 deletions web/tests/libtest/codechecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ def start_server_proc(event, server_cmd, checking_env):
pg_config,
server_args or [])

# pylint: disable=no-member multiprocess module members.
server_proc = multiprocess.Process(
name='server',
target=start_server_proc,
Expand Down

0 comments on commit d3466b8

Please sign in to comment.