Skip to content

Commit

Permalink
refactor client to use sciserver storage client. Closes #1790 (#1791)
Browse files Browse the repository at this point in the history
* refactor client to use sciserver storage client. (Closes #1790)

* WIP- Fix minor space issue in sciserver compute Client

* WIP- incorporate username/owner in _getFile. Increase test timeouts.

* WIP- increase test timeout.

* WIP-Increase test timeouts
  • Loading branch information
umesh-timalsina committed Jul 22, 2020
1 parent 4c514da commit 325bf69
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
32 changes: 17 additions & 15 deletions src/common/compute/backends/sciserver-compute/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,30 +220,32 @@ define([
async _getFile (jobInfo, filename) {
const state = await this.getJobState(jobInfo);
if (state) {
const baseUrl = 'https://apps.sciserver.org/fileservice/api/file/';
const filepath = state.resultsFolderURI.replace(/\/?$/, '/') + filename;
const fileUrl = baseUrl + this._getEncodedFilePath(filepath);

const response = await this.fetch(fileUrl);
return await response.text();
const {config, dataInfo} = this._getStorageConfigAndDataInfo(filepath);
const storage = await Storage.getClient('sciserver-files', this.logger, config);
return (await storage.getFile(dataInfo)).toString('utf-8');
}
}

async _deleteFileDir (state) {
const baseUrl = 'https://apps.sciserver.org/fileservice/api/data/';
const filepath = state.command.split(' ').pop();
const fileUrl = baseUrl + this._getEncodedFilePath(filepath);
const response = await this.fetch(fileUrl, {method: 'DELETE'});
return await response.text();
const {dataInfo, config} = this._getStorageConfigAndDataInfo(filepath);
const storage = await Storage.getClient('sciserver-files', this.logger, config);
await storage.deleteDir(dataInfo.data.filename);
}

_getEncodedFilePath (filepath) {
_getStorageConfigAndDataInfo (filepath) {
const dirs = filepath.split('/').slice(4);
const filename = dirs.pop();
const drive = dirs.slice(0, 3).join('/') + '/';
const dirname = '/' + dirs.slice(3).join('/');

return drive + encodeURIComponent(dirname) + '/' + filename;
let [volumePool, owner, volume] = dirs.slice(0, 3);
const password = this.password;
volume = owner + '/' + volume;
const filename = dirs.slice(3).join('/');
return {
config: {username: this.username, volumePool, password, volume},
dataInfo: {
data: {filename, volume, volumePool}
}
};
}

async _getComputeDomain () {
Expand Down
4 changes: 2 additions & 2 deletions test/integration/ExecutePipeline.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* globals */
describe('Pipeline execution', function () {
this.timeout(15000);
this.timeout(30000);
const {promisify} = require('util');
const {spawn} = require('child_process');
const testFixture = require('../globals');
Expand Down Expand Up @@ -194,7 +194,7 @@ describe('Pipeline execution', function () {
const seconds = 1000;
const minutes = 60*seconds;
if (compute.startsWith('sciserver')) {
return 5*minutes;
return 10*minutes;
} else if (compute === 'gme'){
return 30*seconds;
} else {
Expand Down

0 comments on commit 325bf69

Please sign in to comment.