Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor client to use sciserver storage client. (Closes #1790) #1791

Merged
merged 6 commits into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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