Initial lists populated with pre-defined quality attributes and QA categories.
Source code in mlte/store/custom_list/initial_custom_lists.py
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
67 | class InitialCustomLists:
"""Initial lists populated with pre-defined quality attributes and QA categories."""
DEFAULT_STORES_FOLDER = "stores"
"""Default root folder for all built-in stores."""
@staticmethod
def setup_custom_list_store(
stores_uri: StoreURI,
) -> CustomListStore:
"""
Sets up a custom list store with the initial custom lists.
:param stores_uri: The URI of the store being used (i.e., base folder, base DB, etc).
:return: A custom list store populated with the initial entries.
"""
# Create the initial custom lists.
print(f"Creating initial custom lists at URI: {stores_uri}")
custom_list_store = create_custom_list_store(stores_uri.uri)
with ManagedCustomListSession(custom_list_store.session()) as session:
num_categories = 0
for json_data in get_json_resources(qa_category_entries):
entry = CustomListEntryModel(**json_data)
try:
session.custom_list_entry_mapper.create(
entry, CustomListName.QA_CATEGORIES
)
except error.ErrorAlreadyExists:
# If default values are already there we dont want to overwrite any changes
pass
num_categories += 1
print(f"Loaded {num_categories} QA Categories for initial list")
# Input all initial Quality Attribute entries
num_attributes = 0
for json_data in get_json_resources(quality_attribute_entries):
entry = CustomListEntryModel(**json_data)
try:
session.custom_list_entry_mapper.create(
entry, CustomListName.QUALITY_ATTRIBUTES
)
except error.ErrorAlreadyExists:
# If default values are already there we dont want to overwrite any changes
pass
num_attributes += 1
print(
f"Loaded {num_attributes} Quality Attributes for initial list"
)
return custom_list_store
|
DEFAULT_STORES_FOLDER = 'stores'
class-attribute
instance-attribute
Default root folder for all built-in stores.
setup_custom_list_store(stores_uri)
staticmethod
Sets up a custom list store with the initial custom lists.
Parameters:
Name |
Type |
Description |
Default |
stores_uri
|
StoreURI
|
The URI of the store being used (i.e., base folder, base DB, etc).
|
required
|
Returns:
Type |
Description |
CustomListStore
|
A custom list store populated with the initial entries.
|
Source code in mlte/store/custom_list/initial_custom_lists.py
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
67 | @staticmethod
def setup_custom_list_store(
stores_uri: StoreURI,
) -> CustomListStore:
"""
Sets up a custom list store with the initial custom lists.
:param stores_uri: The URI of the store being used (i.e., base folder, base DB, etc).
:return: A custom list store populated with the initial entries.
"""
# Create the initial custom lists.
print(f"Creating initial custom lists at URI: {stores_uri}")
custom_list_store = create_custom_list_store(stores_uri.uri)
with ManagedCustomListSession(custom_list_store.session()) as session:
num_categories = 0
for json_data in get_json_resources(qa_category_entries):
entry = CustomListEntryModel(**json_data)
try:
session.custom_list_entry_mapper.create(
entry, CustomListName.QA_CATEGORIES
)
except error.ErrorAlreadyExists:
# If default values are already there we dont want to overwrite any changes
pass
num_categories += 1
print(f"Loaded {num_categories} QA Categories for initial list")
# Input all initial Quality Attribute entries
num_attributes = 0
for json_data in get_json_resources(quality_attribute_entries):
entry = CustomListEntryModel(**json_data)
try:
session.custom_list_entry_mapper.create(
entry, CustomListName.QUALITY_ATTRIBUTES
)
except error.ErrorAlreadyExists:
# If default values are already there we dont want to overwrite any changes
pass
num_attributes += 1
print(
f"Loaded {num_attributes} Quality Attributes for initial list"
)
return custom_list_store
|