Skip to content

Commit

Permalink
Pull into prompts GHToolbox dependency handling (via GitHub).
Browse files Browse the repository at this point in the history
  • Loading branch information
guzman-raphael committed Oct 6, 2020
1 parent 621cf3a commit 2c263f0
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 15 deletions.
37 changes: 33 additions & 4 deletions +dj/setup.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,40 @@ function setup(varargin)
try
ghtb.require(requiredToolboxes, 'prompt', prompt);
catch ME
if strcmp(ME.identifier, 'MATLAB:undefinedVarOrClass')
installPromptMsg = {
'Toolbox ''%s'' did not meet the minimum requirements.'
'Would you like to proceed with an upgrade?'
};
if strcmp(ME.identifier, 'MATLAB:undefinedVarOrClass') && (~prompt || strcmpi('yes',...
dj.internal.ask(sprintf(sprintf('%s\n', installPromptMsg{:}), 'GHToolbox'))))
% fetch
tmp_toolbox = [tempname '.mltbx'];
websave(tmp_toolbox, ['https://github.com/' requiredToolboxes{1}.ResolveTarget ...
'/releases/download/' ...
subsref(webread(['https://api.github.com/repos/' ...
requiredToolboxes{1}.ResolveTarget ...
'/releases/latest'], ...
weboptions('Timeout', 60)), ...
substruct('.', 'tag_name')) ...
'/GHToolbox.mltbx'], weboptions('Timeout', 60));
% install
try
matlab.addons.install(tmp_toolbox, 'overwrite');
catch ME
if strcmp(ME.identifier, 'MATLAB:undefinedVarOrClass')
matlab.addons.toolbox.installToolbox(tmp_toolbox);
else
rethrow(ME);
end
end
% remove temp toolbox file
delete(tmp_toolbox);
% retrigger dependency validation
ghtb.require(requiredToolboxes, 'prompt', prompt);
elseif strcmp(ME.identifier, 'MATLAB:undefinedVarOrClass')
GHToolboxMsg = {
'Toolbox ''GHToolbox'' did not meet the minimum minimum requirements.'
'Please install it via instructions in '
'''https://github.com/datajoint/GHToolbox'''.'
'Toolbox ''GHToolbox'' did not meet the minimum requirements.'
'Please proceed to install it.'
};
error('DataJoint:verifyGHToolbox:Failed', ...
sprintf('%s\n', GHToolboxMsg{:}));
Expand Down
2 changes: 1 addition & 1 deletion +dj/version.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function varargout = version
% report DataJoint version

v = struct('major',3,'minor',3,'bugfix',2);
v = struct('major',3,'minor',3,'bugfix',3);

if nargout
varargout{1}=v;
Expand Down
Binary file modified DataJoint.mltbx
Binary file not shown.
10 changes: 1 addition & 9 deletions LNX-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,7 @@ services:
- |
mkdir ~/Documents
matlab -nodisplay -r "
websave([tempdir 'GHToolbox.mltbx'],\
['https://github.com/datajoint/GHToolbox' \
'/releases/download/' subsref(webread(['https://api.github.com/repos' \
'/datajoint/GHToolbox' \
'/releases/latest']),\
substruct('.', 'tag_name')) \
'/GHToolbox.mltbx']);\
matlab.addons.toolbox.installToolbox([tempdir 'GHToolbox.mltbx']);\
ghtb.install('DataJoint.mltbx');\
matlab.addons.toolbox.installToolbox('DataJoint.mltbx');\
addpath('tests');\
res=run(Main);\
disp(res);\
Expand Down
2 changes: 1 addition & 1 deletion tests/Prep.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function init(testCase)
clear functions;
addpath([testCase.test_root '/test_schemas']);
dj.set('suppressPrompt', true);

disp(dj.version);
curr_conn = dj.conn(testCase.CONN_INFO_ROOT.host, ...
testCase.CONN_INFO_ROOT.user, testCase.CONN_INFO_ROOT.password,'',true);
% create test users
Expand Down

0 comments on commit 2c263f0

Please sign in to comment.