Skip to content

Commit 9f6d478

Browse files
committed
oracleReport
1 parent d2f8b58 commit 9f6d478

File tree

4 files changed

+726
-84
lines changed

4 files changed

+726
-84
lines changed

appTemplate.html

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -116,54 +116,7 @@ <h4> copyright Marxvim 2023</h4>
116116

117117
// full ZingChart schema can be found here:
118118
// https://www.zingchart.com/docs/api/json-configuration/
119-
let chartData = [{
120-
id: 'theworld',
121-
parent: '',
122-
name: 'Node: 6 \nType: Alpha \nAccuracy: 0.86'
123-
},
124-
{
125-
id: 'asia',
126-
parent: 'theworld',
127-
name: 'Penrose Node',
128-
value: 4100000000
129-
},
130-
{
131-
id: 'africa',
132-
parent: 'theworld',
133-
name: 'Gpt Node',
134-
value: 1260000000
135-
},
136-
{
137-
id: 'america',
138-
parent: 'theworld',
139-
name: 'Malta Node',
140-
value: 328000000
141-
},
142-
{
143-
id: 'europe',
144-
parent: 'theworld',
145-
name: 'Europe',
146-
value: 741000000
147-
},
148-
{
149-
id: 'ca',
150-
parent: 'africa',
151-
name: 'California',
152-
value: 32000000
153-
},
154-
{
155-
id: 'ny',
156-
parent: 'america',
157-
name: 'New York',
158-
value: 19000000
159-
},
160-
{
161-
id: 'txt',
162-
parent: 'america',
163-
name: 'Texas',
164-
value: 29000000
165-
},
166-
];
119+
let chartData = cluster_map;
167120
let chartConfigLine = {
168121
type: 'line',
169122
backgroundColor: '#2f2b3f',

oas.ipynb

Lines changed: 157 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,68 +2,189 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 2,
5+
"execution_count": null,
66
"id": "517be871-a02b-40b2-9ef7-c1d4723df1d0",
77
"metadata": {
88
"tags": []
99
},
10+
"outputs": [],
11+
"source": [
12+
"from IPython.core.display import display, HTML\n",
13+
"from bs4 import BeautifulSoup as bs\n",
14+
"import os\n",
15+
"import re\n",
16+
"import codecs"
17+
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": 1,
22+
"id": "517822cc-ea03-4e7f-a726-5d67c126ff10",
23+
"metadata": {
24+
"tags": []
25+
},
1026
"outputs": [
1127
{
12-
"name": "stderr",
13-
"output_type": "stream",
14-
"text": [
15-
"/tmp/ipykernel_1621/599365976.py:1: DeprecationWarning: Importing display from IPython.core.display is deprecated since IPython 7.14, please import from IPython display\n",
16-
" from IPython.core.display import display, HTML\n"
28+
"ename": "SyntaxError",
29+
"evalue": "unterminated string literal (detected at line 14) (513320101.py, line 14)",
30+
"output_type": "error",
31+
"traceback": [
32+
"\u001b[0;36m Cell \u001b[0;32mIn[1], line 14\u001b[0;36m\u001b[0m\n\u001b[0;31m template_cluster_map = parsed_template_cluster_map.replace(\"'id', \"id\")\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m unterminated string literal (detected at line 14)\n"
1733
]
1834
}
1935
],
2036
"source": [
21-
"from IPython.core.display import display, HTML"
37+
"class Oracle:\n",
38+
" def __init__(self, access = 'offline',\n",
39+
" node_map = '',\n",
40+
" node_profile = '',\n",
41+
" node_weights = []):\n",
42+
" self.access = access,\n",
43+
" self.node_map = node_map\n",
44+
" self.node_profile = node_profile\n",
45+
" self.node_weights = node_weights\n",
46+
" #print('\\n-> configured oracle')\n",
47+
" \n",
48+
" def template_parser(self):\n",
49+
" parsed_template_cluster_map = str(self.generate_map())\n",
50+
" template_cluster_map = parsed_template_cluster_map.replace(\"'id'\", \"id\").replace(\"'parent'\", \"parent\").replace(\"'name'\", \"name\").replace(\"'value'\", \"value\")\n",
51+
" template_script = codecs.open(\"./appTemplate.html\", 'r')\n",
52+
" oracle_script = codecs.open(\"./oracleReport.html\", 'w')\n",
53+
" html = template_script.read()\n",
54+
" parsed_script = html.replace('cluster_map', template_cluster_map)\n",
55+
" oracle_script.write(parsed_script)\n",
56+
" \n",
57+
" #soup = bs(html, 'html.parser')\n",
58+
" #parsed_script = soup.find_all('script')\n",
59+
" #parsed_script[1] = parsed_script[1].text.replace('cluster_map', template_cluster_map)\n",
60+
" #soup.find_all('script').replace_with(parsed_script)\n",
61+
" #help(soup.find_all('script'))\n",
62+
" #.replace_with(template_cluster_map)\n",
63+
" \n",
64+
" return parsed_script\n",
65+
" \n",
66+
" def get_model_type(self, model_id):\n",
67+
" if model_id == 1:\n",
68+
" return 'gant'\n",
69+
" elif model_id == 2:\n",
70+
" return 'gan' \n",
71+
" elif model_id == 3:\n",
72+
" return 'cnnt' \n",
73+
" elif model_id == 4:\n",
74+
" return 'cnn'\n",
75+
" elif model_id == 5:\n",
76+
" return 'gpt'\n",
77+
" elif model_id == 6:\n",
78+
" return 'dalle' \n",
79+
" elif model_id == 7:\n",
80+
" return 'malta'\n",
81+
" else:\n",
82+
" return 'yolo'\n",
83+
" \n",
84+
" def get_model_names(self):\n",
85+
" models = []\n",
86+
" for index in range(len(self.node_profile)):\n",
87+
" node_id = int(self.node_profile[index])\n",
88+
" models.append(self.get_model_type(node_id))\n",
89+
" models.append('alpha')\n",
90+
" return models\n",
91+
" \n",
92+
" \n",
93+
" \n",
94+
" def generate_map(self):\n",
95+
" node_cluster_map = []\n",
96+
" model_names = self.get_model_names()\n",
97+
" node_weights = self.node_weights\n",
98+
" \n",
99+
" for node in range(len(self.node_profile)):\n",
100+
" weights = node_weights[node]\n",
101+
" for index in range(len(weights)):\n",
102+
" model_id = model_names[node]+str(index)\n",
103+
" weight = int(weights[index])\n",
104+
" parent = model_names[weight]+str(0)\n",
105+
" description = model_names[node]\n",
106+
" \n",
107+
" node_map = {'id': model_id, \n",
108+
" 'parent': parent,\n",
109+
" 'name': description,\n",
110+
" 'value': 741000000\n",
111+
" }\n",
112+
" node_cluster_map.append(node_map)\n",
113+
" node_map = {'id': 'alpha0', \n",
114+
" 'parent': '',\n",
115+
" 'name': 'alpha'}\n",
116+
" node_cluster_map.append(node_map)\n",
117+
" \n",
118+
" return node_cluster_map\n",
119+
" \n",
120+
" \n",
121+
" \n",
122+
" return self.node_map\n",
123+
" \n",
124+
" def set_node(self, node_number, model_path):\n",
125+
" #set node\n",
126+
" return none \n",
127+
" \n",
128+
" def train(self):\n",
129+
" #train model\n",
130+
" return none\n",
131+
" \n",
132+
" def optimize(self):\n",
133+
" #optimize model\n",
134+
" return none\n",
135+
" \n",
136+
" def run(self, oracle_data):\n",
137+
" #magic\n",
138+
" return none\n",
139+
" \n",
140+
" "
22141
]
23142
},
24143
{
25144
"cell_type": "code",
26145
"execution_count": null,
27-
"id": "517822cc-ea03-4e7f-a726-5d67c126ff10",
146+
"id": "a6703cd5-699a-4f30-a1bb-3c8dd10d5952",
28147
"metadata": {},
29148
"outputs": [],
30-
"source": []
149+
"source": [
150+
"# engine = oracle()\n",
151+
"# engine.template_parser()"
152+
]
153+
},
154+
{
155+
"cell_type": "code",
156+
"execution_count": null,
157+
"id": "4c430313-2553-48d5-8ae2-ca12e56fa2d2",
158+
"metadata": {},
159+
"outputs": [],
160+
"source": [
161+
"\n",
162+
" # Give location where text is\n",
163+
" # stored which you wish to alter\n",
164+
"# old_text = soup.find(\"p\", {\"id\": \"para\"})\n",
165+
"\n",
166+
"# # Replace the already stored text with\n",
167+
"# # the new text which you wish to assign\n",
168+
"# new_text = old_text.find(text=re.compile(\n",
169+
"# 'Geeks For Geeks')).replace_with('Vinayak Rai')\n",
170+
"\n",
171+
"# # Alter HTML file to see the changes done\n",
172+
"# with open(\"gfg.html\", \"wb\") as f_output:\n",
173+
"# f_output.write(soup.prettify(\"utf-8\"))"
174+
]
31175
},
32176
{
33177
"cell_type": "code",
34-
"execution_count": 10,
178+
"execution_count": null,
35179
"id": "7558603e-e170-4e36-8b51-1117f4ff9d0a",
36180
"metadata": {
37181
"tags": []
38182
},
39-
"outputs": [
40-
{
41-
"data": {
42-
"text/html": [
43-
"\n",
44-
" <iframe\n",
45-
" width=\"1200\"\n",
46-
" height=\"1000\"\n",
47-
" src=\"./appTemplate.html\"\n",
48-
" frameborder=\"0\"\n",
49-
" allowfullscreen\n",
50-
" \n",
51-
" ></iframe>\n",
52-
" "
53-
],
54-
"text/plain": [
55-
"<IPython.lib.display.IFrame at 0x7f54c6dfba00>"
56-
]
57-
},
58-
"execution_count": 10,
59-
"metadata": {},
60-
"output_type": "execute_result"
61-
}
62-
],
183+
"outputs": [],
63184
"source": [
64-
"from IPython.display import IFrame\n",
185+
"# from IPython.display import IFrame\n",
65186
"\n",
66-
"IFrame(src='./appTemplate.html', width=1200, height=1000)"
187+
"# IFrame(src='./appTemplate.html', width=1200, height=1000)"
67188
]
68189
},
69190
{

0 commit comments

Comments
 (0)