Skip to content

Commit 38ed298

Browse files
committed
removed some old tests
1 parent 6ecbe84 commit 38ed298

File tree

4 files changed

+24
-183
lines changed

4 files changed

+24
-183
lines changed

README.md

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -25,61 +25,3 @@ $ pip install ragas_annotator
2525
First lets init a
2626
[`Project`](https://explodinggradients.github.io/ragas_annotator/project/core.html#project)
2727
from notion.
28-
29-
``` python
30-
from ragas_annotator import Project
31-
32-
project = Project(
33-
name="Ragas Dashboard",
34-
notion_root_page_id="1b35d9bf94ff801792bfd1824fac0c96"
35-
)
36-
project
37-
```
38-
39-
Project(name='Ragas Dashboard', root_page_id=1b35d9bf94ff801792bfd1824fac0c96)
40-
41-
NOTE: ideally this should be optional - just send a dict
42-
43-
``` python
44-
from ragas_annotator import NotionModel, nmt
45-
46-
# define the model
47-
class RAGDataset(NotionModel):
48-
id: int = nmt.ID()
49-
query: str = nmt.Title()
50-
ground_truth: str = nmt.Text()
51-
```
52-
53-
Lets check the datasets it has
54-
55-
``` python
56-
dataset = project.get_dataset("RAG Dataset", RAGDataset)
57-
dataset
58-
```
59-
60-
Dataset(name=RAG Dataset, model=RAGDataset, len=0)
61-
62-
``` python
63-
def example_llm_app(query: str):
64-
return "This is a test"
65-
66-
67-
68-
@project.experiment(RAGDataset)
69-
def random_experiment(row):
70-
print(row)
71-
return row
72-
```
73-
74-
AttributeError: 'Project' object has no attribute 'experiment'
75-
---------------------------------------------------------------------------
76-
AttributeError Traceback (most recent call last)
77-
Cell In[5], line 6
78-
 1 def example_llm_app(query: str):
79-
 2 return "This is a test"
80-
----> 6 @project.experiment(RAGDataset)
81-
 7 def random_experiment(row):
82-
 8 print(row)
83-
 9 return row
84-
85-
AttributeError: 'Project' object has no attribute 'experiment'

nbs/index.ipynb

Lines changed: 0 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -59,123 +59,6 @@
5959
"source": [
6060
"First lets init a `Project` from notion."
6161
]
62-
},
63-
{
64-
"cell_type": "code",
65-
"execution_count": null,
66-
"metadata": {},
67-
"outputs": [
68-
{
69-
"data": {
70-
"text/plain": [
71-
"Project(name='Ragas Dashboard', root_page_id=1b35d9bf94ff801792bfd1824fac0c96)"
72-
]
73-
},
74-
"execution_count": null,
75-
"metadata": {},
76-
"output_type": "execute_result"
77-
}
78-
],
79-
"source": [
80-
"from ragas_annotator import Project\n",
81-
"\n",
82-
"project = Project(\n",
83-
" name=\"Ragas Dashboard\",\n",
84-
" notion_root_page_id=\"1b35d9bf94ff801792bfd1824fac0c96\"\n",
85-
")\n",
86-
"project"
87-
]
88-
},
89-
{
90-
"cell_type": "markdown",
91-
"metadata": {},
92-
"source": [
93-
"NOTE: ideally this should be optional - just send a dict"
94-
]
95-
},
96-
{
97-
"cell_type": "code",
98-
"execution_count": null,
99-
"metadata": {},
100-
"outputs": [],
101-
"source": [
102-
"from ragas_annotator import NotionModel, nmt\n",
103-
"\n",
104-
"# define the model\n",
105-
"class RAGDataset(NotionModel):\n",
106-
" id: int = nmt.ID()\n",
107-
" query: str = nmt.Title()\n",
108-
" ground_truth: str = nmt.Text()"
109-
]
110-
},
111-
{
112-
"cell_type": "markdown",
113-
"metadata": {},
114-
"source": [
115-
"Lets check the datasets it has"
116-
]
117-
},
118-
{
119-
"cell_type": "code",
120-
"execution_count": null,
121-
"metadata": {},
122-
"outputs": [
123-
{
124-
"data": {
125-
"text/plain": [
126-
"Dataset(name=RAG Dataset, model=RAGDataset, len=0)"
127-
]
128-
},
129-
"execution_count": null,
130-
"metadata": {},
131-
"output_type": "execute_result"
132-
}
133-
],
134-
"source": [
135-
"dataset = project.get_dataset(\"RAG Dataset\", RAGDataset)\n",
136-
"dataset\n"
137-
]
138-
},
139-
{
140-
"cell_type": "code",
141-
"execution_count": null,
142-
"metadata": {},
143-
"outputs": [
144-
{
145-
"ename": "AttributeError",
146-
"evalue": "'Project' object has no attribute 'experiment'",
147-
"output_type": "error",
148-
"traceback": [
149-
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
150-
"\u001b[31mAttributeError\u001b[39m Traceback (most recent call last)",
151-
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[5]\u001b[39m\u001b[32m, line 6\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mexample_llm_app\u001b[39m(query: \u001b[38;5;28mstr\u001b[39m):\n\u001b[32m 2\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[33m\"\u001b[39m\u001b[33mThis is a test\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m6\u001b[39m \u001b[38;5;129m@project\u001b[39m\u001b[43m.\u001b[49m\u001b[43mexperiment\u001b[49m(RAGDataset)\n\u001b[32m 7\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mrandom_experiment\u001b[39m(row):\n\u001b[32m 8\u001b[39m \u001b[38;5;28mprint\u001b[39m(row)\n\u001b[32m 9\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m row\n",
152-
"\u001b[31mAttributeError\u001b[39m: 'Project' object has no attribute 'experiment'"
153-
]
154-
}
155-
],
156-
"source": [
157-
"def example_llm_app(query: str):\n",
158-
" return \"This is a test\"\n",
159-
"\n",
160-
"\n",
161-
"\n",
162-
"@project.experiment(RAGDataset)\n",
163-
"def random_experiment(row):\n",
164-
" print(row)\n",
165-
" return row\n",
166-
"\n",
167-
"\n",
168-
"\n",
169-
"\n",
170-
"\n"
171-
]
172-
},
173-
{
174-
"cell_type": "code",
175-
"execution_count": null,
176-
"metadata": {},
177-
"outputs": [],
178-
"source": []
17962
}
18063
],
18164
"metadata": {

nbs/project/core.ipynb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"from fastcore.utils import patch\n",
4343
"\n",
4444
"from ragas_annotator.backends.notion_backend import NotionBackend\n",
45+
"from ragas_annotator.backends.factory import NotionBackendFactory\n",
4546
"from ragas_annotator.model.notion_model import NotionModel\n",
4647
"import ragas_annotator.model.notion_typing as nmt\n",
4748
"from ragas_annotator.dataset import Dataset\n",
@@ -81,10 +82,17 @@
8182
" if notion_root_page_id is None:\n",
8283
" raise ValueError(\"NOTION_ROOT_PAGE_ID is not set\")\n",
8384
"\n",
84-
" self._notion_backend = NotionBackend(\n",
85-
" notion_client=NotionClient(auth=notion_api_key),\n",
86-
" root_page_id=notion_root_page_id,\n",
87-
" )\n",
85+
" if notion_api_key == \"TEST\":\n",
86+
" self._notion_backend = NotionBackendFactory.create(\n",
87+
" root_page_id=notion_root_page_id,\n",
88+
" use_mock=True,\n",
89+
" initialize_project=True,\n",
90+
" )\n",
91+
" else:\n",
92+
" self._notion_backend = NotionBackend(\n",
93+
" notion_client=NotionClient(auth=notion_api_key),\n",
94+
" root_page_id=notion_root_page_id,\n",
95+
" )\n",
8896
" else:\n",
8997
" self._notion_backend = notion_backend\n",
9098
"\n",

ragas_annotator/project/core.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from fastcore.utils import patch
1414

1515
from ..backends.notion_backend import NotionBackend
16+
from ..backends.factory import NotionBackendFactory
1617
from ..model.notion_model import NotionModel
1718
import ragas_annotator.model.notion_typing as nmt
1819
from ..dataset import Dataset
@@ -45,10 +46,17 @@ def __init__(
4546
if notion_root_page_id is None:
4647
raise ValueError("NOTION_ROOT_PAGE_ID is not set")
4748

48-
self._notion_backend = NotionBackend(
49-
notion_client=NotionClient(auth=notion_api_key),
50-
root_page_id=notion_root_page_id,
51-
)
49+
if notion_api_key == "TEST":
50+
self._notion_backend = NotionBackendFactory.create(
51+
root_page_id=notion_root_page_id,
52+
use_mock=True,
53+
initialize_project=True,
54+
)
55+
else:
56+
self._notion_backend = NotionBackend(
57+
notion_client=NotionClient(auth=notion_api_key),
58+
root_page_id=notion_root_page_id,
59+
)
5260
else:
5361
self._notion_backend = notion_backend
5462

0 commit comments

Comments
 (0)