MCPcopy
hub / github.com/treeverse/dvc / send

Function send

dvc/analytics.py:65–94  ·  view source on GitHub ↗

Side effect: Removes the report after sending it. The report is generated and stored in a temporary file, see: `collect_and_send_report`. Sending happens on another process, thus, the need of removing such file afterwards.

(path)

Source from the content-addressed store, hash-verified

63
64
65def send(path):
66 """
67 Side effect: Removes the report after sending it.
68
69 The report is generated and stored in a temporary file, see:
70 `collect_and_send_report`. Sending happens on another process,
71 thus, the need of removing such file afterwards.
72 """
73 import requests
74 from requests.exceptions import RequestException
75
76 url = os.environ.get(DVC_ANALYTICS_ENDPOINT, "https://analytics.dvc.org")
77 headers = {"content-type": "application/json"}
78
79 with open(path, encoding="utf-8") as fobj:
80 report = json.load(fobj)
81
82 report.update(_runtime_info())
83
84 logger.debug("uploading report to %s", url)
85 logger.trace("Sending %s to %s", report, url)
86
87 try:
88 requests.post(url, json=report, headers=headers, timeout=5)
89 except RequestException as e:
90 logger.trace("", exc_info=True)
91 logger.debug("failed to send analytics report %s", str(e))
92
93 logger.trace("removing report %s", path)
94 os.remove(path)
95
96
97def _git_remote_url(scm: Optional["Base"]) -> Optional[str]:

Callers

nothing calls this directly

Calls 6

openFunction · 0.85
_runtime_infoFunction · 0.85
getMethod · 0.45
loadMethod · 0.45
updateMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected