Spaces:
Sleeping
Sleeping
Commit
·
f3a0d02
1
Parent(s):
5dc0abf
Add dynamic components in the Infrastructure tab
Browse files- config.py +1 -1
- services/huggingface.py +32 -9
- services/json_generator.py +32 -27
- ui/form_components.py +43 -7
config.py
CHANGED
@@ -10,7 +10,7 @@ OBLIGATORY_FIELDS = [
|
|
10 |
"taskType", "taskFamily", "taskStage", "algorithmName", "dataType",
|
11 |
"volume", "volumeUnit", "nbRequest", "measurementMethod", "unit",
|
12 |
"powerConsumption", "os", "language", "infraType", "componentName",
|
13 |
-
"nbComponent", "country", "hashAlgorithm", "cryptographicAlgorithm", "
|
14 |
]
|
15 |
|
16 |
# Dropdown Options
|
|
|
10 |
"taskType", "taskFamily", "taskStage", "algorithmName", "dataType",
|
11 |
"volume", "volumeUnit", "nbRequest", "measurementMethod", "unit",
|
12 |
"powerConsumption", "os", "language", "infraType", "componentName",
|
13 |
+
"nbComponent", "country", "hashAlgorithm", "cryptographicAlgorithm", "ecryptedValue"
|
14 |
]
|
15 |
|
16 |
# Dropdown Options
|
services/huggingface.py
CHANGED
@@ -53,7 +53,6 @@ def create_flattened_data(data):
|
|
53 |
|
54 |
# Handle inference properties
|
55 |
inference_props = data.get("task", {}).get("dataset", [{}])[0].get("inferenceProperties", [])
|
56 |
-
print("Extracted inference properties:", inference_props)
|
57 |
|
58 |
# Process inference properties
|
59 |
inference_data = []
|
@@ -76,6 +75,30 @@ def create_flattened_data(data):
|
|
76 |
nbWordsOutput_str = ", ".join([str(p["nbWordsOutput"]) for p in inference_data if p.get("nbWordsOutput")]) if inference_data else None
|
77 |
contextWindowSize_str = ", ".join([str(p["contextWindowSize"]) for p in inference_data if p.get("contextWindowSize")]) if inference_data else None
|
78 |
cache_str = ", ".join([str(p["cache"]) for p in inference_data if p.get("cache")]) if inference_data else None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
return {
|
80 |
# Header
|
81 |
"licensing": [data["header"]["licensing"]],
|
@@ -150,13 +173,13 @@ def create_flattened_data(data):
|
|
150 |
"infraType": [data["infrastructure"]["infraType"]],
|
151 |
"cloudProvider": [data["infrastructure"]["cloudProvider"]],
|
152 |
"cloudInstance": [data["infrastructure"]["cloudInstance"]],
|
153 |
-
"componentName": [
|
154 |
-
"nbComponent": [
|
155 |
-
"memorySize": [
|
156 |
-
"manufacturer_infra": [
|
157 |
-
"family": [
|
158 |
-
"series": [
|
159 |
-
"share": [
|
160 |
|
161 |
# Environment
|
162 |
"country": [data["environment"]["country"]],
|
@@ -173,5 +196,5 @@ def create_flattened_data(data):
|
|
173 |
# Hash
|
174 |
"hashAlgorithm": [data["$hash"]["hashAlgorithm"]],
|
175 |
"cryptographicAlgorithm": [data["$hash"]["cryptographicAlgorithm"]],
|
176 |
-
"value": [data["$hash"]["
|
177 |
}
|
|
|
53 |
|
54 |
# Handle inference properties
|
55 |
inference_props = data.get("task", {}).get("dataset", [{}])[0].get("inferenceProperties", [])
|
|
|
56 |
|
57 |
# Process inference properties
|
58 |
inference_data = []
|
|
|
75 |
nbWordsOutput_str = ", ".join([str(p["nbWordsOutput"]) for p in inference_data if p.get("nbWordsOutput")]) if inference_data else None
|
76 |
contextWindowSize_str = ", ".join([str(p["contextWindowSize"]) for p in inference_data if p.get("contextWindowSize")]) if inference_data else None
|
77 |
cache_str = ", ".join([str(p["cache"]) for p in inference_data if p.get("cache")]) if inference_data else None
|
78 |
+
|
79 |
+
# Handle components
|
80 |
+
components = data.get("infrastructure", {}).get("components", [])
|
81 |
+
component_data = []
|
82 |
+
for comp in components:
|
83 |
+
if comp:
|
84 |
+
component_data.append({
|
85 |
+
"componentName": comp.get("componentName"),
|
86 |
+
"nbComponent": comp.get("nbComponent"),
|
87 |
+
"memorySize": comp.get("memorySize"),
|
88 |
+
"manufacturer": comp.get("manufacturer"),
|
89 |
+
"family": comp.get("family"),
|
90 |
+
"series": comp.get("series"),
|
91 |
+
"share": comp.get("share")
|
92 |
+
})
|
93 |
+
|
94 |
+
componentName_str = ", ".join([str(p["componentName"]) for p in component_data if p.get("componentName")]) if component_data else None
|
95 |
+
nbComponent_str = ", ".join([str(p["nbComponent"]) for p in component_data if p.get("nbComponent")]) if component_data else None
|
96 |
+
memorySize_str = ", ".join([str(p["memorySize"]) for p in component_data if p.get("memorySize")]) if component_data else None
|
97 |
+
manufacturer_infra_str = ", ".join([str(p["manufacturer"]) for p in component_data if p.get("manufacturer")]) if component_data else None
|
98 |
+
family_str = ", ".join([str(p["family"]) for p in component_data if p.get("family")]) if component_data else None
|
99 |
+
series_str = ", ".join([str(p["series"]) for p in component_data if p.get("series")]) if component_data else None
|
100 |
+
share_str = ", ".join([str(p["share"]) for p in component_data if p.get("share")]) if component_data else None
|
101 |
+
|
102 |
return {
|
103 |
# Header
|
104 |
"licensing": [data["header"]["licensing"]],
|
|
|
173 |
"infraType": [data["infrastructure"]["infraType"]],
|
174 |
"cloudProvider": [data["infrastructure"]["cloudProvider"]],
|
175 |
"cloudInstance": [data["infrastructure"]["cloudInstance"]],
|
176 |
+
"componentName": [componentName_str],
|
177 |
+
"nbComponent": [nbComponent_str],
|
178 |
+
"memorySize": [memorySize_str],
|
179 |
+
"manufacturer_infra": [manufacturer_infra_str],
|
180 |
+
"family": [family_str],
|
181 |
+
"series": [series_str],
|
182 |
+
"share": [share_str],
|
183 |
|
184 |
# Environment
|
185 |
"country": [data["environment"]["country"]],
|
|
|
196 |
# Hash
|
197 |
"hashAlgorithm": [data["$hash"]["hashAlgorithm"]],
|
198 |
"cryptographicAlgorithm": [data["$hash"]["cryptographicAlgorithm"]],
|
199 |
+
"value": [data["$hash"]["ecryptedValue"]]
|
200 |
}
|
services/json_generator.py
CHANGED
@@ -32,24 +32,39 @@ def generate_json(
|
|
32 |
"""Generate JSON data from form inputs."""
|
33 |
# Process hyperparameters
|
34 |
hyperparameters = []
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
# Process inference properties
|
43 |
inference_props_list = []
|
44 |
-
|
|
|
45 |
inference_props_list.append({
|
46 |
-
"nbRequest": nbRequest[i],
|
47 |
-
"nbTokensInput": nbTokensInput[i],
|
48 |
-
"nbWordsInput": nbWordsInput[i],
|
49 |
-
"nbTokensOutput": nbTokensOutput[i],
|
50 |
-
"nbWordsOutput": nbWordsOutput[i],
|
51 |
-
"contextWindowSize": contextWindowSize[i],
|
52 |
-
"cache": cache[i]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
})
|
54 |
|
55 |
data = {
|
@@ -137,17 +152,7 @@ def generate_json(
|
|
137 |
"infraType": infraType,
|
138 |
"cloudProvider": cloudProvider,
|
139 |
"cloudInstance": cloudInstance,
|
140 |
-
"components":
|
141 |
-
{
|
142 |
-
"componentName": componentName,
|
143 |
-
"nbComponent": nbComponent,
|
144 |
-
"memorySize": memorySize,
|
145 |
-
"manufacturer": manufacturer_infra,
|
146 |
-
"family": family,
|
147 |
-
"series": series,
|
148 |
-
"share": share
|
149 |
-
}
|
150 |
-
]
|
151 |
},
|
152 |
"environment": {
|
153 |
"country": country,
|
@@ -162,7 +167,7 @@ def generate_json(
|
|
162 |
"$hash": {
|
163 |
"hashAlgorithm": hashAlgorithm,
|
164 |
"cryptographicAlgorithm": cryptographicAlgorithm,
|
165 |
-
"
|
166 |
}
|
167 |
}
|
168 |
|
|
|
32 |
"""Generate JSON data from form inputs."""
|
33 |
# Process hyperparameters
|
34 |
hyperparameters = []
|
35 |
+
max_length = max(len(hyperparameter_names), len(hyperparameter_values))
|
36 |
+
for i in range(max_length):
|
37 |
+
hyperparameters.append({
|
38 |
+
"name": hyperparameter_names[i] if i < len(hyperparameter_names) and hyperparameter_names[i] else "",
|
39 |
+
"value": hyperparameter_values[i] if i < len(hyperparameter_values) and hyperparameter_values[i] else ""
|
40 |
+
})
|
41 |
+
|
42 |
# Process inference properties
|
43 |
inference_props_list = []
|
44 |
+
max_length = max(len(nbRequest), len(nbTokensInput), len(nbWordsInput), len(nbTokensOutput), len(nbWordsOutput), len(contextWindowSize), len(cache))
|
45 |
+
for i in range(max_length):
|
46 |
inference_props_list.append({
|
47 |
+
"nbRequest": nbRequest[i] if i < len(nbRequest) and nbRequest[i] else "",
|
48 |
+
"nbTokensInput": nbTokensInput[i] if i < len(nbTokensInput) and nbTokensInput[i] else "",
|
49 |
+
"nbWordsInput": nbWordsInput[i] if i < len(nbWordsInput) and nbWordsInput[i] else "",
|
50 |
+
"nbTokensOutput": nbTokensOutput[i] if i < len(nbTokensOutput) and nbTokensOutput[i] else "",
|
51 |
+
"nbWordsOutput": nbWordsOutput[i] if i < len(nbWordsOutput) and nbWordsOutput[i] else "",
|
52 |
+
"contextWindowSize": contextWindowSize[i] if i < len(contextWindowSize) and contextWindowSize[i] else "",
|
53 |
+
"cache": cache[i] if i < len(cache) and cache[i] else ""
|
54 |
+
})
|
55 |
+
|
56 |
+
# Process components
|
57 |
+
components_list = []
|
58 |
+
max_length = max(len(componentName), len(nbComponent), len(memorySize), len(manufacturer_infra), len(family), len(series), len(share))
|
59 |
+
for i in range(max_length):
|
60 |
+
components_list.append({
|
61 |
+
"componentName": componentName[i] if i < len(componentName) and componentName[i] else "",
|
62 |
+
"nbComponent": nbComponent[i] if i < len(nbComponent) and nbComponent[i] else "",
|
63 |
+
"memorySize": memorySize[i] if i < len(memorySize) and memorySize[i] else "",
|
64 |
+
"manufacturer": manufacturer_infra[i] if i < len(manufacturer_infra) and manufacturer_infra[i] else "",
|
65 |
+
"family": family[i] if i < len(family) and family[i] else "",
|
66 |
+
"series": series[i] if i < len(series) and series[i] else "",
|
67 |
+
"share": share[i] if i < len(share) and share[i] else ""
|
68 |
})
|
69 |
|
70 |
data = {
|
|
|
152 |
"infraType": infraType,
|
153 |
"cloudProvider": cloudProvider,
|
154 |
"cloudInstance": cloudInstance,
|
155 |
+
"components": components_list
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
},
|
157 |
"environment": {
|
158 |
"country": country,
|
|
|
167 |
"$hash": {
|
168 |
"hashAlgorithm": hashAlgorithm,
|
169 |
"cryptographicAlgorithm": cryptographicAlgorithm,
|
170 |
+
"ecryptedValue": value_hash
|
171 |
}
|
172 |
}
|
173 |
|
ui/form_components.py
CHANGED
@@ -280,13 +280,49 @@ def create_infrastructure_tab():
|
|
280 |
)
|
281 |
cloudProvider = gr.Textbox(label="Cloud Provider", info="(name of your cloud provider)")
|
282 |
cloudInstance = gr.Textbox(label="Cloud Instance", info="(name of your cloud instance)")
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
|
291 |
return [
|
292 |
infraType, cloudProvider, cloudInstance, componentName,
|
|
|
280 |
)
|
281 |
cloudProvider = gr.Textbox(label="Cloud Provider", info="(name of your cloud provider)")
|
282 |
cloudInstance = gr.Textbox(label="Cloud Instance", info="(name of your cloud instance)")
|
283 |
+
with gr.Accordion("Components"):
|
284 |
+
_, componentName, nbComponent, memorySize, manufacturer_infra, family, series, share, add_component_btn = create_dynamic_section(
|
285 |
+
section_name="Component",
|
286 |
+
fields_config=[
|
287 |
+
{
|
288 |
+
"type": gr.Textbox,
|
289 |
+
"label": "Component Name",
|
290 |
+
"info": "Required field<br>(type of subsystem part)",
|
291 |
+
},
|
292 |
+
{
|
293 |
+
"type": gr.Textbox,
|
294 |
+
"label": "Number of Components",
|
295 |
+
"info": "Required field<br>(number of items of this component)",
|
296 |
+
},
|
297 |
+
{
|
298 |
+
"type": gr.Textbox,
|
299 |
+
"label": "Memory Size",
|
300 |
+
"info": "(size of memory in Gbytes)",
|
301 |
+
},
|
302 |
+
{
|
303 |
+
"type": gr.Textbox,
|
304 |
+
"label": "Manufacturer",
|
305 |
+
"info": "(name of the manufacturer)",
|
306 |
+
},
|
307 |
+
{
|
308 |
+
"type": gr.Textbox,
|
309 |
+
"label": "Family",
|
310 |
+
"info": "(family of this component)",
|
311 |
+
},
|
312 |
+
{
|
313 |
+
"type": gr.Textbox,
|
314 |
+
"label": "Series",
|
315 |
+
"info": "(series of this component)",
|
316 |
+
},
|
317 |
+
{
|
318 |
+
"type": gr.Textbox,
|
319 |
+
"label": "Share",
|
320 |
+
"info": "(percentage of equipment used)",
|
321 |
+
}
|
322 |
+
],
|
323 |
+
initial_count=0,
|
324 |
+
layout="column"
|
325 |
+
)
|
326 |
|
327 |
return [
|
328 |
infraType, cloudProvider, cloudInstance, componentName,
|