Skip to content

Commit 0cf3a49

Browse files
authored
Merge pull request #431 from biothings/custom-uploader
Extend Manifest
2 parents 48b3697 + 813b9e3 commit 0cf3a49

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

biothings/hub/dataplugin/loaders/dumper.py.tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ from config import DATA_ARCHIVE_ROOT
66

77
from biothings.utils.common import uncompressall
88

9+
import $PLUGIN_MODULE
910

1011
import biothings.hub.dataload.dumper
1112

biothings/hub/dataplugin/loaders/loader.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ def get_dumper_dynamic_class(
271271
dumper_class = self.dumper_registry.get(scheme)
272272
dumper_configuration["BASE_CLASSES"] = "biothings.hub.dataload.dumper.%s" % dumper_class.__name__
273273

274+
dumper_configuration["PLUGIN_MODULE"] = dumper_configuration["BASE_CLASSES"].split(".")[0]
275+
274276
if not dumper_class:
275277
raise LoaderException("No dumper class registered to handle scheme '%s'", scheme)
276278

@@ -438,7 +440,16 @@ def jobs(self):
438440
)
439441
)
440442
else:
441-
confdict["BASE_CLASSES"] = "biothings.hub.dataload.uploader.BaseSourceUploader"
443+
# use specified custom class
444+
klass = uploader_section.get("class")
445+
if klass:
446+
get_class_from_classpath(klass)
447+
confdict["BASE_CLASSES"] = klass
448+
else:
449+
confdict["BASE_CLASSES"] = "biothings.hub.dataload.uploader.BaseSourceUploader"
450+
451+
confdict["PLUGIN_MODULE"] = confdict["BASE_CLASSES"].split(".")[0]
452+
442453
confdict["JOBS_FUNC"] = ""
443454

444455
if uploader_section.get("mapping"):

biothings/hub/dataplugin/loaders/schema/manifest.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@
143143
"disabled": {
144144
"type": "boolean",
145145
"description": "If true, then the dumper will not be run. This is useful for testing purposes or if you want to disable the dumper without removing it from the manifest"
146+
},
147+
"class": {
148+
"type": "string",
149+
"description": "Reference to a locally defined dumper class. Format: 'module:class_name'"
146150
}
147151
},
148152
"required": [
@@ -264,7 +268,11 @@
264268
"examples": [
265269
"parallelizer:parallel_jobs"
266270
]
267-
}
271+
},
272+
"class": {
273+
"type": "string",
274+
"description": "Reference to a locally defined uploader class. Format: 'module:class_name'"
275+
}
268276
},
269277
"required": [
270278
"name",

biothings/hub/dataplugin/loaders/subuploader.py.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import biothings, config
44
biothings.config_for_app(config)
55

66
import biothings.hub.dataload.uploader
7-
7+
import $PLUGIN_MODULE
88

99
$PARSER_FACTORY_CODE
1010

biothings/hub/dataplugin/loaders/uploader.py.tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ biothings.config_for_app(config)
55

66
import biothings.hub.dataload.uploader
77

8+
import $PLUGIN_MODULE
89

910
$PARSER_FACTORY_CODE
1011

0 commit comments

Comments
 (0)