-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathtest_v2_client.py
More file actions
66 lines (55 loc) · 1.87 KB
/
test_v2_client.py
File metadata and controls
66 lines (55 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# # pylint: disable=missing-function-docstring
# import os
# import scaleapi
# from scaleapi.exceptions import (
# ScaleResourceNotFound,
# )
# from scaleapi.tasks import TaskType
# # The test project needs to be setup before running these tests
# # Alternatively, you can use an existing project
# TEST_PROJECT_NAME = "scaleapi-python-sdk-v2-test"
# try:
# print(f"SDK Version: {scaleapi.__version__}")
# test_api_key = os.environ["SCALE_TEST_API_KEY"]
# if test_api_key.startswith("test_") or \
# test_api_key.endswith("|test"):
# client = scaleapi.ScaleClient(test_api_key, "pytest")
# else:
# raise Exception("Please provide a valid"
# + "TEST environment key.")
# except KeyError as err:
# raise Exception(
# "Please set the environment variable"
# + "SCALE_TEST_API_KEY to run tests."
# ) from err
# try:
# project = client.get_project(TEST_PROJECT_NAME)
# except ScaleResourceNotFound:
# res = client.create_project(project_name=TEST_PROJECT_NAME, \
# task_type=TaskType.Chat)
# def make_a_chat_task():
# args = {
# "project": TEST_PROJECT_NAME,
# "instruction": "Task instructions.",
# "params": {
# "before": [],
# "turn": [],
# "after": [],
# },
# "template_variables": {
# "some_key": "some_value",
# "languageCode": "en_US",
# },
# }
# return client.create_task(TaskType.Chat, **args)
# def test_v2_get_tasks():
# new_task = make_a_chat_task()
# tasks = client.v2_get_tasks(
# project_name=TEST_PROJECT_NAME,
# )
# task_ids = {task.task_id for task in tasks}
# assert new_task.id in task_ids
# def test_v2_get_task():
# new_task = make_a_chat_task()
# task = client.v2.get_task(task_id=new_task.id)
# assert task.task_id == new_task.id