Skip to content
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

Added more descriptive error messages and hints for common usage mistakes #226

Merged
merged 30 commits into from Dec 8, 2022
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ebe8ad7
multiprocessing fix and helper func
Apr 14, 2022
ef96114
Merge branch 'fuse2' of https://github.com/IBM/fuse-med-ml into yoels
Jun 23, 2022
5131962
path utilities and also moshikos change to solve hang on tests
Jun 27, 2022
0f49726
Merge branch 'fuse2' of https://github.com/IBM/fuse-med-ml into yoels
Jun 28, 2022
f22c82c
PR comments implemented
Jul 7, 2022
21d8489
Merge branch 'fuse2' of https://github.com/IBM/fuse-med-ml into yoels
Jul 7, 2022
bf6d0d6
Merge branch 'fuse2' into yoels
mosheraboh Jul 7, 2022
deb3f8c
solved conflict
Jul 15, 2022
8874cf1
path utils
Jul 30, 2022
2eff0a0
path utils
Jul 30, 2022
b1000a1
Merge branch 'master' of https://github.com/IBM/fuse-med-ml into yoels
Aug 3, 2022
49e9c4e
changed default deepdiff behavior to ignore nans in comparison, added…
Aug 4, 2022
df426e6
solved static code analysis raised issues
Aug 4, 2022
b0e80ba
removed unreachable code in paths.py
Aug 4, 2022
f122c6f
* Added "remove_extension" to path utils
Aug 4, 2022
41728fe
Merge branch 'master' of https://github.com/IBM/fuse-med-ml into yoels
Sep 7, 2022
b8a60d1
fixed a bug in head_1D_classifier
Sep 8, 2022
0e57146
added a lightweight mode of DatasetDefault that doesn't hold any samp…
Sep 13, 2022
8424eb8
Merge branch 'master' of https://github.com/IBM/fuse-med-ml into yoels
Sep 14, 2022
8d31cd3
fixing statically detected issues
Sep 14, 2022
e718736
added simple function caching utility
Sep 20, 2022
d589c53
lite weight dataset default
Sep 22, 2022
5ae0181
fixed static checkers
Sep 22, 2022
e8b6dd2
fixed static code analysis related stuff
Sep 29, 2022
b183413
code cleanup
Sep 29, 2022
889e631
removed comments
Sep 29, 2022
8c774e2
implemented PR comments
Sep 29, 2022
81a7a70
added hints and better error messages for common mistakes when provid…
Dec 8, 2022
4912a06
merge and solved conflict
Dec 8, 2022
415ace3
linters etc.
Dec 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion fuse/data/ops/op_base.py
Expand Up @@ -21,6 +21,7 @@
from fuse.data.utils.sample import get_sample_id
from fuse.utils.ndict import NDict
from fuse.data.ops.hashable_class import HashableClass
import inspect


class OpBase(HashableClass):
Expand Down Expand Up @@ -93,11 +94,26 @@ def reverse(self, sample_dict: NDict, key_to_reverse: str, key_to_follow: str, o


def op_call(op: OpBase, sample_dict: NDict, op_id: str, **kwargs):

if inspect.isclass(op):
raise Exception(
f"Error: expected an instance object, not a class object for {op}\n"
"When creating a pipeline, such error can happen when you provide the following ops list description:\n"
"[SomeOp, {}]\n"
"instead of \n"
"[SomeOp(), {}]\n"
)

try:
if isinstance(op, OpReversibleBase):
return op(sample_dict, op_id=op_id, **kwargs)
else: # OpBase but note reversible
elif isinstance(op, OpBase): # OpBase but not reversible
return op(sample_dict, **kwargs)
else:
raise Exception(
f"Ops are expected to be instances of classes or subclasses of OpBase. The following op is not: {op}"
)

except:
# error messages are cryptic without this. For example, you can get "TypeError: __call__() got an unexpected keyword argument 'key_out_input'" , without any reference to the relevant op!
print(
Expand Down