Skip to content

Commit

Permalink
Search for model attributes will also search on backends
Browse files Browse the repository at this point in the history
  • Loading branch information
rgerkin committed Jan 26, 2019
1 parent 99b811b commit 0602321
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sciunit/models/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def set_attrs(self, **attrs):
"""Set model attributes on the backend."""
pass

def set_run_params(self, **attrs):
def set_run_params(self, **run_params):
"""Set model attributes on the backend."""
pass

Expand Down
11 changes: 11 additions & 0 deletions sciunit/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ def is_match(self, match):
result = True # Found by instance or name
return result

def __getattr__(self, attr):
try:
result = super(Model, self).__getattribute__(attr)
except AttributeError:
try:
result = self._backend.__getattribute__(attr)
except:
raise AttributeError("Model %s has no attribute %s"
% (self, attr))
return result

def __str__(self):
"""Return the model name."""
return '%s' % self.name

0 comments on commit 0602321

Please sign in to comment.