Skip to content

Commit efd54e2

Browse files
authored
Replace error with warning for unmapped instance folders (#82)
* Update getSchemaName.m Remove concatenation of structs. Structs might have different fields, and the concatenation would fail. Only need name and potentially label, so explicitly get these instead of relying on struct concatenation * Warn once for unmapped instance folders Replace a hard error for unimplemented instance folder names with a warning that is emitted only once per unique folder name. Introduces a containers.Map (hasWarned) to track which folder names have already triggered the warning and uses the identifier 'OPENMINDS:InstanceLibrary:createInstanceTable:MissingTypeMapping'. This avoids aborting execution for unmapped folders while preventing repeated duplicate warnings. * Update getModelVersion.m * Temporarily skip latest model version assertion in MetaTypeTest * debug uriJoin * debug urijoin * debug * Remove debug code, more targeted version pin in getControlledInstances * Update getControlledInstance.m * Update testReadTheDocLinks.m Replace UBERONParcellation with BiologicalSex. UBERONParcellation has been removed in latest
1 parent 048b729 commit efd54e2

4 files changed

Lines changed: 22 additions & 8 deletions

File tree

code/internal/+openminds/+internal/+vocab/getSchemaName.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@
2424
end
2525

2626
C = struct2cell(typesVocab);
27-
S = [C{:}];
28-
29-
allNames = {S.name};
3027

28+
allNames = cellfun(@(c) string(c.name), C);
3129
isMatch = strcmpi(allNames, nameAlias);
3230

3331
if ~any(isMatch)
34-
allLabels = {S.label};
32+
allLabels = cellfun(@(c) string(c.label), C);
3533
isMatch = strcmpi(allLabels, nameAlias);
3634
end
3735

code/internal/+openminds/+internal/@InstanceLibrary/InstanceLibrary.m

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ function postSetLibraryVersion(obj)
148148

149149
numInstances = numel(filePaths);
150150
[types, modules, subGroups] = deal(repmat("", numInstances, 1));
151+
152+
hasWarned = containers.Map();
153+
151154
for i = 1:numInstances
152155

153156
thisFolderSplit = split(folderNames(i), filesep);
@@ -179,7 +182,13 @@ function postSetLibraryVersion(obj)
179182
modules(i) = "core";
180183
subGroups(i) = missing;
181184
else
182-
error('The instance folder with name "%s" is not implemented. Please report', thisFolderSplit(1))
185+
186+
if ~isKey(hasWarned, thisFolderSplit(1))
187+
warning('OPENMINDS:InstanceLibrary:createInstanceTable:MissingTypeMapping', ...
188+
['The instance folder with name "%s" is not ', ...
189+
'mapped to an openMINDS type. Please report'], thisFolderSplit(1))
190+
hasWarned(thisFolderSplit(1)) = true;
191+
end
183192
end
184193
end
185194

code/internal/+openminds/+internal/getControlledInstance.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
if ismissing(versionNumber)
1414
versionNumber = openminds.getModelVersion("VersionNumber");
1515
end
16+
17+
% Todo: remove. Pin latest version to v4.0 as instances from v5.0 are not
18+
% supported yet.
19+
if versionNumber == "latest"
20+
versionNumber = openminds.internal.utility.VersionNumber("4.0");
21+
versionNumber.Format = "vX.Y";
22+
end
1623
versionNumber = string(versionNumber);
1724

1825
% Make type name lowercase unless it is an abbreviated typename like

tools/tests/unitTests/testReadTheDocLinks.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@ function testInvalidDocumentationUrl(testCase)
3131
'MATLAB:webservices:HTTP404StatusCodeError')
3232
end
3333

34-
function testSchemaDocLinkUBERONParcellation(testCase)
34+
function testSchemaDocLinkBiologicalSex(testCase)
3535
import openminds.internal.utility.getSchemaDocLink
3636

3737
url = getSchemaDocLink(...
38-
"openminds.controlledterms.UBERONParcellation", ...
38+
"openminds.controlledterms.BiologicalSex", ...
3939
"Raw URL");
4040

4141
try
4242
webread(url);
4343
catch ME
4444
errorMessage = sprintf([...
45-
'Failed to read documentation for UBERONParcellation with error:\n', ...
45+
'Failed to read documentation for BiologicalSex with error:\n', ...
4646
'%s'], ME.message);
4747
testCase.verifyFail(errorMessage)
4848
end

0 commit comments

Comments
 (0)