Skip to content

Commit 9cdd897

Browse files
pjoshi30Preetam Joshi
andauthored
Adding an ENUM for application stage (#3)
* Adding an ENUM for application stage * Fixed bug in dataset creation and updated the notebook with the Enum utility --------- Co-authored-by: Preetam Joshi <info@aimon.ai>
1 parent ca4c435 commit 9cdd897

File tree

3 files changed

+29
-21
lines changed

3 files changed

+29
-21
lines changed

aimon/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .client import Client
2+
from .client import ApplicationStage
23
from .dataset import Dataset, DatasetCollection, DatasetRecord
34
from .evaluation import Evaluation, Run
45
from .models import MLModel

aimon/client.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
class InvalidAPIKeyError(Exception):
1111
pass
1212

13+
# An Enum for the different stages of an application
14+
class ApplicationStage:
15+
PRODUCTION = "production"
16+
EVALUATION = "evaluation"
1317

1418
class Client(object):
1519

@@ -80,11 +84,13 @@ def application(self, name, model, stage, app_type, metadata=None):
8084
Gets or creates an Application object.
8185
:param name: The name of the model
8286
:param model: An MLModel object
83-
:param stage: The stage of the application. Should be either "production" or "experimentation"
87+
:param stage: The stage of the application. Should be either "production" or "evaluation"
8488
:param app_type: The type of the application
8589
:param metadata: The metadata associated with the model
8690
"""
8791
headers = self.create_header()
92+
if stage.lower() not in ['production', 'evaluation']:
93+
raise Exception("Invalid stage specified. Should be either 'production' or 'evaluation'")
8894
data = {
8995
"name": name,
9096
"model_name": model.name,
@@ -173,8 +179,8 @@ def create_dataset(self, name, file_path, description):
173179
dataset = get_request('{}/v1/dataset'.format(AIMON_SDK_BACKEND_URL), headers=headers,
174180
params={'name': name})
175181
if dataset:
176-
return Dataset(dataset['name'], dataset['description'], dataset['creation_time'],
177-
dataset['last_updated_time'], dataset['s3_location'], dataset['sha'], dataset['user_id'])
182+
return Dataset(self.api_key, dataset['name'], dataset['description'], dataset['creation_time'],
183+
dataset['last_updated_time'], dataset['sha'], dataset['user_id'])
178184

179185
# Dataset does not exist, create a new one
180186
if not file_path:

examples/notebooks/aimon_sdk_langchain_summarization.ipynb

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"source": [
3030
"# Create the AIMon client. You would need an API Key (that can be retrieved from the UI in your user profile). \n",
3131
"# Your user email is also needed to track ownership of components such as datasets and applications.\n",
32-
"aimon_client = Client(api_key=\"YOUR API KEY HERE\", email=\"YOUR EMAIL ADDRESS HERE\")"
32+
"aimon_client = Client(api_key=\"YOUR AIMon API KEY HERE\", email=\"YOUR EMAIL ID HERE\")"
3333
]
3434
},
3535
{
@@ -52,7 +52,7 @@
5252
"name": "stdout",
5353
"output_type": "stream",
5454
"text": [
55-
"['GPT-4']\n"
55+
"['GPT-4', 'Llama-2', 'model_type']\n"
5656
]
5757
}
5858
],
@@ -92,16 +92,17 @@
9292
},
9393
{
9494
"cell_type": "code",
95-
"execution_count": 6,
95+
"execution_count": 5,
9696
"id": "22794a7c-8193-4c10-b633-fe4d0d4277d0",
9797
"metadata": {},
9898
"outputs": [],
9999
"source": [
100+
"from aimon import ApplicationStage\n",
100101
"# Using the AIMon client, create or get an existing application\n",
101102
"new_app = aimon_client.application(\n",
102103
" \"my_llm_summarization_app\", \n",
103104
" my_model, \n",
104-
" stage=\"experimentation\", \n",
105+
" stage=ApplicationStage.EVALUATION, \n",
105106
" app_type=\"summarization\", \n",
106107
" metadata={\"applicaiton_url\": \"https://acme.com/summarization\"}\n",
107108
")"
@@ -119,7 +120,7 @@
119120
},
120121
{
121122
"cell_type": "code",
122-
"execution_count": 8,
123+
"execution_count": 6,
123124
"id": "af98abfc-c04d-4cc7-ba3c-62f550de0c99",
124125
"metadata": {},
125126
"outputs": [],
@@ -177,19 +178,19 @@
177178
},
178179
{
179180
"cell_type": "code",
180-
"execution_count": 9,
181+
"execution_count": 7,
181182
"id": "34881793-3778-4114-8066-7c41cfb6d462",
182183
"metadata": {},
183184
"outputs": [],
184185
"source": [
185186
"# Create a new dataset\n",
186-
"# dataset1 = aimon_client.create_dataset(\"test_evaluation_dataset_1.csv\", \"./aimon_sdk_files/test_evaluation_dataset_1.csv\", \"This is one custom dataset\")\n",
187-
"# dataset2 = aimon_client.create_dataset(\"test_evaluation_dataset_2.csv\", \"./aimon_sdk_files/test_evaluation_dataset_2.csv\", \"This is another custom dataset\")"
187+
"dataset1 = aimon_client.create_dataset(\"test_evaluation_dataset_1.csv\", \"/Users/preetamjoshi/Downloads/test_evaluation_dataset_1.csv\", \"This is one custom dataset\")\n",
188+
"dataset2 = aimon_client.create_dataset(\"test_evaluation_dataset_2.csv\", \"/Users/preetamjoshi/Downloads/test_evaluation_dataset_2.csv\", \"This is another custom dataset\")"
188189
]
189190
},
190191
{
191192
"cell_type": "code",
192-
"execution_count": 10,
193+
"execution_count": 8,
193194
"id": "c7cc2795-6010-479a-90c0-bd275589f0cf",
194195
"metadata": {},
195196
"outputs": [],
@@ -210,7 +211,7 @@
210211
},
211212
{
212213
"cell_type": "code",
213-
"execution_count": 11,
214+
"execution_count": 9,
214215
"id": "0dbceabd-a6a2-4671-959d-ca15025841b1",
215216
"metadata": {},
216217
"outputs": [],
@@ -235,7 +236,7 @@
235236
},
236237
{
237238
"cell_type": "code",
238-
"execution_count": 12,
239+
"execution_count": 10,
239240
"id": "0f7991bf-a7b5-42f6-9a45-08c66c98d41c",
240241
"metadata": {},
241242
"outputs": [],
@@ -259,7 +260,7 @@
259260
},
260261
{
261262
"cell_type": "code",
262-
"execution_count": 13,
263+
"execution_count": 11,
263264
"id": "7b76a493-8738-40ba-a722-e22425c37e1f",
264265
"metadata": {},
265266
"outputs": [],
@@ -274,17 +275,17 @@
274275
},
275276
{
276277
"cell_type": "code",
277-
"execution_count": 14,
278+
"execution_count": 12,
278279
"id": "c2706102-672d-4e11-b77b-c1110a31772f",
279280
"metadata": {},
280281
"outputs": [
281282
{
282283
"name": "stderr",
283284
"output_type": "stream",
284285
"text": [
285-
"/Users/preetamjoshi/projects/aimon/aimon/datascience/aimon_dev/lib/python3.10/site-packages/langchain_core/_api/deprecation.py:117: LangChainDeprecationWarning: The class `langchain_community.llms.openai.OpenAI` was deprecated in langchain-community 0.0.10 and will be removed in 0.2.0. An updated version of the class exists in the langchain-openai package and should be used instead. To use it run `pip install -U langchain-openai` and import as `from langchain_openai import OpenAI`.\n",
286+
"/Users/preetamjoshi/projects/aimon/aimon-rely/artry/lib/python3.9/site-packages/langchain_core/_api/deprecation.py:119: LangChainDeprecationWarning: The class `OpenAI` was deprecated in LangChain 0.0.10 and will be removed in 0.3.0. An updated version of the class exists in the langchain-openai package and should be used instead. To use it run `pip install -U langchain-openai` and import as `from langchain_openai import OpenAI`.\n",
286287
" warn_deprecated(\n",
287-
"/Users/preetamjoshi/projects/aimon/aimon/datascience/aimon_dev/lib/python3.10/site-packages/langchain_core/_api/deprecation.py:117: LangChainDeprecationWarning: The function `run` was deprecated in LangChain 0.1.0 and will be removed in 0.2.0. Use invoke instead.\n",
288+
"/Users/preetamjoshi/projects/aimon/aimon-rely/artry/lib/python3.9/site-packages/langchain_core/_api/deprecation.py:119: LangChainDeprecationWarning: The method `Chain.run` was deprecated in langchain 0.1.0 and will be removed in 0.3.0. Use invoke instead.\n",
288289
" warn_deprecated(\n"
289290
]
290291
},
@@ -332,7 +333,7 @@
332333
},
333334
{
334335
"cell_type": "code",
335-
"execution_count": 12,
336+
"execution_count": 15,
336337
"id": "bb81a8ad-e10a-43f5-9682-844d9ab2ccb4",
337338
"metadata": {},
338339
"outputs": [],
@@ -352,7 +353,7 @@
352353
},
353354
{
354355
"cell_type": "code",
355-
"execution_count": 13,
356+
"execution_count": 16,
356357
"id": "1e0dc9d7-e0b0-4a05-8967-0e06179486a3",
357358
"metadata": {},
358359
"outputs": [
@@ -394,7 +395,7 @@
394395
"name": "python",
395396
"nbconvert_exporter": "python",
396397
"pygments_lexer": "ipython3",
397-
"version": "3.10.13"
398+
"version": "3.9.0"
398399
}
399400
},
400401
"nbformat": 4,

0 commit comments

Comments
 (0)