From 946dfc14004a1dd17241c30795e48d36fce4c615 Mon Sep 17 00:00:00 2001 From: "Mr. Outis" Date: Mon, 2 Dec 2019 17:35:21 -0600 Subject: [PATCH] analytics: send report without loading it to memory shout-out to @Suor for the suggestion --- dvc/analytics.py | 5 ++--- tests/unit/test_analytics.py | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dvc/analytics.py b/dvc/analytics.py index a4c321a18..d658c9191 100644 --- a/dvc/analytics.py +++ b/dvc/analytics.py @@ -52,11 +52,10 @@ def is_enabled(): def send(path): url = "https://analytics.dvc.org" + headers = {"content-type": "application/json"} with open(str(path)) as fobj: - report = json.load(fobj) - - requests.post(url, json=report, timeout=5) + requests.post(url, data=fobj, headers=headers, timeout=5) def scm_in_use(): diff --git a/tests/unit/test_analytics.py b/tests/unit/test_analytics.py index b0f3affaa..e48e4972d 100644 --- a/tests/unit/test_analytics.py +++ b/tests/unit/test_analytics.py @@ -34,7 +34,8 @@ def test_send(mock_post, tmp_path): fname.write_text(str(json.dumps(report))) analytics.send(fname) - mock_post.assert_called_with(url, json=report, timeout=5) + assert mock_post.called + assert mock_post.call_args.args[0] == url @pytest.mark.parametrize(