<commit_before>let Controller = require('./controller')
let slaves = require('../Models/Slaves')
let algo = require('../Models/Algo')
let rp = require('request-promise')
let AlgoController = class AlgoController {

  constructor (req, res, next) {
    this.req = req
    this.res = res
    this.next = next
    this.controller = new Controller(req, res, next)
  }

  upload () {
    // eval(JSON.parse(this.req.body.algo))
    algo.add(this.req.body.algo)
  }

  launch () {
    let slave = slaves.get(this.req.body.server)
    if (slave !== undefined) {
      let options = {
        method: 'POST',
        body: {
          algo: JSON.stringify(algo.get()),
          iteration: this.req.body.iteration
        },
        uri: 'http://' + slave.ip + ':' + slave.port + '/launchAlgo',
        json: true // Automatically stringifies the body to JSON
      }
      rp(options).then(function (parsedBody) {
      }).catch(function (err) {
        if (err) {
        }
      })
    }
  }
}

module.exports = AlgoController<commit_msg>Added slaveId<commit_after>let Controller = require('./controller')
let slaves = require('../Models/Slaves')
let algo = require('../Models/Algo')
let rp = require('request-promise')
let AlgoController = class AlgoController {

  constructor (req, res, next) {
    this.req = req
    this.res = res
    this.next = next
    this.controller = new Controller(req, res, next)
  }

  upload () {
    // eval(JSON.parse(this.req.body.algo))
    algo.add(this.req.body.algo)
  }

  launch () {
    let slave = slaves.get(this.req.body.server)
    if (slave !== undefined) {
      let options = {
        method: 'POST',
        body: {
          algo: JSON.stringify(algo.get()),
          iteration: this.req.body.iteration,
          slaveId: this.req.body.slaveId
        },
        uri: 'http://' + slave.ip + ':' + slave.port + '/launchAlgo',
        json: true // Automatically stringifies the body to JSON
      }
      rp(options).then(function (parsedBody) {
      }).catch(function (err) {
        if (err) {
        }
      })
    }
  }
}

module.exports = AlgoController
{'fraction_non_alphanumeric': 0.15417457305502846, 'fraction_numerical': 0.0, 'mean_word_length': 2.279937791601866, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2474370', 'n_tokens_mistral': 679, 'n_tokens_neox': 676, 'n_words': 144}