We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Do not drop tables in functional tests
## Expected Behavior

Functional tests should clean the tables in Postgres and HBase.

## Actual Behavior

Functional tests drops all the available tables and create them again. This may be (and probably is) time consuming.

## Additional comment

Please compare both implementations before merge.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `backend/medtagger/clients/hbase_client.py`
Content:
```
1 """Module responsible for definition of client for HBase database."""
2 import logging
3 from typing import Iterable, List, Mapping, Tuple, Any
4 
5 import happybase
6 from retrying import retry
7 from thriftpy.transport import TTransportException
8 
9 from medtagger.config import AppConfiguration
10 
11 logger = logging.getLogger(__name__)
12 
13 configuration = AppConfiguration()
14 host = configuration.get('hbase', 'host', fallback='localhost')
15 port = configuration.getint('hbase', 'port', fallback=9090)
16 size = configuration.getint('hbase', 'connection_pool_size', fallback=10)
17 try:
18     HBASE_CONNECTION_POOL = happybase.ConnectionPool(size, host=host, port=port)
19 except (TTransportException, BrokenPipeError):
20     logger.warning('Could not connect to HBase. Is it down?')
21 
22 
23 def is_alive() -> bool:
24     """Return boolean information if HBase is alive or not."""
25     try:
26         happybase.ConnectionPool(1, host=host, port=port)
27         return True
28     except (TTransportException, BrokenPipeError):
29         return False
30 
31 
32 class HBaseClient(object):
33     """Client for HBase.
34 
35     How to use this client?
36     -----------------------
37     This is a wrapper for HappyBase Connection. Client uses HappyBase's Connection Pool, so don't worry about closing
38     connection, etc. This client should do everything inside below methods.
39 
40     WATCH OUT: Script that migrates HBase schema may not work properly if you want to change column names!
41                In such case please run your migration manually!
42 
43     Example:
44 
45         >>> hbase_client = HBaseClient()
46         >>> data = hbase_client.get('my_table_name', 'row_key')
47         >>> ...
48 
49     """
50 
51     ORIGINAL_SLICES_TABLE = 'original_slices'
52     CONVERTED_SLICES_TABLE = 'converted_slices'
53     LABEL_SELECTION_BINARY_MASK_TABLE = 'label_selection_binary_mask'
54 
55     HBASE_SCHEMA = {
56         ORIGINAL_SLICES_TABLE: ['image'],
57         CONVERTED_SLICES_TABLE: ['image'],
58         LABEL_SELECTION_BINARY_MASK_TABLE: ['binary_mask'],
59     }
60 
61     def __init__(self) -> None:
62         """Initialize client."""
63         pass
64 
65     @staticmethod
66     @retry(stop_max_attempt_number=3, wait_random_min=200, wait_random_max=1000,
67            retry_on_exception=lambda ex: isinstance(ex, (TTransportException, BrokenPipeError)))
68     def get_all_keys(table_name: str, starts_with: str = None) -> Iterable[str]:
69         """Fetch all keys for given table.
70 
71         :param table_name: name of a table
72         :param starts_with: prefix for keys
73         :return: iterator for table keys
74         """
75         with HBASE_CONNECTION_POOL.connection() as connection:
76             row_prefix = str.encode(starts_with) if starts_with else None
77             table = connection.table(table_name)
78             for key, _ in table.scan(row_prefix=row_prefix, filter=str.encode('KeyOnlyFilter()')):
79                 yield key.decode('utf-8')
80 
81     @staticmethod
82     @retry(stop_max_attempt_number=3, wait_random_min=200, wait_random_max=1000,
83            retry_on_exception=lambda ex: isinstance(ex, (TTransportException, BrokenPipeError)))
84     def get_all_rows(table_name: str, columns: List, starts_with: str = None) -> Iterable[Tuple[str, Any]]:
85         """Fetch all rows for given table.
86 
87         :param table_name: name of a table
88         :param starts_with: prefix for keys
89         :param columns: list of columns to fetch
90         :return: iterator for table keys
91         """
92         with HBASE_CONNECTION_POOL.connection() as connection:
93             row_prefix = str.encode(starts_with) if starts_with else None
94             table = connection.table(table_name)
95             for key, value in table.scan(row_prefix=row_prefix, columns=columns):
96                 yield key.decode('utf-8'), value
97 
98     @staticmethod
99     @retry(stop_max_attempt_number=3, wait_random_min=200, wait_random_max=1000,
100            retry_on_exception=lambda ex: isinstance(ex, (TTransportException, BrokenPipeError)))
101     def get(table_name: str, key: str, columns: List[str] = None) -> Mapping:
102         """Fetch a single row from HBase table.
103 
104         :param table_name: name of a table
105         :param key: key representing a row
106         :param columns: columns which should be loaded (by default all)
107         :return: mapping returned by HBase
108         """
109         hbase_key = str.encode(key)
110         with HBASE_CONNECTION_POOL.connection() as connection:
111             table = connection.table(table_name)
112             return table.row(hbase_key, columns=columns)
113 
114     @staticmethod
115     @retry(stop_max_attempt_number=3, wait_random_min=200, wait_random_max=1000,
116            retry_on_exception=lambda ex: isinstance(ex, (TTransportException, BrokenPipeError)))
117     def put(table_name: str, key: str, value: Any) -> None:
118         """Add new entry into HBase table.
119 
120         :param table_name: name of a table
121         :param key: key under value should be stored
122         :param value: value which should be stored
123         """
124         hbase_key = str.encode(key)
125         with HBASE_CONNECTION_POOL.connection() as connection:
126             table = connection.table(table_name)
127             table.put(hbase_key, value)
128 
129     @staticmethod
130     @retry(stop_max_attempt_number=3, wait_random_min=200, wait_random_max=1000,
131            retry_on_exception=lambda ex: isinstance(ex, (TTransportException, BrokenPipeError)))
132     def check_if_exists(table_name: str, key: str) -> bool:
133         """Scan database and check if given key exists.
134 
135         :param table_name: name of a table
136         :param key: HBase key
137         :return: boolean information if such key exists or not
138         """
139         hbase_key = str.encode(key)
140         with HBASE_CONNECTION_POOL.connection() as connection:
141             table = connection.table(table_name)
142             results = table.scan(row_start=hbase_key, row_stop=hbase_key,
143                                  filter=str.encode('KeyOnlyFilter() AND FirstKeyOnlyFilter()'), limit=1)
144             return next(results, None) is not None
145
```

Path: `backend/scripts/utils.py`
Content:
```
1 """Storage for all utility functions."""
2 from starbase import Connection
3 from medtagger.config import AppConfiguration
4 
5 
6 def get_connection_to_hbase() -> Connection:
7     """Fetch configuration data and create HBase connection.
8 
9     :return: connection to HBase using Starbase library
10     """
11     configuration = AppConfiguration()
12     host = configuration.get('hbase', 'host', fallback='localhost')
13     port = configuration.getint('hbase', 'rest_port', fallback=8080)
14     return Connection(host=host, port=port)
15 
16 
17 def user_agrees(prompt_message: str) -> bool:
18     """Ask user a question and ask him/her for True/False answer (default answer is False).
19 
20     :param prompt_message: message that will be prompted to user
21     :return: boolean information if user agrees or not
22     """
23     answer = input(prompt_message + ' [y/N] ')
24     return answer.lower() in ['y', 'yes', 't', 'true']
25
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/backend/medtagger/clients/hbase_client.py b/backend/medtagger/clients/hbase_client.py
--- a/backend/medtagger/clients/hbase_client.py
+++ b/backend/medtagger/clients/hbase_client.py
@@ -111,6 +111,21 @@
             table = connection.table(table_name)
             return table.row(hbase_key, columns=columns)
 
+    @staticmethod
+    @retry(stop_max_attempt_number=3, wait_random_min=200, wait_random_max=1000,
+           retry_on_exception=lambda ex: isinstance(ex, (TTransportException, BrokenPipeError)))
+    def delete(table_name: str, key: str, columns: List[str] = None) -> None:
+        """Delete a single row (or values from colums in given row) in HBase table.
+
+        :param table_name: name of a table
+        :param key: key representing a row
+        :param columns: columns which should be cleared
+        """
+        hbase_key = str.encode(key)
+        with HBASE_CONNECTION_POOL.connection() as connection:
+            table = connection.table(table_name)
+            table.delete(hbase_key, columns=columns)
+
     @staticmethod
     @retry(stop_max_attempt_number=3, wait_random_min=200, wait_random_max=1000,
            retry_on_exception=lambda ex: isinstance(ex, (TTransportException, BrokenPipeError)))
diff --git a/backend/scripts/utils.py b/backend/scripts/utils.py
--- a/backend/scripts/utils.py
+++ b/backend/scripts/utils.py
@@ -1,8 +1,13 @@
 """Storage for all utility functions."""
 from starbase import Connection
+from retrying import retry
+import requests
+
 from medtagger.config import AppConfiguration
 
 
+@retry(stop_max_attempt_number=5, wait_random_min=200, wait_random_max=1000,
+       retry_on_exception=lambda ex: isinstance(ex, requests.ConnectionError))
 def get_connection_to_hbase() -> Connection:
     """Fetch configuration data and create HBase connection.
 
@@ -11,7 +16,9 @@
     configuration = AppConfiguration()
     host = configuration.get('hbase', 'host', fallback='localhost')
     port = configuration.getint('hbase', 'rest_port', fallback=8080)
-    return Connection(host=host, port=port)
+    connection = Connection(host=host, port=port)
+    connection.tables()  # Test if the connection was properly set up
+    return connection
 
 
 def user_agrees(prompt_message: str) -> bool:

{"golden_diff": "diff --git a/backend/medtagger/clients/hbase_client.py b/backend/medtagger/clients/hbase_client.py\n--- a/backend/medtagger/clients/hbase_client.py\n+++ b/backend/medtagger/clients/hbase_client.py\n@@ -111,6 +111,21 @@\n             table = connection.table(table_name)\n             return table.row(hbase_key, columns=columns)\n \n+    @staticmethod\n+    @retry(stop_max_attempt_number=3, wait_random_min=200, wait_random_max=1000,\n+           retry_on_exception=lambda ex: isinstance(ex, (TTransportException, BrokenPipeError)))\n+    def delete(table_name: str, key: str, columns: List[str] = None) -> None:\n+        \"\"\"Delete a single row (or values from colums in given row) in HBase table.\n+\n+        :param table_name: name of a table\n+        :param key: key representing a row\n+        :param columns: columns which should be cleared\n+        \"\"\"\n+        hbase_key = str.encode(key)\n+        with HBASE_CONNECTION_POOL.connection() as connection:\n+            table = connection.table(table_name)\n+            table.delete(hbase_key, columns=columns)\n+\n     @staticmethod\n     @retry(stop_max_attempt_number=3, wait_random_min=200, wait_random_max=1000,\n            retry_on_exception=lambda ex: isinstance(ex, (TTransportException, BrokenPipeError)))\ndiff --git a/backend/scripts/utils.py b/backend/scripts/utils.py\n--- a/backend/scripts/utils.py\n+++ b/backend/scripts/utils.py\n@@ -1,8 +1,13 @@\n \"\"\"Storage for all utility functions.\"\"\"\n from starbase import Connection\n+from retrying import retry\n+import requests\n+\n from medtagger.config import AppConfiguration\n \n \n+@retry(stop_max_attempt_number=5, wait_random_min=200, wait_random_max=1000,\n+       retry_on_exception=lambda ex: isinstance(ex, requests.ConnectionError))\n def get_connection_to_hbase() -> Connection:\n     \"\"\"Fetch configuration data and create HBase connection.\n \n@@ -11,7 +16,9 @@\n     configuration = AppConfiguration()\n     host = configuration.get('hbase', 'host', fallback='localhost')\n     port = configuration.getint('hbase', 'rest_port', fallback=8080)\n-    return Connection(host=host, port=port)\n+    connection = Connection(host=host, port=port)\n+    connection.tables()  # Test if the connection was properly set up\n+    return connection\n \n \n def user_agrees(prompt_message: str) -> bool:\n", "issue": "Do not drop tables in functional tests\n## Expected Behavior\r\n\r\nFunctional tests should clean the tables in Postgres and HBase.\r\n\r\n## Actual Behavior\r\n\r\nFunctional tests drops all the available tables and create them again. This may be (and probably is) time consuming.\r\n\r\n## Additional comment\r\n\r\nPlease compare both implementations before merge.\n", "before_files": [{"content": "\"\"\"Module responsible for definition of client for HBase database.\"\"\"\nimport logging\nfrom typing import Iterable, List, Mapping, Tuple, Any\n\nimport happybase\nfrom retrying import retry\nfrom thriftpy.transport import TTransportException\n\nfrom medtagger.config import AppConfiguration\n\nlogger = logging.getLogger(__name__)\n\nconfiguration = AppConfiguration()\nhost = configuration.get('hbase', 'host', fallback='localhost')\nport = configuration.getint('hbase', 'port', fallback=9090)\nsize = configuration.getint('hbase', 'connection_pool_size', fallback=10)\ntry:\n    HBASE_CONNECTION_POOL = happybase.ConnectionPool(size, host=host, port=port)\nexcept (TTransportException, BrokenPipeError):\n    logger.warning('Could not connect to HBase. Is it down?')\n\n\ndef is_alive() -> bool:\n    \"\"\"Return boolean information if HBase is alive or not.\"\"\"\n    try:\n        happybase.ConnectionPool(1, host=host, port=port)\n        return True\n    except (TTransportException, BrokenPipeError):\n        return False\n\n\nclass HBaseClient(object):\n    \"\"\"Client for HBase.\n\n    How to use this client?\n    -----------------------\n    This is a wrapper for HappyBase Connection. Client uses HappyBase's Connection Pool, so don't worry about closing\n    connection, etc. This client should do everything inside below methods.\n\n    WATCH OUT: Script that migrates HBase schema may not work properly if you want to change column names!\n               In such case please run your migration manually!\n\n    Example:\n\n        >>> hbase_client = HBaseClient()\n        >>> data = hbase_client.get('my_table_name', 'row_key')\n        >>> ...\n\n    \"\"\"\n\n    ORIGINAL_SLICES_TABLE = 'original_slices'\n    CONVERTED_SLICES_TABLE = 'converted_slices'\n    LABEL_SELECTION_BINARY_MASK_TABLE = 'label_selection_binary_mask'\n\n    HBASE_SCHEMA = {\n        ORIGINAL_SLICES_TABLE: ['image'],\n        CONVERTED_SLICES_TABLE: ['image'],\n        LABEL_SELECTION_BINARY_MASK_TABLE: ['binary_mask'],\n    }\n\n    def __init__(self) -> None:\n        \"\"\"Initialize client.\"\"\"\n        pass\n\n    @staticmethod\n    @retry(stop_max_attempt_number=3, wait_random_min=200, wait_random_max=1000,\n           retry_on_exception=lambda ex: isinstance(ex, (TTransportException, BrokenPipeError)))\n    def get_all_keys(table_name: str, starts_with: str = None) -> Iterable[str]:\n        \"\"\"Fetch all keys for given table.\n\n        :param table_name: name of a table\n        :param starts_with: prefix for keys\n        :return: iterator for table keys\n        \"\"\"\n        with HBASE_CONNECTION_POOL.connection() as connection:\n            row_prefix = str.encode(starts_with) if starts_with else None\n            table = connection.table(table_name)\n            for key, _ in table.scan(row_prefix=row_prefix, filter=str.encode('KeyOnlyFilter()')):\n                yield key.decode('utf-8')\n\n    @staticmethod\n    @retry(stop_max_attempt_number=3, wait_random_min=200, wait_random_max=1000,\n           retry_on_exception=lambda ex: isinstance(ex, (TTransportException, BrokenPipeError)))\n    def get_all_rows(table_name: str, columns: List, starts_with: str = None) -> Iterable[Tuple[str, Any]]:\n        \"\"\"Fetch all rows for given table.\n\n        :param table_name: name of a table\n        :param starts_with: prefix for keys\n        :param columns: list of columns to fetch\n        :return: iterator for table keys\n        \"\"\"\n        with HBASE_CONNECTION_POOL.connection() as connection:\n            row_prefix = str.encode(starts_with) if starts_with else None\n            table = connection.table(table_name)\n            for key, value in table.scan(row_prefix=row_prefix, columns=columns):\n                yield key.decode('utf-8'), value\n\n    @staticmethod\n    @retry(stop_max_attempt_number=3, wait_random_min=200, wait_random_max=1000,\n           retry_on_exception=lambda ex: isinstance(ex, (TTransportException, BrokenPipeError)))\n    def get(table_name: str, key: str, columns: List[str] = None) -> Mapping:\n        \"\"\"Fetch a single row from HBase table.\n\n        :param table_name: name of a table\n        :param key: key representing a row\n        :param columns: columns which should be loaded (by default all)\n        :return: mapping returned by HBase\n        \"\"\"\n        hbase_key = str.encode(key)\n        with HBASE_CONNECTION_POOL.connection() as connection:\n            table = connection.table(table_name)\n            return table.row(hbase_key, columns=columns)\n\n    @staticmethod\n    @retry(stop_max_attempt_number=3, wait_random_min=200, wait_random_max=1000,\n           retry_on_exception=lambda ex: isinstance(ex, (TTransportException, BrokenPipeError)))\n    def put(table_name: str, key: str, value: Any) -> None:\n        \"\"\"Add new entry into HBase table.\n\n        :param table_name: name of a table\n        :param key: key under value should be stored\n        :param value: value which should be stored\n        \"\"\"\n        hbase_key = str.encode(key)\n        with HBASE_CONNECTION_POOL.connection() as connection:\n            table = connection.table(table_name)\n            table.put(hbase_key, value)\n\n    @staticmethod\n    @retry(stop_max_attempt_number=3, wait_random_min=200, wait_random_max=1000,\n           retry_on_exception=lambda ex: isinstance(ex, (TTransportException, BrokenPipeError)))\n    def check_if_exists(table_name: str, key: str) -> bool:\n        \"\"\"Scan database and check if given key exists.\n\n        :param table_name: name of a table\n        :param key: HBase key\n        :return: boolean information if such key exists or not\n        \"\"\"\n        hbase_key = str.encode(key)\n        with HBASE_CONNECTION_POOL.connection() as connection:\n            table = connection.table(table_name)\n            results = table.scan(row_start=hbase_key, row_stop=hbase_key,\n                                 filter=str.encode('KeyOnlyFilter() AND FirstKeyOnlyFilter()'), limit=1)\n            return next(results, None) is not None\n", "path": "backend/medtagger/clients/hbase_client.py"}, {"content": "\"\"\"Storage for all utility functions.\"\"\"\nfrom starbase import Connection\nfrom medtagger.config import AppConfiguration\n\n\ndef get_connection_to_hbase() -> Connection:\n    \"\"\"Fetch configuration data and create HBase connection.\n\n    :return: connection to HBase using Starbase library\n    \"\"\"\n    configuration = AppConfiguration()\n    host = configuration.get('hbase', 'host', fallback='localhost')\n    port = configuration.getint('hbase', 'rest_port', fallback=8080)\n    return Connection(host=host, port=port)\n\n\ndef user_agrees(prompt_message: str) -> bool:\n    \"\"\"Ask user a question and ask him/her for True/False answer (default answer is False).\n\n    :param prompt_message: message that will be prompted to user\n    :return: boolean information if user agrees or not\n    \"\"\"\n    answer = input(prompt_message + ' [y/N] ')\n    return answer.lower() in ['y', 'yes', 't', 'true']\n", "path": "backend/scripts/utils.py"}], "after_files": [{"content": "\"\"\"Module responsible for definition of client for HBase database.\"\"\"\nimport logging\nfrom typing import Iterable, List, Mapping, Tuple, Any\n\nimport happybase\nfrom retrying import retry\nfrom thriftpy.transport import TTransportException\n\nfrom medtagger.config import AppConfiguration\n\nlogger = logging.getLogger(__name__)\n\nconfiguration = AppConfiguration()\nhost = configuration.get('hbase', 'host', fallback='localhost')\nport = configuration.getint('hbase', 'port', fallback=9090)\nsize = configuration.getint('hbase', 'connection_pool_size', fallback=10)\ntry:\n    HBASE_CONNECTION_POOL = happybase.ConnectionPool(size, host=host, port=port)\nexcept (TTransportException, BrokenPipeError):\n    logger.warning('Could not connect to HBase. Is it down?')\n\n\ndef is_alive() -> bool:\n    \"\"\"Return boolean information if HBase is alive or not.\"\"\"\n    try:\n        happybase.ConnectionPool(1, host=host, port=port)\n        return True\n    except (TTransportException, BrokenPipeError):\n        return False\n\n\nclass HBaseClient(object):\n    \"\"\"Client for HBase.\n\n    How to use this client?\n    -----------------------\n    This is a wrapper for HappyBase Connection. Client uses HappyBase's Connection Pool, so don't worry about closing\n    connection, etc. This client should do everything inside below methods.\n\n    WATCH OUT: Script that migrates HBase schema may not work properly if you want to change column names!\n               In such case please run your migration manually!\n\n    Example:\n\n        >>> hbase_client = HBaseClient()\n        >>> data = hbase_client.get('my_table_name', 'row_key')\n        >>> ...\n\n    \"\"\"\n\n    ORIGINAL_SLICES_TABLE = 'original_slices'\n    CONVERTED_SLICES_TABLE = 'converted_slices'\n    LABEL_SELECTION_BINARY_MASK_TABLE = 'label_selection_binary_mask'\n\n    HBASE_SCHEMA = {\n        ORIGINAL_SLICES_TABLE: ['image'],\n        CONVERTED_SLICES_TABLE: ['image'],\n        LABEL_SELECTION_BINARY_MASK_TABLE: ['binary_mask'],\n    }\n\n    def __init__(self) -> None:\n        \"\"\"Initialize client.\"\"\"\n        pass\n\n    @staticmethod\n    @retry(stop_max_attempt_number=3, wait_random_min=200, wait_random_max=1000,\n           retry_on_exception=lambda ex: isinstance(ex, (TTransportException, BrokenPipeError)))\n    def get_all_keys(table_name: str, starts_with: str = None) -> Iterable[str]:\n        \"\"\"Fetch all keys for given table.\n\n        :param table_name: name of a table\n        :param starts_with: prefix for keys\n        :return: iterator for table keys\n        \"\"\"\n        with HBASE_CONNECTION_POOL.connection() as connection:\n            row_prefix = str.encode(starts_with) if starts_with else None\n            table = connection.table(table_name)\n            for key, _ in table.scan(row_prefix=row_prefix, filter=str.encode('KeyOnlyFilter()')):\n                yield key.decode('utf-8')\n\n    @staticmethod\n    @retry(stop_max_attempt_number=3, wait_random_min=200, wait_random_max=1000,\n           retry_on_exception=lambda ex: isinstance(ex, (TTransportException, BrokenPipeError)))\n    def get_all_rows(table_name: str, columns: List, starts_with: str = None) -> Iterable[Tuple[str, Any]]:\n        \"\"\"Fetch all rows for given table.\n\n        :param table_name: name of a table\n        :param starts_with: prefix for keys\n        :param columns: list of columns to fetch\n        :return: iterator for table keys\n        \"\"\"\n        with HBASE_CONNECTION_POOL.connection() as connection:\n            row_prefix = str.encode(starts_with) if starts_with else None\n            table = connection.table(table_name)\n            for key, value in table.scan(row_prefix=row_prefix, columns=columns):\n                yield key.decode('utf-8'), value\n\n    @staticmethod\n    @retry(stop_max_attempt_number=3, wait_random_min=200, wait_random_max=1000,\n           retry_on_exception=lambda ex: isinstance(ex, (TTransportException, BrokenPipeError)))\n    def get(table_name: str, key: str, columns: List[str] = None) -> Mapping:\n        \"\"\"Fetch a single row from HBase table.\n\n        :param table_name: name of a table\n        :param key: key representing a row\n        :param columns: columns which should be loaded (by default all)\n        :return: mapping returned by HBase\n        \"\"\"\n        hbase_key = str.encode(key)\n        with HBASE_CONNECTION_POOL.connection() as connection:\n            table = connection.table(table_name)\n            return table.row(hbase_key, columns=columns)\n\n    @staticmethod\n    @retry(stop_max_attempt_number=3, wait_random_min=200, wait_random_max=1000,\n           retry_on_exception=lambda ex: isinstance(ex, (TTransportException, BrokenPipeError)))\n    def delete(table_name: str, key: str, columns: List[str] = None) -> None:\n        \"\"\"Delete a single row (or values from colums in given row) in HBase table.\n\n        :param table_name: name of a table\n        :param key: key representing a row\n        :param columns: columns which should be cleared\n        \"\"\"\n        hbase_key = str.encode(key)\n        with HBASE_CONNECTION_POOL.connection() as connection:\n            table = connection.table(table_name)\n            table.delete(hbase_key, columns=columns)\n\n    @staticmethod\n    @retry(stop_max_attempt_number=3, wait_random_min=200, wait_random_max=1000,\n           retry_on_exception=lambda ex: isinstance(ex, (TTransportException, BrokenPipeError)))\n    def put(table_name: str, key: str, value: Any) -> None:\n        \"\"\"Add new entry into HBase table.\n\n        :param table_name: name of a table\n        :param key: key under value should be stored\n        :param value: value which should be stored\n        \"\"\"\n        hbase_key = str.encode(key)\n        with HBASE_CONNECTION_POOL.connection() as connection:\n            table = connection.table(table_name)\n            table.put(hbase_key, value)\n\n    @staticmethod\n    @retry(stop_max_attempt_number=3, wait_random_min=200, wait_random_max=1000,\n           retry_on_exception=lambda ex: isinstance(ex, (TTransportException, BrokenPipeError)))\n    def check_if_exists(table_name: str, key: str) -> bool:\n        \"\"\"Scan database and check if given key exists.\n\n        :param table_name: name of a table\n        :param key: HBase key\n        :return: boolean information if such key exists or not\n        \"\"\"\n        hbase_key = str.encode(key)\n        with HBASE_CONNECTION_POOL.connection() as connection:\n            table = connection.table(table_name)\n            results = table.scan(row_start=hbase_key, row_stop=hbase_key,\n                                 filter=str.encode('KeyOnlyFilter() AND FirstKeyOnlyFilter()'), limit=1)\n            return next(results, None) is not None\n", "path": "backend/medtagger/clients/hbase_client.py"}, {"content": "\"\"\"Storage for all utility functions.\"\"\"\nfrom starbase import Connection\nfrom retrying import retry\nimport requests\n\nfrom medtagger.config import AppConfiguration\n\n\n@retry(stop_max_attempt_number=5, wait_random_min=200, wait_random_max=1000,\n       retry_on_exception=lambda ex: isinstance(ex, requests.ConnectionError))\ndef get_connection_to_hbase() -> Connection:\n    \"\"\"Fetch configuration data and create HBase connection.\n\n    :return: connection to HBase using Starbase library\n    \"\"\"\n    configuration = AppConfiguration()\n    host = configuration.get('hbase', 'host', fallback='localhost')\n    port = configuration.getint('hbase', 'rest_port', fallback=8080)\n    connection = Connection(host=host, port=port)\n    connection.tables()  # Test if the connection was properly set up\n    return connection\n\n\ndef user_agrees(prompt_message: str) -> bool:\n    \"\"\"Ask user a question and ask him/her for True/False answer (default answer is False).\n\n    :param prompt_message: message that will be prompted to user\n    :return: boolean information if user agrees or not\n    \"\"\"\n    answer = input(prompt_message + ' [y/N] ')\n    return answer.lower() in ['y', 'yes', 't', 'true']\n", "path": "backend/scripts/utils.py"}]}