#1597 Improve error logs for classifier operations + fix complex tests

Merged Vincent Chen vincentschen Pseudo commit used to compare (c4e24fb...e95681a)
Missing base report.

Unable to compare commits because the base of the pull request did not upload a coverage report.

Changes found in between c4e24fb...e95681a (pseudo...base) which prevent comparing this pull request.


@@ -2,7 +2,7 @@
Loading
2 2
3 3
import spacy
4 4
5 -
from snorkel.types import FieldMap
5 +
from snorkel.types import FieldMap, HashingFunction
6 6
7 7
from .core import BasePreprocessor, Preprocessor
8 8
@@ -40,6 +40,8 @@
Loading
40 40
        Preprocessors to run before this preprocessor is executed
41 41
    memoize
42 42
        Memoize preprocessor outputs?
43 +
    memoize_key
44 +
        Hashing function to handle the memoization (default to snorkel.map.core.get_hashable)
43 45
    gpu
44 46
        Prefer Spacy GPU processing?
45 47
    """
@@ -52,6 +54,7 @@
Loading
52 54
        disable: Optional[List[str]] = None,
53 55
        pre: Optional[List[BasePreprocessor]] = None,
54 56
        memoize: bool = False,
57 +
        memoize_key: Optional[HashingFunction] = None,
55 58
        gpu: bool = False,
56 59
    ) -> None:
57 60
        name = type(self).__name__
@@ -61,6 +64,7 @@
Loading
61 64
            mapped_field_names=dict(doc=doc_field),
62 65
            pre=pre,
63 66
            memoize=memoize,
67 +
            memoize_key=memoize_key,
64 68
        )
65 69
        self.gpu = gpu
66 70
        if self.gpu:

@@ -49,6 +49,8 @@
Loading
49 49
        See https://spacy.io/usage/processing-pipelines#disabling
50 50
    memoize
51 51
        Memoize preprocessor outputs?
52 +
    memoize_key
53 +
        Hashing function to handle the memoization (default to snorkel.map.core.get_hashable)
52 54
53 55
    Raises
54 56
    ------

@@ -25,7 +25,7 @@
Loading
25 25
26 26
27 27
class LambdaPreprocessor(LambdaMapper):
28 -
    """Convenience class for definining preprocessors from functions.
28 +
    """Convenience class for defining preprocessors from functions.
29 29
30 30
    See ``snorkel.map.core.LambdaMapper`` for details.
31 31
    """

@@ -94,10 +94,10 @@
Loading
94 94
    if "base" not in slice_names:
95 95
        slice_names = slice_names + ["base"]
96 96
97 -
    slice_tasks = []
97 +
    slice_tasks: List[Task] = []
98 98
99 99
    # Keep track of all operations related to slice tasks
100 -
    slice_task_ops = []
100 +
    slice_task_ops: List[Operation] = []
101 101
102 102
    # NOTE: We assume here that the last operation uses the head module
103 103
    # Identify base task head module
@@ -108,7 +108,9 @@
Loading
108 108
        head_module = head_module.module
109 109
110 110
    neck_size = head_module.in_features
111 +
    assert isinstance(neck_size, int)
111 112
    base_task_cardinality = head_module.out_features
113 +
    assert isinstance(base_task_cardinality, int)
112 114
113 115
    # Remove the slice-unaware head module from module pool and op sequence
114 116
    del base_task.module_pool[head_module_op.module_name]

@@ -90,7 +90,7 @@
Loading
90 90
        Name of the LF
91 91
    resources
92 92
        Labeling resources passed in to ``f`` via ``kwargs``
93 -
    preprocessors
93 +
    pre
94 94
        Preprocessors to run on data points before LF execution
95 95
96 96
    Examples

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Unable to process changes.

No base report to compare against.

Files Coverage
snorkel 97.19%
Project Totals (68 files) 97.19%
Loading