| 
136 | 136 |    "source": [  | 
137 | 137 |     "def load_report(rule_name):\n",  | 
138 | 138 |     "    try:\n",  | 
139 |  | -    "        report = json.load(open('/opt/ml/processing/outputs/profiler-reports/'+rule_name+'.json'))\n",  | 
 | 139 | +    "        report = json.load(open('/opt/ml/processing/output/rule/profiler-reports/'+rule_name+'.json'))\n",  | 
140 | 140 |     "        return report\n",  | 
141 | 141 |     "    except FileNotFoundError:\n",  | 
142 | 142 |     "        print (rule_name + ' not triggered')"  | 
 | 
207 | 207 |    },  | 
208 | 208 |    "outputs": [],  | 
209 | 209 |    "source": [  | 
210 |  | -    "text =  \"\"\"The following table gives a summary about the training job. The table includes information about when the training job started and ended, how much time initialization, training loop and finalization took.\"\"\"\n",  | 
211 |  | -    "if len(job_statistics) > 0:\n",  | 
212 |  | -    "    df = pd.DataFrame.from_dict(job_statistics, orient='index')\n",  | 
213 |  | -    "    start_time = us_since_epoch_to_human_readable_time(report['Details']['job_start'] * 1000000)\n",  | 
214 |  | -    "    date = datetime.datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%S:%f')\n",  | 
215 |  | -    "    day = date.date().strftime(\"%m/%d/%Y\")\n",  | 
216 |  | -    "    hour = date.time().strftime(\"%H:%M:%S\")\n",  | 
217 |  | -    "    duration = job_duration_in_seconds\n",  | 
218 |  | -    "    text = f\"\"\"{text} \\n Your training job started on {day} at {hour} and ran for {duration} seconds.\"\"\"\n",  | 
219 |  | -    "     \n",  | 
220 |  | -    "    #pretty_print(df)\n",  | 
221 |  | -    "    if \"first\" in report['Details'][\"step_num\"] and \"last\" in report['Details'][\"step_num\"]:\n",  | 
222 |  | -    "        if finalization_perc  < 0:\n",  | 
223 |  | -    "            job_statistics[\"Finalization%\"]  = 0\n",  | 
224 |  | -    "        if training_loop_perc < 0:\n",  | 
225 |  | -    "            job_statistics[\"Training loop\"] = 0\n",  | 
226 |  | -    "        if initialization_perc < 0:\n",  | 
227 |  | -    "            job_statistics[\"Initialization\"] = 0\n",  | 
 | 210 | +    "if report:\n",  | 
 | 211 | +    "    text =  \"\"\"The following table gives a summary about the training job. The table includes information about when the training job started and ended, how much time initialization, training loop and finalization took.\"\"\"\n",  | 
 | 212 | +    "    if len(job_statistics) > 0:\n",  | 
 | 213 | +    "        df = pd.DataFrame.from_dict(job_statistics, orient='index')\n",  | 
 | 214 | +    "        start_time = us_since_epoch_to_human_readable_time(report['Details']['job_start'] * 1000000)\n",  | 
 | 215 | +    "        date = datetime.datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%S:%f')\n",  | 
 | 216 | +    "        day = date.date().strftime(\"%m/%d/%Y\")\n",  | 
 | 217 | +    "        hour = date.time().strftime(\"%H:%M:%S\")\n",  | 
 | 218 | +    "        duration = job_duration_in_seconds\n",  | 
 | 219 | +    "        text = f\"\"\"{text} \\n Your training job started on {day} at {hour} and ran for {duration} seconds.\"\"\"\n",  | 
 | 220 | +    "\n",  | 
 | 221 | +    "        #pretty_print(df)\n",  | 
 | 222 | +    "        if \"first\" in report['Details'][\"step_num\"] and \"last\" in report['Details'][\"step_num\"]:\n",  | 
 | 223 | +    "            if finalization_perc  < 0:\n",  | 
 | 224 | +    "                job_statistics[\"Finalization%\"]  = 0\n",  | 
 | 225 | +    "            if training_loop_perc < 0:\n",  | 
 | 226 | +    "                job_statistics[\"Training loop\"] = 0\n",  | 
 | 227 | +    "            if initialization_perc < 0:\n",  | 
 | 228 | +    "                job_statistics[\"Initialization\"] = 0\n",  | 
 | 229 | +    "        else:\n",  | 
 | 230 | +    "            text = f\"\"\"{text} \\n Your training job started on {day} at {hour} and ran for {duration} seconds.\"\"\"\n",  | 
 | 231 | +    "            \n",  | 
 | 232 | +    "    if len(job_statistics) > 0:\n",  | 
 | 233 | +    "        df2 = df.reset_index()\n",  | 
 | 234 | +    "        df2.columns = [\"0\", \"1\"]\n",  | 
 | 235 | +    "        source = ColumnDataSource(data=df2)\n",  | 
 | 236 | +    "        columns = [TableColumn(field='0', title=\"\"),\n",  | 
 | 237 | +    "                   TableColumn(field='1', title=\"Job Statistics\"),]\n",  | 
 | 238 | +    "        table = DataTable(source=source, columns=columns, width=450, height=380)\n",  | 
 | 239 | +    "\n",  | 
 | 240 | +    "    plot = None\n",  | 
 | 241 | +    "\n",  | 
 | 242 | +    "    if \"Initialization\" in job_statistics:\n",  | 
 | 243 | +    "        piechart_data = {}\n",  | 
 | 244 | +    "        piechart_data[\"Initialization\"] = initialization_perc  \n",  | 
 | 245 | +    "        piechart_data[\"Training loop\"]  = training_loop_perc\n",  | 
 | 246 | +    "        piechart_data[\"Finalization\"]  = finalization_perc \n",  | 
 | 247 | +    "\n",  | 
 | 248 | +    "        plot = create_piechart(piechart_data, \n",  | 
 | 249 | +    "                               height=350,\n",  | 
 | 250 | +    "                               width=500,\n",  | 
 | 251 | +    "                               x1=0.15,\n",  | 
 | 252 | +    "                               x2=0.15,\n",  | 
 | 253 | +    "                               radius=0.15, \n",  | 
 | 254 | +    "                               toolbar_location=None)\n",  | 
 | 255 | +    "\n",  | 
 | 256 | +    "    if plot != None:\n",  | 
 | 257 | +    "        paragraph = Paragraph(text=f\"\"\"{text}\"\"\", width = 800)\n",  | 
 | 258 | +    "        show(column(paragraph, row(table, plot)))\n",  | 
228 | 259 |     "    else:\n",  | 
229 |  | -    "        text = f\"\"\"{text} \\n Your training job started on {day} at {hour} and ran for {duration} seconds.\"\"\"\n"  | 
230 |  | -   ]  | 
231 |  | -  },  | 
232 |  | -  {  | 
233 |  | -   "cell_type": "code",  | 
234 |  | -   "execution_count": null,  | 
235 |  | -   "metadata": {  | 
236 |  | -    "tags": [  | 
237 |  | -     "hide-input"  | 
238 |  | -    ]  | 
239 |  | -   },  | 
240 |  | -   "outputs": [],  | 
241 |  | -   "source": [  | 
242 |  | -    "if len(job_statistics) > 0:\n",  | 
243 |  | -    "    df2 = df.reset_index()\n",  | 
244 |  | -    "    df2.columns = [\"0\", \"1\"]\n",  | 
245 |  | -    "    source = ColumnDataSource(data=df2)\n",  | 
246 |  | -    "    columns = [TableColumn(field='0', title=\"\"),\n",  | 
247 |  | -    "               TableColumn(field='1', title=\"Job Statistics\"),]\n",  | 
248 |  | -    "    table = DataTable(source=source, columns=columns, width=450, height=380)\n",  | 
249 |  | -    "\n",  | 
250 |  | -    "plot = None\n",  | 
251 |  | -    "    \n",  | 
252 |  | -    "if \"Initialization\" in job_statistics:\n",  | 
253 |  | -    "    piechart_data = {}\n",  | 
254 |  | -    "    piechart_data[\"Initialization\"] = initialization_perc  \n",  | 
255 |  | -    "    piechart_data[\"Training loop\"]  = training_loop_perc\n",  | 
256 |  | -    "    piechart_data[\"Finalization\"]  = finalization_perc \n",  | 
257 |  | -    "\n",  | 
258 |  | -    "    plot = create_piechart(piechart_data, \n",  | 
259 |  | -    "                           height=350,\n",  | 
260 |  | -    "                           width=500,\n",  | 
261 |  | -    "                           x1=0.15,\n",  | 
262 |  | -    "                           x2=0.15,\n",  | 
263 |  | -    "                           radius=0.15, \n",  | 
264 |  | -    "                           toolbar_location=None)\n",  | 
265 |  | -    "\n",  | 
266 |  | -    "if plot != None:\n",  | 
267 |  | -    "    paragraph = Paragraph(text=f\"\"\"{text}\"\"\", width = 800)\n",  | 
268 |  | -    "    show(column(paragraph, row(table, plot)))\n",  | 
269 |  | -    "else:\n",  | 
270 |  | -    "    paragraph = Paragraph(text=f\"\"\"{text}. No step information was profiled from your training job. The time spent on initialization and finalization cannot be computed.\"\"\" , width = 800)\n",  | 
271 |  | -    "    show(column(paragraph, row(table)))"  | 
 | 260 | +    "        paragraph = Paragraph(text=f\"\"\"{text}. No step information was profiled from your training job. The time spent on initialization and finalization cannot be computed.\"\"\" , width = 800)\n",  | 
 | 261 | +    "        show(column(paragraph, row(table)))"  | 
272 | 262 |    ]  | 
273 | 263 |   },  | 
274 | 264 |   {  | 
 | 
372 | 362 |     "    show(column( text1, text2, row(table)))"  | 
373 | 363 |    ]  | 
374 | 364 |   },  | 
375 |  | -  {  | 
376 |  | -   "cell_type": "code",  | 
377 |  | -   "execution_count": null,  | 
378 |  | -   "metadata": {  | 
379 |  | -    "tags": [  | 
380 |  | -     "hide-input"  | 
381 |  | -    ]  | 
382 |  | -   },  | 
383 |  | -   "outputs": [],  | 
384 |  | -   "source": [  | 
385 |  | -    "def display_image(image_name):\n",  | 
386 |  | -    "    files = glob.glob('/opt/ml/processing/outputs/profiler-reports/' + image_name)\n",  | 
387 |  | -    "    for filename in files:\n",  | 
388 |  | -    "        display(Image(filename=filename))"  | 
389 |  | -   ]  | 
390 |  | -  },  | 
391 | 365 |   {  | 
392 | 366 |    "cell_type": "code",  | 
393 | 367 |    "execution_count": null,  | 
 | 
696 | 670 |    },  | 
697 | 671 |    "outputs": [],  | 
698 | 672 |    "source": [  | 
699 |  | -    "files = glob.glob('/opt/ml/processing/outputs/profiler-reports/*json')\n",  | 
 | 673 | +    "files = glob.glob('/opt/ml/processing/output/rule/profiler-reports/*json')\n",  | 
700 | 674 |     "summary = {}\n",  | 
701 | 675 |     "for i in files:\n",  | 
702 | 676 |     "    rule_name = i.split('/')[-1].replace('.json','')\n",  | 
 | 
0 commit comments