Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
Merge pull request #32 from AnikaBettge/pctemplate_in_pctemplate
Browse files Browse the repository at this point in the history
process chain templates can be used in other process chain templates
  • Loading branch information
anikaweinmann authored May 20, 2020
2 parents b54aecc + fecbc68 commit d7ba659
Showing 1 changed file with 35 additions and 30 deletions.
65 changes: 35 additions & 30 deletions actinia_gdi/api/gdi_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,40 @@ def log_error_to_resource_logger(self, msg, rdc):
)


def set_actinia_modules(self, rdc, pc_list, grass_module_list, actinia_module_list):
new_pc = []
for module in pc_list:
if "module" in module:
name = module["module"]
if name in ["importer", "exporter"]:
new_pc.append(module)
elif name in grass_module_list:
new_pc.append(module)
elif name in actinia_module_list:
module_pc = fillTemplateFromProcessChain(module)
if isinstance(module_pc, str):
# then return value is a missing attribute
msg = ("Required parameter '%s' missing in actinia-module "
" '%s'." % (module_pc, name))
log_error_to_resource_logger(self, msg, rdc)
return
elif module_pc is None:
msg = "Invalid request for %s" % (name)
log_error_to_resource_logger(self, msg, rdc)
return
else:
ac_module_pc = set_actinia_modules(self, rdc, module_pc, grass_module_list, actinia_module_list)
new_pc.extend(ac_module_pc)
else:
msg = ("Module %s is not of type importer, exporter, "
"grass-module or an actinia-module." % name)
log_error_to_resource_logger(self, msg, rdc)
return
else:
new_pc.append(module)
return new_pc


def preprocess_build_pc_and_enqueue(self, preprocess_kwargs, start_job):
""" This method looks up the lists of GRASS GIS and actinia modules to
parse the incoming process chain. If an actinia-module is found, it is
Expand All @@ -100,36 +134,7 @@ def preprocess_build_pc_and_enqueue(self, preprocess_kwargs, start_job):
if rdc:
rdc.set_storage_model_to_file()

new_pc = []
for module in rdc.request_data['list']:
if "module" in module:
name = module["module"]
if name in ["importer", "exporter"]:
new_pc.append(module)
elif name in grass_module_list:
new_pc.append(module)
elif name in actinia_module_list:
module_pc = fillTemplateFromProcessChain(module)
if isinstance(module_pc, str):
# then return value is a missing attribute
msg = ("Required parameter '%s' missing in actinia-module "
" '%s'." % (module_pc, name))
log_error_to_resource_logger(self, msg, rdc)
return
elif module_pc is None:
msg = "Invalid request for %s" % (name)
log_error_to_resource_logger(self, msg, rdc)
return
else:
new_pc.extend(module_pc)
else:
msg = ("Module %s is not of type importer, exporter, "
"grass-module or an actinia-module." % name)
log_error_to_resource_logger(self, msg, rdc)
return
else:
new_pc.append(module)

new_pc = set_actinia_modules(self, rdc, rdc.request_data['list'], grass_module_list, actinia_module_list)
rdc.request_data['list'] = new_pc

enqueue_job(self.job_timeout, start_job, rdc)
Expand Down

0 comments on commit d7ba659

Please sign in to comment.