Skip to content

Commit 9c971cf

Browse files
[Fixes #273] connect resource with execution request
1 parent 13eb26a commit 9c971cf

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

importer/celery_tasks.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ def create_geonode_resource(
367367
handler_module_path, resource, _exec, **kwargs
368368
)
369369

370+
# assign geonode resource to ExectionRequest
371+
orchestrator.update_execution_request_obj(_exec, {"geonode_resource": resource})
372+
370373
# at the end recall the import_orchestrator for the next step
371374
import_orchestrator.apply_async(
372375
(

importer/handlers/common/metadata.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ def import_resource(self, files: dict, execution_id: str, **kwargs):
7878
self.handle_metadata_resource(_exec, dataset, original_handler)
7979

8080
dataset.refresh_from_db()
81+
# assign the resource to the execution_obj
82+
orchestrator.update_execution_request_obj(_exec, {"geonode_resource": dataset})
8183

8284
orchestrator.evaluate_execution_progress(
8385
execution_id, handler_module_path=str(self)

importer/handlers/common/vector.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ def create_geonode_resource(
607607
resource_manager.set_thumbnail(None, instance=saved_dataset)
608608

609609
ResourceBase.objects.filter(alternate=alternate).update(dirty_state=False)
610-
610+
611611
saved_dataset.refresh_from_db()
612612
return saved_dataset
613613

@@ -805,13 +805,13 @@ def _import_resource_rollback(self, exec_id, instance_name=None, *args, **kwargs
805805
"Dynamic model does not exists, removing ogr2ogr table in progress"
806806
)
807807
if instance_name is None:
808-
logger.info("No table created, skipping...")
808+
logger.warning("No table created, skipping...")
809809
return
810810
db_name = os.getenv("DEFAULT_BACKEND_DATASTORE", "datastore")
811811
with connections[db_name].cursor() as cursor:
812812
cursor.execute(f"DROP TABLE {instance_name}")
813813
except Exception as e:
814-
logger.info(e)
814+
logger.warning(e)
815815
pass
816816

817817
def _publish_resource_rollback(self, exec_id, instance_name=None, *args, **kwargs):

importer/orchestrator.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ def update_execution_request_status(
332332
task_args=celery_task_request.args
333333
)
334334

335+
def update_execution_request_obj(self, _exec_obj, payload):
336+
ExecutionRequest.objects.filter(pk=_exec_obj.pk).update(**payload)
337+
_exec_obj.refresh_from_db()
338+
return _exec_obj
339+
335340
def _last_step(self, execution_id, handler_module_path):
336341
"""
337342
Last hookable step for each handler before mark the execution as completed

importer/tests/unit/test_task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def test_publish_resource_if_overwrite_should_not_call_the_publishing(
245245
"""
246246
try:
247247
with self.assertRaises(Exception):
248-
get_resource.return_falue = True
248+
get_resource.return_value = True
249249
publish_resources.return_value = True
250250
extract_resource_to_publish.return_value = [
251251
{"crs": 4326, "name": "dataset3"}

0 commit comments

Comments
 (0)