Skip to content

Commit

Permalink
Fix exception type raised on calling missing error on Handler
Browse files Browse the repository at this point in the history
  • Loading branch information
aniezurawski committed Sep 7, 2021
1 parent 9a08513 commit 481de74
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
6 changes: 3 additions & 3 deletions neptune/new/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from neptune.new.attributes.series.float_series import FloatSeries
from neptune.new.attributes.series.string_series import StringSeries
from neptune.new.attributes.sets.string_set import StringSet
from neptune.new.exceptions import MissingFieldException, NeptuneException
from neptune.new.exceptions import NeptuneException
from neptune.new.internal.utils import verify_type, is_collection, verify_collection_type, is_float, is_string, \
is_float_like, is_string_like
from neptune.new.internal.utils.paths import join_paths, parse_path
Expand Down Expand Up @@ -49,12 +49,12 @@ def __getattr__(self, attribute_name):
if attr:
return getattr(attr, attribute_name)
else:
raise MissingFieldException(self._path)
raise AttributeError(f"No such method '{attribute_name}'.")

def __getattribute__(self, attribute_name):
_docstring_attrs = super().__getattribute__('DOCSTRING_ATTRIBUTES')
if attribute_name in _docstring_attrs:
raise AttributeError()
raise AttributeError(f"No such method '{attribute_name}'.")
return super().__getattribute__(attribute_name)

def assign(self, value, wait: bool = False) -> None:
Expand Down
10 changes: 5 additions & 5 deletions tests/neptune/new/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from neptune.new.attributes.atoms import String
from neptune.new.envs import API_TOKEN_ENV_NAME, PROJECT_ENV_NAME
from neptune.new.exceptions import (
MetadataInconsistency, MissingFieldException, NeptuneOfflineModeFetchException, NeptuneUninitializedException,
MetadataInconsistency, NeptuneOfflineModeFetchException, NeptuneUninitializedException,
)
from neptune.new.internal.backends.api_model import (
ApiRun,
Expand Down Expand Up @@ -141,19 +141,19 @@ def test_entrypoint(self):
@patch("neptune.new.internal.utils.source_code.is_ipython", new=lambda: True)
def test_entrypoint_in_interactive_python(self):
exp = init(mode='debug')
with self.assertRaises(MissingFieldException):
with self.assertRaises(AttributeError):
exp["source_code/entrypoint"].get()

exp = init(mode='debug', source_files=[])
with self.assertRaises(MissingFieldException):
with self.assertRaises(AttributeError):
exp["source_code/entrypoint"].get()

exp = init(mode='debug', source_files=["../*"])
with self.assertRaises(MissingFieldException):
with self.assertRaises(AttributeError):
exp["source_code/entrypoint"].get()

exp = init(mode='debug', source_files=["internal/*"])
with self.assertRaises(MissingFieldException):
with self.assertRaises(AttributeError):
exp["source_code/entrypoint"].get()

@patch("neptune.new.internal.utils.source_code.sys.argv", ["main.py"])
Expand Down
6 changes: 1 addition & 5 deletions tests/neptune/new/test_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from neptune.new.attributes.atoms.string import String
from neptune.new.attributes.sets.string_set import StringSet
from neptune.new.envs import PROJECT_ENV_NAME, API_TOKEN_ENV_NAME
from neptune.new.exceptions import FileNotFound, MissingFieldException
from neptune.new.exceptions import FileNotFound
from neptune.new.types import File as FileVal
from neptune.new.types.atoms.datetime import Datetime as DatetimeVal
from neptune.new.types.atoms.float import Float as FloatVal
Expand Down Expand Up @@ -317,12 +317,8 @@ def test_lookup(self):

def test_attribute_error(self):
exp = init(mode="debug", flush_period=0.5)
with self.assertRaises(MissingFieldException):
exp['var'].something()
with self.assertRaises(AttributeError):
exp['var'].something()
with self.assertRaises(KeyError):
exp['var'].something()

def test_float_like_types(self):
exp = init(mode="debug", flush_period=0.5)
Expand Down

0 comments on commit 481de74

Please sign in to comment.