-
Notifications
You must be signed in to change notification settings - Fork 63
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
Proper input value type verification for append
method
#1254
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,7 @@ | |
from neptune.exceptions import ( | ||
FileNotFound, | ||
NeptuneUserApiInputException, | ||
UnsupportedType, | ||
) | ||
from neptune.types import File as FileVal | ||
from neptune.types.atoms.artifact import Artifact | ||
|
@@ -64,6 +65,10 @@ | |
from tests.unit.neptune.new.utils.file_helpers import create_file | ||
|
||
|
||
class Obj: | ||
pass | ||
|
||
|
||
class TestBaseAssign(unittest.TestCase): | ||
@classmethod | ||
def setUpClass(cls) -> None: | ||
|
@@ -270,21 +275,20 @@ def test_log_many_values(self): | |
|
||
def test_append_many_values_cause_error(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It sould not be called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
with init_run(mode="debug", flush_period=0.5) as exp: | ||
with self.assertRaises(NeptuneUserApiInputException): | ||
exp["some/num/val"].append([]) | ||
with self.assertRaises(NeptuneUserApiInputException): | ||
exp["some/num/val"].append([5, 10, 15]) | ||
with self.assertRaises(NeptuneUserApiInputException): | ||
exp["some/str/val"].append(["some text", "other"]) | ||
with self.assertRaises(NeptuneUserApiInputException): | ||
exp["some/num/val"].append({"key-a": [1, 2]}) | ||
with self.assertRaises(NeptuneUserApiInputException): | ||
exp["some/img/val"].append( | ||
[ | ||
FileVal.as_image(PIL.Image.new("RGB", (60, 30), color="red")), | ||
FileVal.as_image(PIL.Image.new("RGB", (20, 90), color="red")), | ||
] | ||
) | ||
with self.assertRaises(UnsupportedType): | ||
exp["some/empty-list/val"].append([]) | ||
with self.assertRaises(UnsupportedType): | ||
exp["some/tuple/val"].append(()) | ||
with self.assertRaises(UnsupportedType): | ||
exp["some/list/val"].append([5, 10, 15]) | ||
with self.assertRaises(UnsupportedType): | ||
exp["some/str-tuple/val"].append(("some text", "other")) | ||
with self.assertRaises(UnsupportedType): | ||
exp["some/dict-list/val"].append({"key-a": [1, 2]}) | ||
with self.assertRaises(UnsupportedType): | ||
exp["some/custom-obj/val"].append(Obj()) | ||
with self.assertRaises(UnsupportedType): | ||
exp["some/list-custom-obj/val"].append([Obj(), Obj()]) | ||
|
||
def test_extend(self): | ||
with init_run(mode="debug", flush_period=0.5) as exp: | ||
|
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 we change
validate_and_transform_to_extend_format
totransform_to_extend_format
?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.
Done