HookBase
and HookHolder
¶
API¶
HookBase ¶
Bases: ParamExtractor
Source code in src/gapper/core/hook.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
__call__ ¶
Add the post test to the problem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
problem | Problem | The problem to add the post test to. | required |
__init__ ¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hook_fn | FnType | The function when the hook is triggered. | required |
as_test_case | bool | Whether to treat the post test as a test case. If this is set to True, this hook will incur a TestResult instance to be created and will then be used to synthesize the score. Therefore, it will also be seen as an entry in gradescope. If this is set to False, it will only have side effects and will not be seen as an entry in gradescope. | True |
kwargs | gap keyword parameters. | {} |
Source code in src/gapper/core/hook.py
process_generator ¶
Process the generator if the hook function returns a generator.
Source code in src/gapper/core/hook.py
tear_down ¶
Tear down the generated generator.
Source code in src/gapper/core/hook.py
HookHolder ¶
Source code in src/gapper/core/hook.py
generate_hooks abstractmethod
¶
Generate the hooks of the given type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hook_type | HookTypes | The type of the hooks. | required |
get_hooks ¶
Get the hooks of the given type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hook_type | HookTypes | The type of the hooks. | required |
get_or_gen_hooks ¶
Get or generate the hooks of the given type. The result is guaranteed to be a list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hook_type | HookTypes | The type of the hooks. | required |
Source code in src/gapper/core/hook.py
run_hooks abstractmethod
¶
Run the hooks of the given type given args and kwargs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hook_type | HookTypes | The type of the hooks. | required |
data | HookDataBase | The data to be passed to the hooks. | required |