Skip to content

Commit

Permalink
warning for not using the model directory when it probably should be …
Browse files Browse the repository at this point in the history
…(valid base64 encoding)
  • Loading branch information
davidvlaminck committed Nov 25, 2024
1 parent 5bb4a6b commit 62588e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions UnitTests/GeneralTests/OTLObjectHelper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ def test_is_aim_id_valid():

aim_id = '12345678-1234-1234-1234-123456789012-b25kZXJkZWVsI0FsbENhc2VzVGVzdENsYXNz' # AllCasesTestClass
model_path = Path(__file__).parent.parent / 'TestModel'
with pytest.warns(ImportWarning):
assert not is_aim_id(aim_id)
assert is_aim_id(aim_id, model_directory=model_path)


Expand Down
4 changes: 4 additions & 0 deletions otlmow_model/OtlmowModel/Helpers/OTLObjectHelper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import base64
import warnings
from collections import defaultdict
from pathlib import Path
from typing import Iterable, List, Dict
Expand Down Expand Up @@ -223,5 +224,8 @@ def is_aim_id(aim_id: str, model_directory: Path = None) -> bool:
ns, name = short_uri.split('#')
instance = dynamic_create_instance_from_ns_and_name(ns, name, model_directory=model_directory)
return instance is not None
except ModuleNotFoundError:
warnings.warn('Could not import the module for the given aim_id, did you forget the model_directory?', category=ImportWarning)
return False
except ValueError:
return False

0 comments on commit 62588e3

Please sign in to comment.