Skip to content

Instantly share code, notes, and snippets.

@mrhanlon
Last active February 5, 2016 22:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrhanlon/728c8223a8d3a6f105a3 to your computer and use it in GitHub Desktop.
Save mrhanlon/728c8223a8d3a6f105a3 to your computer and use it in GitHub Desktop.
Gets project information for jobs currently running on TACC Stampede, Lonestar, and Maverick
{
"name": "projects-running-jobs",
"version": "1.0.0",
"description": "",
"main": "projects-running-jobs.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git@gist.github.com:/728c8223a8d3a6f105a3.git"
},
"author": "Matthew Hanlon <mrhanlon@tacc.utexas.edu>",
"license": "MIT",
"dependencies": {
"q": "^1.2.0",
"request-promise": "^0.4.0",
"underscore": "^1.8.2"
}
}
/**
* projects-running-jobs.js
* http://www.tacc.utexas.edu
*
* @author: Matthew R Hanlon <mrhanlon@tacc.utexas.edu>
* Copyright (c) 2015 TACC
* Licensed under the MIT license.
*/
'use strict';
var request = require('request-promise'),
Q = require('q'),
_ = require('underscore');
var queues = [
'https://portal.tacc.utexas.edu/commnq/stampede.tacc.utexas.edu/queue.json',
'https://portal.tacc.utexas.edu/commnq/lonestar.tacc.utexas.edu/queue.json',
'https://portal.tacc.utexas.edu/commnq/maverick.tacc.utexas.edu/queue.json'
];
Q.all(_.map(queues, function(queue) {
return request({uri: queue, json: true})
.then(function(json) {
return json.running;
});
}))
.then(function(runningJobs) {
var projects = _.chain(runningJobs)
.flatten()
.reduce(function(mem, job) { var p = job.Extension.LocalAccount; var c = job.RequestedSlots; var val = mem[p] || 0; mem[p] = val + c; return mem; }, {})
.map(function(cores, project) { return {'projectCode': project, 'cores': cores}; })
.value();
Q.all(_.map(projects, function(project) {
return request({
uri: 'https://tas.tacc.utexas.edu/api/web/project?name=' + project.projectCode,
json: true
}).then(function(json) {
project.pi = json.principal_investigator;
project.fos = json.field_of_science;
project.inst = json.pi_institution;
project.abstract = json.project_abstract;
})
}))
.then(function() {
/* Do something with the projects */
console.log(projects);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment