Skip to content

Commit

Permalink
only two first tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ignacioct committed May 2, 2024
1 parent dd24c2c commit 16c29f2
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 70 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ jobs:
run:
shell: bash -l {0}
steps:
- name: Wait for argilla-quickstart to start
- name: 🪑 Wait for argilla-quickstart
run: |
while ! curl -XGET http://localhost:6900/api/_status; do sleep 30; done
- name: Curl
run: curl -XGET http://localhost:6900/api/_status
- name: 🪑 Check workspaces
run: |
curl -XGET http://localhost:6900/api/workspaces
- name: Checkout Code 🛎
uses: actions/checkout@v3
- name: Setup Conda Env 🐍
Expand Down
134 changes: 67 additions & 67 deletions tests/test_llama_index_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,73 +46,73 @@ def test_init_connection_error(self, mock_init):
api_key=self.api_key,
)

@patch("argilla_llama_index.llama_index_handler.rg.FeedbackDataset.list")
@patch("argilla_llama_index.llama_index_handler.rg.FeedbackDataset.from_argilla")
def test_init_file_not_found_error(self, mock_from_argilla, mock_list):
mock_list.return_value = []
mock_from_argilla.side_effect = FileNotFoundError("Dataset not found")
with self.assertRaises(FileNotFoundError):
ArgillaCallbackHandler(
dataset_name=self.dataset_name,
workspace_name=self.workspace_name,
api_url=self.api_url,
api_key=self.api_key,
)

def test_check_components_for_tree(self):
self.handler._check_components_for_tree(self.tree_structure_dict)

def test_get_events_map_with_names(self):

trace_map = {"query": ["retrieve"], "llm": []}
events_map = self.handler._get_events_map_with_names(
self.events_data, trace_map
)
self.assertIsInstance(events_map, dict)
self.assertEqual(len(events_map), 2)

def test_extract_and_log_info(self):

tree_structure_dict = self.handler._check_components_for_tree(
self.tree_structure_dict
)
self.handler._extract_and_log_info(self.events_data, tree_structure_dict)

def test_start_trace(self):
self.handler.start_trace()

# TODO: Create a test for end_trace

def test_on_event_start(self):
event_type = "event1"
payload = {}
event_id = "123"
parent_id = "456"
self.handler.on_event_start(event_type, payload, event_id, parent_id)

def test_on_event_end(self):
event_type = "event1"
payload = {}
event_id = "123"
self.handler.on_event_end(event_type, payload, event_id)

def test_get_time_diff(self):
event_1_time_str = "01/11/2024, 17:01:04.328656"
event_2_time_str = "01/11/2024, 17:02:07.328523"
time_diff = _get_time_diff(event_1_time_str, event_2_time_str)
self.assertIsInstance(time_diff, float)

def test_calc_time(self):

id = "event1"
self.events_data.__getitem__().__getitem__().time = (
"01/11/2024, 17:01:04.328656"
)
self.events_data.__getitem__().__getitem__().time = (
"01/11/2024, 17:02:07.328523"
)
time = _calc_time(self.events_data, id)
self.assertIsInstance(time, float)
# @patch("argilla_llama_index.llama_index_handler.rg.FeedbackDataset.list")
# @patch("argilla_llama_index.llama_index_handler.rg.FeedbackDataset.from_argilla")
# def test_init_file_not_found_error(self, mock_from_argilla, mock_list):
# mock_list.return_value = []
# mock_from_argilla.side_effect = FileNotFoundError("Dataset not found")
# with self.assertRaises(FileNotFoundError):
# ArgillaCallbackHandler(
# dataset_name=self.dataset_name,
# workspace_name=self.workspace_name,
# api_url=self.api_url,
# api_key=self.api_key,
# )

# def test_check_components_for_tree(self):
# self.handler._check_components_for_tree(self.tree_structure_dict)

# def test_get_events_map_with_names(self):

# trace_map = {"query": ["retrieve"], "llm": []}
# events_map = self.handler._get_events_map_with_names(
# self.events_data, trace_map
# )
# self.assertIsInstance(events_map, dict)
# self.assertEqual(len(events_map), 2)

# def test_extract_and_log_info(self):

# tree_structure_dict = self.handler._check_components_for_tree(
# self.tree_structure_dict
# )
# self.handler._extract_and_log_info(self.events_data, tree_structure_dict)

# def test_start_trace(self):
# self.handler.start_trace()

# # TODO: Create a test for end_trace

# def test_on_event_start(self):
# event_type = "event1"
# payload = {}
# event_id = "123"
# parent_id = "456"
# self.handler.on_event_start(event_type, payload, event_id, parent_id)

# def test_on_event_end(self):
# event_type = "event1"
# payload = {}
# event_id = "123"
# self.handler.on_event_end(event_type, payload, event_id)

# def test_get_time_diff(self):
# event_1_time_str = "01/11/2024, 17:01:04.328656"
# event_2_time_str = "01/11/2024, 17:02:07.328523"
# time_diff = _get_time_diff(event_1_time_str, event_2_time_str)
# self.assertIsInstance(time_diff, float)

# def test_calc_time(self):

# id = "event1"
# self.events_data.__getitem__().__getitem__().time = (
# "01/11/2024, 17:01:04.328656"
# )
# self.events_data.__getitem__().__getitem__().time = (
# "01/11/2024, 17:02:07.328523"
# )
# time = _calc_time(self.events_data, id)
# self.assertIsInstance(time, float)


if __name__ == "__main__":
Expand Down

0 comments on commit 16c29f2

Please sign in to comment.