Skip to content

Commit

Permalink
Store and display jobs' qgis app version
Browse files Browse the repository at this point in the history
Rename to `qgis_version`

Update qgis version methods docstring

Remove unnecessary `qgis_version` ModelAdmin method

Update docker-app/qfieldcloud/core/models.py

Co-authored-by: Ivan Ivanov <[email protected]>

Fix docstring alignment

Update docker-app/qfieldcloud/core/models.py

Co-authored-by: Ivan Ivanov <[email protected]>
  • Loading branch information
gounux and suricactus committed Feb 6, 2025
1 parent 76428fa commit 7e21ac3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
1 change: 1 addition & 0 deletions docker-app/qfieldcloud/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,7 @@ class JobAdmin(QFieldCloudModelAdmin):
"status",
"error_type",
"type",
"qgis_version",
"created_at",
"updated_at",
"started_at",
Expand Down
24 changes: 24 additions & 0 deletions docker-app/qfieldcloud/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1764,6 +1764,30 @@ def fallback_output(self) -> str:
"The job ended in unknown state. Please verify the project is configured properly, try again and contact QFieldCloud support for more information."
)

@property
def qgis_version(self) -> str | None:
"""Returns QGIS app version used for the job.
The QGIS version is the one coming from the instanciated worker QGIS app.
The version number would be in `Major.Minor.Patch-NAME` format, e.g. 3.40.2-Bratislava
Returns:
str | None: QGIS version if found else None.
"""
if not self.feedback:
return None

feedback_step_data = self.get_feedback_step_data("start_qgis_app")

if not feedback_step_data:
return None

if "qgis_version" in feedback_step_data["returns"]:
qgis_version = feedback_step_data["returns"]["qgis_version"]
return qgis_version

return None

def check_can_be_created(self):
from qfieldcloud.core.permissions_utils import (
check_supported_regarding_owner_account,
Expand Down
3 changes: 3 additions & 0 deletions docker-qgis/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def cmd_package_project(args: argparse.Namespace):
id="start_qgis_app",
name="Start QGIS Application",
method=qfc_worker.utils.start_app,
return_names=["qgis_version"],
),
Step(
id="download_project_directory",
Expand Down Expand Up @@ -250,6 +251,7 @@ def cmd_apply_deltas(args: argparse.Namespace):
id="start_qgis_app",
name="Start QGIS Application",
method=qfc_worker.utils.start_app,
return_names=["qgis_version"],
),
Step(
id="download_project_directory",
Expand Down Expand Up @@ -308,6 +310,7 @@ def cmd_process_projectfile(args: argparse.Namespace):
id="start_qgis_app",
name="Start QGIS Application",
method=qfc_worker.utils.start_app,
return_names=["qgis_version"],
),
Step(
id="download_project_directory",
Expand Down
8 changes: 3 additions & 5 deletions docker-qgis/qfc_worker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def _write_log_message(message, tag, level):
QGISAPP: QgsApplication = None


def start_app():
def start_app() -> str:
"""
Will start a QgsApplication and call all initialization code like
registering the providers and other infrastructure. It will not load
Expand All @@ -158,9 +158,7 @@ def start_app():
Returns
-------
QgsApplication
A QgsApplication singleton
str: QGIS app version that was started.
"""
global QGISAPP

Expand Down Expand Up @@ -192,7 +190,7 @@ def exitQgis():
# we set the `bad_layer_handler` and assume we always have only one single `QgsProject` instance within the job's life
QgsProject.instance().setBadLayerHandler(bad_layer_handler)

return QGISAPP
return Qgis.version()


def stop_app():
Expand Down

0 comments on commit 7e21ac3

Please sign in to comment.