@@ -3,6 +3,8 @@ const fs = require('fs');
33const global = require ( '../../lib/global' ) ;
44const print = console . log ;
55const childprocess = require ( 'child_process' ) ;
6+ const path = require ( 'path' ) ;
7+
68
79function loadPage ( page_path ) {
810 $ ( "#main-content" ) . html ( '' ) ;
@@ -20,9 +22,9 @@ $("#user-create-project-button").click(() => {
2022 swal ( "Error" , "Projet Name can't be empty." , "error" ) ;
2123 } else if ( value ) {
2224 let dir = value . replace ( / [ ^ a - z 0 - 9 ] / gi, '_' ) . toLowerCase ( ) ;
23- let basepath = process . cwd ( ) + "/../testing/Projects/" ;
24- if ( ! fs . existsSync ( process . cwd ( ) + "/../testing" ) ) {
25- fs . mkdirSync ( process . cwd ( ) + "/../testing" ) ;
25+ let basepath = path . join ( process . cwd ( ) , "/../testing/Projects/" ) ;
26+ if ( ! fs . existsSync ( path . join ( process . cwd ( ) , "/../testing" ) ) ) {
27+ fs . mkdirSync ( path . join ( process . cwd ( ) , "/../testing" ) ) ;
2628 }
2729 if ( ! fs . existsSync ( basepath ) ) {
2830 fs . mkdirSync ( basepath ) ;
@@ -43,7 +45,7 @@ $("#user-create-project-button").click(() => {
4345 print ( "Error creating folder" , err ) ;
4446 }
4547 } ) ;
46- fs . mkdirSync ( basepath + dir + "/ logs") ;
48+ fs . mkdirSync ( path . join ( basepath , dir , " logs") ) ;
4749 let data = {
4850 name : dir ,
4951 details : value ,
@@ -64,7 +66,7 @@ import numpy as np
6466Do not remove tensorboard initialization.
6567Also, don't forget to add tensorboard as callback in your model.
6668'''
67- tensorboard = TensorBoard(log_dir="../testing/Projects/${ dir } /logs/{}".format(asctime()), histogram_freq=0,write_graph=True,write_grads=True,write_images=True)
69+ tensorboard = TensorBoard(log_dir="../testing/Projects/${ dir } /logs/{}".format(asctime()).replace(":"."-") , histogram_freq=0,write_graph=True,write_grads=True,write_images=True)
6870
6971
7072def getTrainingData():
@@ -94,9 +96,9 @@ def train():
9496train()
9597
9698`
97- fs . writeFileSync ( basepath + dir + "/ graph.json", JSON . stringify ( initgraph ) ) ;
98- fs . writeFileSync ( basepath + dir + "/ editor.py", initeditor ) ;
99- fs . writeFile ( basepath + dir + "/ info.json", JSON . stringify ( data ) , 'utf-8' , err => {
99+ fs . writeFileSync ( path . join ( basepath , dir , " graph.json") , JSON . stringify ( initgraph ) ) ;
100+ fs . writeFileSync ( path . join ( basepath , dir , " editor.py") , initeditor ) ;
101+ fs . writeFile ( path . join ( basepath , dir , " info.json") , JSON . stringify ( data ) , 'utf-8' , err => {
100102 if ( err ) {
101103 print ( "Error writing file" , err ) ;
102104 } else {
@@ -128,22 +130,33 @@ function openProject(value, page) {
128130 global . projectDetails . name = pdosi [ 0 ] . innerText ;
129131 global . projectDetails . details = pdosi [ 1 ] . innerText ;
130132
131- let killtensorboard = childprocess . spawn ( 'killall' , [ "-9" , "tensorboard" ] ) ;
132-
133+
134+ let killtensorboard ;
135+ if ( process . platform == "win32" ) {
136+ killtensorboard = childprocess . spawn ( 'taskkill' , [ '/f' , '/im' , 'tensorboard.exe' ] )
137+ } else {
138+ killtensorboard = childprocess . spawn ( 'killall' , [ "-9" , "tensorboard" ] ) ;
139+ }
140+
141+ var tensorbaord ;
133142 var env = Object . create ( process . env ) ;
134143 killtensorboard . on ( 'close' , ( code ) => {
135- let tensorbaord = childprocess . spawn ( 'tensorboard' , [ "--logdir=../testing/Projects/" + global . projectDetails . name + "/logs/" ] , {
144+ let tensorbaordcmd = process . platform == "win32" ? path . join ( env [ 'CONDA_PREFIX' ] , 'Scripts' , 'tensorboard.exe' ) : 'tensorboard' ;
145+ tensorbaord = childprocess . spawn ( tensorbaordcmd , [ "--logdir=" + path . join ( "../testing/Projects/" , global . projectDetails . name , "logs" ) , "--host=127.0.0.1" ] , {
136146 env : env
137147 } ) ;
138148
139- console . log ( `child process exited with code ${ code } ` ) ;
149+ tensorbaord . on ( 'close' , ( code ) => {
150+ console . log ( code ) ;
151+ } ) ;
152+ // console.log(`child process exited with code ${code}`);
140153 } ) ;
141154
142155 loadPage ( page ) ;
143156}
144157
145158function loadProjects ( ) {
146- let basepath = process . cwd ( ) + "/../testing/Projects/" ;
159+ let basepath = path . join ( process . cwd ( ) , "/../testing/Projects/" ) ;
147160 let dirlist = getDirectories ( basepath )
148161
149162 if ( dirlist . length != 0 ) {
@@ -152,7 +165,7 @@ function loadProjects() {
152165
153166 $ ( "#user-projects-card-row" ) . empty ( ) ;
154167 for ( let dir in dirlist ) {
155- fs . readFile ( basepath + dirlist [ dir ] + "/ info.json", ( err , fileData ) => {
168+ fs . readFile ( path . join ( basepath , dirlist [ dir ] , " info.json") , ( err , fileData ) => {
156169 if ( err ) {
157170 return print ( "Error in reading all projects" , err )
158171 }
0 commit comments