Commit 9c502ce5d6673552084598f7af45d35cc03d0b2d
1 parent
540555ad
Exists in
master
and in
29 other branches
Fixed to only call tasks if fetch_data is not abstract
Signed-off-by: Sergio Oliveira <sergio@tracy.com.br>
Showing
2 changed files
with
8 additions
and
3 deletions
Show diff stats
colab/plugins/data/base_importer.py
| ... | ... | @@ -11,4 +11,9 @@ class PluginDataImporter(object): |
| 11 | 11 | |
| 12 | 12 | @abc.abstractmethod |
| 13 | 13 | def fetch_data(self): |
| 14 | - raise NotImplementedError('fetchData not yet implemented') | |
| 14 | + raise NotImplementedError | |
| 15 | + fetch_data.is_abstract = True | |
| 16 | + | |
| 17 | + @abc.abstractmethod | |
| 18 | + def app_label(self): | |
| 19 | + raise NotImplementedError | ... | ... |
colab/plugins/data/tasks.py
| ... | ... | @@ -27,10 +27,10 @@ def register_tasks(): |
| 27 | 27 | |
| 28 | 28 | for item_name in dir(module): |
| 29 | 29 | item = getattr(module, item_name) |
| 30 | - if item is PluginDataImporter: | |
| 31 | - continue | |
| 32 | 30 | |
| 33 | 31 | if callable(getattr(item, 'fetch_data', None)): |
| 32 | + if getattr(item.fetch_data, 'is_abstract', False): | |
| 33 | + continue | |
| 34 | 34 | instance = item() |
| 35 | 35 | task_name = '{}.{}'.format(module.__name__, item_name) |
| 36 | 36 | task = app.task(name=task_name, bind=True)(instance.fetch_data) | ... | ... |