'Python: what is "@main.result_callback()"?
i'm trying to understand how that python code works. In particular i'm referring to that part (from line 27):
def main(**kwargs):
pass
@main.result_callback()
def run(methods, results_path, gpu, seed, save_segmentation_images):
methods = {key: item for (key, item) in methods}
...
What i don't understand is where the parameter methods is taken from. All the other parameters are command line parameters obtained through the library "click", as you can see in the complete code linked before. I'm sorry if the question is generic but i can't find anything related to this @main.result_callback() thing used here. I don't even understand if it's from "click" or not
Solution 1:[1]
The interesting part here is what you did not show:
@click.group(chain=True)
...
def main(**kwargs):
pass
The main function is wrapped by a decorator and becomes a click.MultiCommand. This MultiCommand can have callback functions and they are defined by the .result_callback() decorator.
See the documentation on result_callback for more details.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
