Skip to content

Commit

Permalink
Move compareVersions to its maintained toolbox, rename setupDJ to +dj…
Browse files Browse the repository at this point in the history
…/setup, add GHToolbox/mym dependencies, add installation docs, and clean up tests.
  • Loading branch information
guzman-raphael committed Sep 22, 2020
1 parent b016561 commit 058227c
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 234 deletions.
100 changes: 0 additions & 100 deletions +dj/+lib/compareVersions.m

This file was deleted.

14 changes: 1 addition & 13 deletions +dj/Connection.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,7 @@
% specify the connection to the database.
% initQuery is the SQL query to be executed at the start
% of each new session.
if ~any(arrayfun(@(x) strcmp(x.Name, 'mym'), ...
matlab.addons.toolbox.installedToolboxes, 'uni', true))
ghtb.install('guzman-raphael/mym');
end
try
mymVersion = mym('version');
assert(mymVersion.major > 2 || mymVersion.major==2 && mymVersion.minor>=6)
catch
error 'Outdated version of mYm. Please upgrade to version 2.6 or later'
end
if verLessThan('matlab', '8.6')
error 'MATLAB version 8.6 (R2015b) or greater is required'
end
dj.setup('prompt', ~dj.set('suppressPrompt'));
self.host = host;
self.user = username;
self.password = password;
Expand Down
1 change: 0 additions & 1 deletion +dj/conn.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
end
end
else
% invoke setupDJ
% optional environment variables specifying the connection.
env = struct(...
'host', 'DJ_HOST', ...
Expand Down
51 changes: 51 additions & 0 deletions +dj/setup.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
function setup(varargin)
p = inputParser;
addOptional(p, 'force', false);
addOptional(p, 'prompt', true);
parse(p, varargin{:});
force = p.Results.force;
prompt = p.Results.prompt;
persistent INVOKED
if ~isempty(INVOKED) && ~force
return
end
% check MATLAB
if verLessThan('matlab', '9.1')
error('DataJoint:System:UnsupportedMatlabVersion', ...
'MATLAB version 9.1 (R2016b) or greater is required');
end
% require certain toolboxes
requiredToolboxes = {...
struct(...
'Name', 'GHToolbox', ...
'ResolveTarget', 'datajoint/GHToolbox'...
), ...
struct(...
'Name', 'mym', ...
'ResolveTarget', 'guzman-raphael/mym', ...
'Version', '2.7.3'...
)...
};
try
ghtb.require(requiredToolboxes, 'prompt', prompt);
catch ME
if 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'''.'
};
error('DataJoint:verifyGHToolbox:Failed', ...
sprintf('%s\n', GHToolboxMsg{:}));
else
rethrow(ME)
end
end
% check mym
mymVersion = mym('version');
assert(mymVersion.major > 2 || mymVersion.major==2 && mymVersion.minor>=6, ...
'DataJoint:System:mYmIncompatible', ...
'Outdated version of mYm. Please upgrade to version 2.6 or later');
% set cache
INVOKED = true;
end
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 @@ -40,15 +40,7 @@ services:
- -c
- |
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
39 changes: 31 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,33 @@ DataJoint for MATLAB is a high-level programming interface for relational databa

DataJoint was initially developed in 2009 by Dimitri Yatsenko in [Andreas Tolias' Lab](http://toliaslab.org) for the distributed processing and management of large volumes of data streaming from regular experiments. Starting in 2011, DataJoint has been available as an open-source project adopted by other labs and improved through contributions from several developers.

## Installation

Running Tests Locally
=====================
### Greater than R2016b (Recommended)

1. Utilize MATLAB built-in GUI i.e. *Top Ribbon -> Add-Ons -> Get Add-Ons*
2. Search and Select `DataJoint`
3. Select *Add from GitHub*

### Less than R2016b

1. Utilize MATLAB built-in GUI i.e. *Top Ribbon -> Add-Ons -> Get Add-Ons*
2. Search and Select `DataJoint`
3. Select *Download from GitHub*
4. Save `DataJoint.mltbx` locally
5. Navigate in MATLAB tree browser to saved toolbox file
6. Right-Click and Select *Install*
7. Select *Install*

### From Source

1. Download `DataJoint.mltbx` locally
2. Navigate in MATLAB tree browser to saved toolbox file
3. Right-Click and Select *Install*
4. Select *Install*


## Running Tests Locally

* Create an `.env` with desired development environment values e.g.
``` sh
Expand All @@ -30,20 +53,20 @@ MYSQL_TAG=5.7
| Run tests based on test name | `import matlab.unittest.TestSuite;`<br>`import matlab.unittest.selectors.HasName;`<br>`import matlab.unittest.constraints.ContainsSubstring;`<br>`suite = TestSuite.fromClass(?Main, ... `<br><code>&nbsp;&nbsp;&nbsp;&nbsp;</code>`HasName(ContainsSubstring('Conn')));`<br>`run(suite)`|


Launch Jupyter Notebook
-----------------------
### Launch Jupyter Notebook

* Navigate to `localhost:8888`
* Input Jupyter password
* Launch a notebook i.e. `New > MATLAB`


Launch MATLAB GUI (supports remote interactive debugger)
--------------------------------------------------------
### Launch MATLAB GUI (supports remote interactive debugger)

* Shell into `datajoint-matlab_app_1` i.e. `docker exec -it datajoint-matlab_app_1 bash`
* Launch Matlab by runnning command `matlab`


Launch MATLAB Terminal
----------------------
### Launch MATLAB Terminal

* Shell into `datajoint-matlab_app_1` i.e. `docker exec -it datajoint-matlab_app_1 bash`
* Launch Matlab with no GUI by runnning command `matlab -nodisplay`
2 changes: 0 additions & 2 deletions local-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ services:
'uni', false),\
'.'),\
{'+dj'});\
ghtb.install('DataJoint.mltbx');\
dj.version;\
"
# Copy preferences
cp /tmp/matlab.prf /home/muser/.matlab/${MATLAB_VERSION}/matlab.prf
Expand Down
100 changes: 0 additions & 100 deletions tests/+lib/compareVersions.m

This file was deleted.

2 changes: 1 addition & 1 deletion tests/Prep.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function init(testCase)
testCase.CONN_INFO_ROOT.user, testCase.CONN_INFO_ROOT.password,'',true);
% create test users
ver = curr_conn.query('select @@version as version').version;
if lib.compareVersions(ver,'5.8')
if compareVersions(ver,'5.8')
cmd = {...
'CREATE USER IF NOT EXISTS ''datajoint''@''%%'' '
'IDENTIFIED BY ''datajoint'';'
Expand Down

0 comments on commit 058227c

Please sign in to comment.