-
Notifications
You must be signed in to change notification settings - Fork 39
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
stage -> master for #246 (fix for #228 (Matlab / mYm improved version/compatibility support)) #258
Conversation
…upDJ.m - ensures earlier detection of outdated components - part of fix for #228
- setupMYM now manages actual install/setup of mym - setupDJ calls this to install mym, and checks versions. currently: - we install 'master' (other options 'X.Y.Z', maps to github releases e.g: https://github.com/datajoint/mym/archive/v2.7.2.zip) - we check for >2 or >= 2.6
fix for #228 (Matlab / mYm improved version/compatibility support)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall PR looks good and ready. Have minor suggestions related to style, and, since we are modifying it, returning the installed versions from setupDJ.m
and setupMYM.m
when there is an output value defined. Can you also add a test? Should be a pretty simple one and self contained e.g. force install an old version of mym
, check version, then force install from master over it, and check version.
setupMYM.m
Outdated
@@ -0,0 +1,67 @@ | |||
function setupMYM(version, force) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function setupMYM(version, force) | |
function mymVersion = setupMYM(version, force) |
Would be nice if calls to this returned the installed version. Could also make sense to apply to setupDJ
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can see returning version is useful, renaming function I'm less clear on since this doesn't simply return the version but also may modify the system
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to rename the function but the way in Matlab that you return arguments is by defining a variable to output result to. Then you simply set that within your method. Such as mymVersion
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, misread this. what should we return? string? 3-array of versions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm don't remember our convention at the moment but I'd likely just stick to how version is returned in the dj.version
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, version support is partially implemented - some issues w/r/t proposed scheme ('how dj.version works') below -
current approach applies the input argument (string) to the corresponding file, and if mymSetup succeeds, returns this value back to the user, and replaces the INVOKED variable with INSTALLED_VERSION to cache this for subsequent non-force calls. Paused here as anything further needs wider discussions / more intrusive changes.
so - to the issues on 'how dj version works':
-
This function has to support new abstraction of 'master' (if I install 'master', should I get 'master' back or '2.3.4' ? if 2.3.4 where is master:2.3.4 reference mapping stored for confirmation/tests/maintenance, etc). For now, returning as specified in input argument if install succeeded (see point 2). setupDJ doesn't suffer from this problem because it doesn't need to manage other files / take any version arguments / etc
-
mym('version') and dj.version() both return 'struct with fields', which isn't how we are expecting the input argument, which makes version checking of input arg vs result tricky even without the master:version mapping problem in point 1
-
mym/mymSetup doesn't directly return anything, so the only way to get the 'real' mym version is mym('version') after calling mymSetup(), not sure if there could be issues here w/r/t some hidden mym internal state / install sequence problems.
also related to the unit test: unit test is clearing various directories but calling back into setupMYM() without force, which means unit test environment is unreliable because of INSTALLED_VERSION caching. not sure how best to handle this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. I will provide feedback on these points in my review where they associate within the code.
@@ -0,0 +1,117 @@ | |||
|
|||
classdef TestSetupMYM < tests.Prep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order for your tests to run alongside the existing tests, you will need to add an entry for this TestSetupMYM
class to +tests/Main.m
.
% note: for 'master', is currently 'master' not mym('version') | ||
% using mym('version') needs a master:version mapping, | ||
% and how to handle this is a wider dev issue (releses, tests, etc) | ||
mymVersion = INSTALLED_VERSION; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the master
case, I don't think we should return master
for mymVersion
. It is not explicit enough what is the actual installed version. We do not necessarily need the mapping here as it is installing master
at that time. If user would like to update to latest, simply calling SetupMYM('master', true)
would be fine.
Also, caching the INSTALLED_VERSION
seems unnecessary as we can simply ask mYm
via mym('version')
. Therefore, we can simply pass through mYm
version for the output to this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The caching of INSTALLED_VERSION evolved from just caching if the function ran (persistent INVOKED), and was modeled after setupDJ for consistency. Not sure why we are caching there, but setupDJ now calls this function, so thought this was useful (assuming that caching to be implemented on purpose) to keep the same.
Definately 'cargo cult' to be sure, but if removing cache here, seems like 'why is this happening in setupDJ' should be discussed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so basically in response to #258 (comment) people calling with 'master' would just assume successful completion is the 'correct' master?
On it's own, makes sense - wasn't sure how strict we wanted to do this and if e.g. we wanted to leave dj matlab installing 'master' but have a strict version sanity check, where to manage that, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also: so basically in response to #258 (comment) people calling with 'master' would just assume successful completion is the 'correct' master?
On it's own, makes sense - wasn't sure how strict we wanted to do this and if e.g. we wanted to leave dj matlab installing 'master' but have a strict version sanity check, where to manage that, etc.
@@ -0,0 +1,76 @@ | |||
function mymVersion = setupMYM(version, force) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After taking another look, perhaps we should change the function name to updateMYM
so we do not confuse this method with mymSetup.m
(from mYm
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Named this to be consistent with 'setupDJ', realized it was confusing but thought in-matlab consistency made more sense to follow since mymSetup is in another repo. Not sure what's best.
|
||
persistent INSTALLED_VERSION; | ||
|
||
if ~isempty(INSTALLED_VERSION) && ~force |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like we can consolidate the overall logic a bit since some of the checks can be redundant. Think it is fair to assume if user 'forces' an install, we should always reinstall (even if the same version). Logic could look like:
base = fileparts(mfilename('fullpath'));
mymdir = fullfile(base, 'mym');
if isdir(mymdir) && ~force
error('mYm already installed, etc.');
mymVersion = [];
return;
elseif isdir(mymdir) && force
warning('mYm detected but forcing update, etc.');
rmdir(mymdir, 's');
end
{{install mYm}}
mymVersion = mym('version');
fprintf('downloading %s to %s\n', mymURL, target); | ||
target = websave(target, mymURL); | ||
|
||
extdir = fullfile(base, sprintf('mym-%s', version)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might not select the dir properly if vX.X.X
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^ see above - versions as written should be either names or 'x.y.z' strings ( goes to overall question of how to represent abstract vs real versions & where to store this). Not saying this is how it should be, but, that's the API model currently.
|
||
% TODO: how manage version string? | ||
ms = setupMYM('2.7.2'); | ||
testCase.verifyTrue(strcmp(ms, '2.7.2')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testCase.verifyTrue(strcmp(ms, '2.7.2')); | |
testCase.verifyTrue(strcmp([ms.major '.' ms.minor '.' ms.bugfix], '2.7.2')); |
[dir, nam, ext] = fileparts(mfilename('fullpath')); | ||
tmym = strcat(dir, '/../', 'mym'); | ||
|
||
if isdir(tmym) | ||
fprintf('testDefaultInstall: mymdir %s exists. removing\n', ... | ||
tmym); | ||
rmdir(tmym, 's'); | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[dir, nam, ext] = fileparts(mfilename('fullpath')); | |
tmym = strcat(dir, '/../', 'mym'); | |
if isdir(tmym) | |
fprintf('testDefaultInstall: mymdir %s exists. removing\n', ... | |
tmym); | |
rmdir(tmym, 's'); | |
end | |
tmym = [which('mym') '/../../..']; | |
rmdir(tmym, 's'); |
end | ||
|
||
ms = setupMYM(); | ||
testCase.verifyTrue(strcmp(ms, 'master')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testCase.verifyTrue(strcmp(ms, 'master')); | |
latest_mym = webread('https://api.github.com/repos/datajoint/mym/releases/latest'); | |
testCase.verifyTrue(tests.lib.compareVersions([ms.major '.' ms.minor '.' ms.bugfix], latest_mym.tag_name(2:end))); |
testCase.verifyTrue(isdir(tmym)); | ||
|
||
end | ||
function TestSetupMYM_testVersionInstallStale(testCase) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not too clear on the objective of the below tests. Thinking you might only need 2 tests to cover most cases:
- Install master, verify, install specific version w/o force, verify error, install specific version w/ force, verify
- Install specific version, verify, install master w/o force, verify error, install master w/ force, verify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, good thinking, will adjust
setupMYM.m
Outdated
@@ -0,0 +1,67 @@ | |||
function setupMYM(version, force) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. I will provide feedback on these points in my review where they associate within the code.
@ixcat One more note regarding tests on MySQL8, you will need to modify |
think version string handling is clear - remaining design questions:
pending:
|
setupMYM naming: leaving as is, 'meh'+'sort conflicting criteria by something' as rationale |
so - since this effort will be deprecated, we need to clean up 'stage' - thoughts welcome to proceed. |
Closing as discussed since #285 ready. Will reset |
see also: #246