Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fixes #273] connect resource with execution request #274

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions importer/celery_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ def create_geonode_resource(
handler_module_path, resource, _exec, **kwargs
)

# assign geonode resource to ExectionRequest
orchestrator.update_execution_request_obj(_exec, {"geonode_resource": resource})

# at the end recall the import_orchestrator for the next step
import_orchestrator.apply_async(
(
Expand Down
2 changes: 2 additions & 0 deletions importer/handlers/common/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def import_resource(self, files: dict, execution_id: str, **kwargs):
self.handle_metadata_resource(_exec, dataset, original_handler)

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

orchestrator.evaluate_execution_progress(
execution_id, handler_module_path=str(self)
Expand Down
6 changes: 3 additions & 3 deletions importer/handlers/common/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ def create_geonode_resource(
resource_manager.set_thumbnail(None, instance=saved_dataset)

ResourceBase.objects.filter(alternate=alternate).update(dirty_state=False)

saved_dataset.refresh_from_db()
return saved_dataset

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

def _publish_resource_rollback(self, exec_id, instance_name=None, *args, **kwargs):
Expand Down
5 changes: 5 additions & 0 deletions importer/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@ def update_execution_request_status(
task_args=celery_task_request.args
)

def update_execution_request_obj(self, _exec_obj, payload):
ExecutionRequest.objects.filter(pk=_exec_obj.pk).update(**payload)
_exec_obj.refresh_from_db()
return _exec_obj

def _last_step(self, execution_id, handler_module_path):
"""
Last hookable step for each handler before mark the execution as completed
Expand Down
2 changes: 1 addition & 1 deletion importer/tests/unit/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def test_publish_resource_if_overwrite_should_not_call_the_publishing(
"""
try:
with self.assertRaises(Exception):
get_resource.return_falue = True
get_resource.return_value = True
publish_resources.return_value = True
extract_resource_to_publish.return_value = [
{"crs": 4326, "name": "dataset3"}
Expand Down
Loading