diff --git a/dvc/analytics.py b/dvc/analytics.py index 088b24eb8..2826a95f7 100644 --- a/dvc/analytics.py +++ b/dvc/analytics.py @@ -35,7 +35,7 @@ def collect_and_send_report(args=None, return_code=None): report as a JSON, where the _collector_ generates it and the _sender_ removes it after sending it. """ - report = runtime_info() + report = _runtime_info() # Include command execution information on the report report.update( @@ -50,19 +50,6 @@ def collect_and_send_report(args=None, return_code=None): daemon(["analytics", fobj.name]) -def runtime_info(): - """ - Gather information from the environment where DVC runs to fill a report. - """ - return { - "dvc_version": __version__, - "is_binary": is_binary(), - "scm_class": scm_in_use(), - "system_info": system_info(), - "user_id": find_or_create_user_id(), - } - - def is_enabled(): if env2bool("DVC_TEST"): return False @@ -95,7 +82,7 @@ def send(report): os.remove(report) -def scm_in_use(): +def _scm_in_use(): try: scm = SCM(root_dir=Repo.find_root()) return type(scm).__name__ @@ -103,7 +90,20 @@ def scm_in_use(): pass -def system_info(): +def _runtime_info(): + """ + Gather information from the environment where DVC runs to fill a report. + """ + return { + "dvc_version": __version__, + "is_binary": is_binary(), + "scm_class": _scm_in_use(), + "system_info": _system_info(), + "user_id": _find_or_create_user_id(), + } + + +def _system_info(): system = platform.system() if system == "Windows": @@ -131,7 +131,7 @@ def system_info(): return {"os": system.lower()} -def find_or_create_user_id(): +def _find_or_create_user_id(): """ The user's ID is stored on a file under the global config directory. diff --git a/tests/func/test_analytics.py b/tests/func/test_analytics.py index 863b0e329..f7cc0bfed 100644 --- a/tests/func/test_analytics.py +++ b/tests/func/test_analytics.py @@ -14,7 +14,7 @@ def test_daemon_analytics(mock_send, tmp_path): @mock.patch("dvc.daemon._spawn") @mock.patch("dvc.analytics.is_enabled", return_value=True) -@mock.patch("dvc.analytics.runtime_info", return_value={}) +@mock.patch("dvc.analytics._runtime_info", return_value={}) def test_main_analytics(mock_is_enabled, mock_daemon, mock_report, dvc_repo): assert 0 == main(["add", "foo"]) assert mock_is_enabled.called diff --git a/tests/unit/test_analytics.py b/tests/unit/test_analytics.py index 60e7a565b..7d4138564 100644 --- a/tests/unit/test_analytics.py +++ b/tests/unit/test_analytics.py @@ -34,7 +34,7 @@ def test_runtime_info(tmp_global_config): } ) - assert schema(analytics.runtime_info()) + assert schema(analytics._runtime_info()) @mock.patch("requests.post") @@ -99,11 +99,11 @@ def test_system_info(): } ) - assert schema(analytics.system_info()) + assert schema(analytics._system_info()) def test_find_or_create_user_id(tmp_global_config): - created = analytics.find_or_create_user_id() - found = analytics.find_or_create_user_id() + created = analytics._find_or_create_user_id() + found = analytics._find_or_create_user_id() assert created == found