client/src/components/core/services/athenaService.js
/**
     * Asks athena server to run the algorithm with the given options
     */
Asks athena server to run the algorithm with the given options
Asks athena server to run the algorithm with the given options
function run_algorithm(name, options, networkName, networkId) {
        return projFactory.currProject()
            .then(function() {
                var taskId = 'athena_' + _.random(0, 100000, false).toString();
                if (_.isEmpty(projFactory.currProjectUnsafe().dataset)) {
                    throw new Error('No dataset yet, can\'t generate networks');
                }
                var projectId = projFactory.currProjectUnsafe()._id;
                console.assert(projectId.length > 0, 'projectId must exist!');
                var ioCreate = $http.post('/api/jobs', {
                    name: 'athenaJob',
                    taskId: taskId
                });
                ioCreate.catch(function(response) {
                    console.log('[athenaService] Error in executing algorithm. data : %O, status : %s', response.data, response.status);
                });
                var onConnectFn = function() {
                    return $http.post('/athena/algo', {
                        taskId: taskId,
                        algo_name: name,
                        options: options,
                        projectId: projectId,
                        networkId: networkId,
                        newNetworkName: networkName,
                        createNew: networkId == null
                    }).catch(function(data, status) {
                        console.log('[athenaService] Error in executing algorithm. data : %O, status : %s', data, status);
                    });
                };
                var res = ioCreate
                    .then(function() {
                        return watchTask(taskId, onConnectFn);
                    })
                    .then(function(data) {
                        console.log('[athenaService] Called algorithm successfully. Got data : %O', data);
                        console.log('[athenaService] Athena Process id: %s', data.result);
                        $rootScope.$broadcast(BROADCAST_MESSAGES.network.created);
                        networkService.deCacheNetwork(data.networkId);
                        return {
                            networkId: data.networkId,
                            data: data.data
                        };
                    }, function(err) {
                        console.error('SOMETHING BAD HAPPENED! :', err);
                        console.error(err.result);
                        return $q.reject(err.result);
                    });
                return res;
            });
    }
function run_algorithm ( name , options , networkName , networkId ) { return projFactory . currProject ( ) . then ( function ( ) { var taskId = 'athena_' + _ . random ( 0 , 100000 , false ) . toString ( ) ; if ( _ . isEmpty ( projFactory . currProjectUnsafe ( ) . dataset ) ) { throw new Error ( 'No dataset yet, can\'t generate networks' ) ; } var projectId = projFactory . currProjectUnsafe ( ) . _id ; console . assert ( projectId . length > 0 , 'projectId must exist!' ) ; var ioCreate = $http . post ( '/api/jobs' , { name : 'athenaJob' , taskId : taskId } ) ; ioCreate . catch ( function ( response ) { console . log ( '[athenaService] Error in executing algorithm. data : %O, status : %s' , response . data , response . status ) ; } ) ; var onConnectFn = function ( ) { return $http . post ( '/athena/algo' , { taskId : taskId , algo_name : name , options : options , projectId : projectId , networkId : networkId , newNetworkName : networkName , createNew : networkId == null } ) . catch ( function ( data , status ) { console . log ( '[athenaService] Error in executing algorithm. data : %O, status : %s' , data , status ) ; } ) ; } ; var res = ioCreate . then ( function ( ) { return watchTask ( taskId , onConnectFn ) ; } ) . then ( function ( data ) { console . log ( '[athenaService] Called algorithm successfully. Got data : %O' , data ) ; console . log ( '[athenaService] Athena Process id: %s' , data . result ) ; $rootScope . $broadcast ( BROADCAST_MESSAGES . network . created ) ; networkService . deCacheNetwork ( data . networkId ) ; return { networkId : data . networkId , data : data . data } ; } , function ( err ) { console . error ( 'SOMETHING BAD HAPPENED! :' , err ) ; console . error ( err . result ) ; return $q . reject ( err . result ) ; } ) ; return res ; } ) ; }
Asks athena server to run the algorithm with the given options
Asks athena server to run the algorithm with the given options
// create a channel to communicate the status //ioCreate.error(function(data, status) // load network // var onLoadNW = networkService.fetchProjectNetwork(data.networkId);