<commit_before>
var http = require('http'),
	thrift = require('thrift'),
	fs = require('fs');

var FARService = require('./thrift_bindings/FARService.js'),
	MetricsFrontendService = require('./thrift_bindings/MetricsFrontendService.js'),
	MetadataService = require('./thrift_bindings/MetadataService.js'),
	FlowService = require('./thrift_bindings/FlowService.js');

var metadataservice_types = require('./thrift_bindings/metadataservice_types.js'),
	metricsservice_types = require('./thrift_bindings/metricsservice_types.js'),
	flowservices_types = require('./thrift_bindings/flowservices_types.js');

var SubscriptionService;
var ttransport, tprotocol;

try {
	ttransport = require('thrift/lib/thrift/transport');
} catch (e) {
	ttransport = require('thrift/transport');
}
try {
	tprotocol = require('thrift/lib/thrift/protocol');
} catch (e) {
	tprotocol = require('thrift/protocol');
}

(function () {

	this.config = {};
	this.configure = function (config) {
		this.config = config;
	};

	this.metadata = function (method, params, done) {

		params = params || [];

		var conn = thrift.createConnection(
			this.config['metadata.server.address'],
			this.config['metadata.server.port'], {
			transport: ttransport.TFramedTransport,
			protocol: tprotocol.TBinaryProtocol
		});
		conn.on('error', function (error) {
			done('Could not connect to MetadataService.');
		});

		var MetaData = thrift.createClient(MetadataService, conn);

		if (params.length === 2) {
			var entitType = params.shift();
			params[0] = new metadataservice_types[entitType](params[0]);
		}

		// Pushing the accountID into arguments. Comes from the authenticated session.
		params.unshift(new metadataservice_types.Account({
			id: 'demo'
		}));

		if (method in MetaData) {
			try {
				MetaData[method].apply(MetaData, params.concat(done));
			} catch (e) {
				done(e);
			}
		} else {
			done('Unknown method for MetadataService: ' + method, null);
		}
		
	},

	this.manager = function (method, params, done) {

		params = params || [];

		// Pushing the accountID into arguments. Comes from the authenticated session.
		params.unshift('demo');

		var auth_token = new flowservices_types.DelegationToken({ token: null });

		var conn = thrift.createConnection(
			this.config['flow.manager.server.address'],
			this.config['flow.manager.server.port'], {
			transport: ttransport.TFramedTransport,
			protocol: tprotocol.TBinaryProtocol
		});

		conn.on('error', function (error) {
			done('Could not connect to FlowMonitor.');
		});
		
		var Manager = thrift.createClient(FlowService, conn);
		var identifier = new flowservices_types.FlowIdentifier({
			applicationId: params[1],
			flowId: params[2],
			version: params[3] ? parseInt(params[3], 10) : -1,
			accountId: params[0]
		});

		switch (method) {
			case 'start':
				identifier = new flowservices_types.FlowDescriptor({
					identifier: new flowservices_types.FlowIdentifier({
						applicationId: params[1],
						flowId: params[2],
						version: parseInt(params[3], 10),
						accountId: 'demo'
					}),
					"arguments": []
				});
				Manager.start(auth_token, identifier, done);
			break;
			case 'stop':
				Manager.stop(auth_token, identifier, done);
			break;
			case 'status':
				Manager.status(auth_token, identifier, done);
			break;
			case 'getFlowDefinition':
				Manager.getFlowDefinition(identifier, done);
			break;
			case 'getFlowHistory':
				Manager.getFlowHistory(identifier, done);
			break;
			case 'setInstances':

				var flowlet_id = params[3];
				var instances = params[4];<commit_msg>setInstances argument fix try<commit_after>
var http = require('http'),
	thrift = require('thrift'),
	fs = require('fs');

var FARService = require('./thrift_bindings/FARService.js'),
	MetricsFrontendService = require('./thrift_bindings/MetricsFrontendService.js'),
	MetadataService = require('./thrift_bindings/MetadataService.js'),
	FlowService = require('./thrift_bindings/FlowService.js');

var metadataservice_types = require('./thrift_bindings/metadataservice_types.js'),
	metricsservice_types = require('./thrift_bindings/metricsservice_types.js'),
	flowservices_types = require('./thrift_bindings/flowservices_types.js');

var SubscriptionService;
var ttransport, tprotocol;

try {
	ttransport = require('thrift/lib/thrift/transport');
} catch (e) {
	ttransport = require('thrift/transport');
}
try {
	tprotocol = require('thrift/lib/thrift/protocol');
} catch (e) {
	tprotocol = require('thrift/protocol');
}

(function () {

	this.config = {};
	this.configure = function (config) {
		this.config = config;
	};

	this.metadata = function (method, params, done) {

		params = params || [];

		var conn = thrift.createConnection(
			this.config['metadata.server.address'],
			this.config['metadata.server.port'], {
			transport: ttransport.TFramedTransport,
			protocol: tprotocol.TBinaryProtocol
		});
		conn.on('error', function (error) {
			done('Could not connect to MetadataService.');
		});

		var MetaData = thrift.createClient(MetadataService, conn);

		if (params.length === 2) {
			var entitType = params.shift();
			params[0] = new metadataservice_types[entitType](params[0]);
		}

		// Pushing the accountID into arguments. Comes from the authenticated session.
		params.unshift(new metadataservice_types.Account({
			id: 'demo'
		}));

		if (method in MetaData) {
			try {
				MetaData[method].apply(MetaData, params.concat(done));
			} catch (e) {
				done(e);
			}
		} else {
			done('Unknown method for MetadataService: ' + method, null);
		}
		
	},

	this.manager = function (method, params, done) {

		params = params || [];

		// Pushing the accountID into arguments. Comes from the authenticated session.
		params.unshift('demo');

		var auth_token = new flowservices_types.DelegationToken({ token: null });

		var conn = thrift.createConnection(
			this.config['flow.manager.server.address'],
			this.config['flow.manager.server.port'], {
			transport: ttransport.TFramedTransport,
			protocol: tprotocol.TBinaryProtocol
		});

		conn.on('error', function (error) {
			done('Could not connect to FlowMonitor.');
		});
		
		var Manager = thrift.createClient(FlowService, conn);
		var identifier = new flowservices_types.FlowIdentifier({
			applicationId: params[1],
			flowId: params[2],
			version: params[3] ? parseInt(params[3], 10) : -1,
			accountId: params[0]
		});

		switch (method) {
			case 'start':
				identifier = new flowservices_types.FlowDescriptor({
					identifier: new flowservices_types.FlowIdentifier({
						applicationId: params[1],
						flowId: params[2],
						version: parseInt(params[3], 10),
						accountId: 'demo'
					}),
					"arguments": []
				});
				Manager.start(auth_token, identifier, done);
			break;
			case 'stop':
				Manager.stop(auth_token, identifier, done);
			break;
			case 'status':
				Manager.status(auth_token, identifier, done);
			break;
			case 'getFlowDefinition':
				Manager.getFlowDefinition(identifier, done);
			break;
			case 'getFlowHistory':
				Manager.getFlowHistory(identifier, done);
			break;
			case 'setInstances':

				var flowlet_id = params[3];
				var instances = params[4];

				var identifier = new flowservices_types.FlowIdentifier({
					applicationId: params[0],
					flowId: params[1],
					version: params[2] ? parseInt(params[2], 10) : -1,
					accountId: 'demo'
				});
{'fraction_non_alphanumeric': 0.14242919389978215, 'fraction_numerical': 0.005855119825708061, 'mean_word_length': 4.165260196905766, 'pattern_counts': {'":': 2, '<': 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': '1247592', 'n_tokens_mistral': 2625, 'n_tokens_neox': 2270, 'n_words': 481}