kedro-org / kedro

Kedro is a toolbox for production-ready data science. It uses software engineering best practices to help you create data engineering and data science pipelines that are reproducible, maintainable, and modular.
https://kedro.org
Apache License 2.0
9.85k stars 893 forks source link

HEAP_ENDPOINT prevents kedro run of Iris Project on Windows #1249

Closed bwbelljr closed 2 years ago

bwbelljr commented 2 years ago

Description

When I opt into kedro product analytics and run the Iris project example (kedro run) I get an error message (see below).

Context

The bug prevented me from running the tutorial example.

Steps to Reproduce

Based on tutorial from this page: https://kedro.readthedocs.io/en/stable/02_get_started/05_example_project.html 1.kedro new --starter=pandas-iris

  1. cd getting-started
  2. kedro install
  3. kedro run

Expected Result

The project should have run.

Actual Result

(kedro-environment-feb2022) C:\Users\bwbel\Google Drive\learning\learn_repo\kedro_feb2022\get-started>kedro run
2022-02-12 13:51:09,653 - kedro.framework.cli.hooks.manager - INFO - Registered CLI hooks from 1 installed plugin(s): kedro-telemetry-0.1.3
2022-02-12 13:51:09,766 - kedro_telemetry.plugin - INFO - You have opted into product usage analytics.
Traceback (most recent call last):
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\urllib3\connection.py", line 175, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\urllib3\util\connection.py", line 95, in create_connection
    raise err
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\urllib3\util\connection.py", line 85, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\urllib3\connectionpool.py", line 710, in urlopen
    chunked=chunked,
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\urllib3\connectionpool.py", line 1040, in _validate_conn
    conn.connect()
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\urllib3\connection.py", line 358, in connect
    conn = self._new_conn()
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\urllib3\connection.py", line 187, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x000002AE5303F1C8>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\requests\adapters.py", line 449, in send
    timeout=timeout
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\urllib3\connectionpool.py", line 786, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\urllib3\util\retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='heapanalytics.com', port=443): Max retries exceeded with url: /api/track (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000002AE5303F1C8>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it')) 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\Scripts\kedro.exe\__main__.py", line 7, in <module>
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\kedro\framework\cli\cli.py", line 238, in main
    cli_collection()
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\kedro\framework\cli\cli.py", line 180, in main
    project_metadata=self._metadata, command_args=args
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\pluggy\hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\pluggy\manager.py", line 87, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\pluggy\callers.py", line 208, in _multicall
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\kedro_telemetry\plugin.py", line 148, in _send_heap_event
    resp = requests.post(url=HEAP_ENDPOINT, headers=HEAP_HEADERS, data=json.dumps(data))
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\requests\api.py", line 119, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\requests\api.py", line 61, in request    return session.request(method=method, url=url, **kwargs)
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\requests\sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\bwbel\Anaconda3\envs\kedro-environment-feb2022\lib\site-packages\requests\adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='heapanalytics.com', port=443): Max retries exceeded with url: /api/track (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000002AE5303F1C8>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))
-- Separate them if you have more than one.

Your Environment

Include as many relevant details about the environment in which you experienced the bug:

bwbelljr commented 2 years ago

I intend to submit a pull request to solve this. The quick resolution is to change line 26 in kedro_telemetry/plugin.py to:

HEAP_ENDPOINT = "https://heap.io/api/track"

The previous value was heapanalytics.com, which caused the ConnectionError.

datajoely commented 2 years ago

Thank you for pointing this out! @lorenabalan one for kedro-telemetry

mzjp2 commented 2 years ago

Should Kedro catch any exceptions coming from the telemetry and prevent those exceptions from bubbling upwards to interrupt Kedro commands?

datajoely commented 2 years ago

100% we need to wrap this line in an exception handler either way https://github.com/kedro-org/kedro-plugins/blob/fb3c348c9ca72ed968977473aba1485cfa2120b1/kedro-telemetry/kedro_telemetry/plugin.py#L148

lorenabalan commented 2 years ago

Closing as resolved in https://github.com/kedro-org/kedro-plugins/pull/6