Skip to content

Commit

Permalink
Added option to pass workflow dir to workflows so we can run tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timlinux committed Dec 7, 2024
1 parent c5c2382 commit e016db8
Show file tree
Hide file tree
Showing 20 changed files with 335 additions and 50 deletions.
4 changes: 3 additions & 1 deletion geest/core/workflows/acled_impact_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ def __init__(
cell_size_m: float,
feedback: QgsFeedback,
context: QgsProcessingContext,
working_directory: str = None,
):
"""
Initialize the workflow with attributes and feedback.
:param attributes: Item containing workflow parameters.
:param feedback: QgsFeedback object for progress reporting and cancellation.
:context: QgsProcessingContext object for processing. This can be used to pass objects to the thread. e.g. the QgsProject Instance
:working_directory: Folder containing study_area.gpkg and where the outputs will be placed. If not set will be taken from QSettings.
"""
super().__init__(
item, cell_size_m, feedback, context
item, cell_size_m, feedback, context, working_directory
) # ⭐️ Item is a reference - whatever you change in this item will directly update the tree
self.csv_file = self.attributes.get("use_csv_to_point_layer_csv_file", "")
if not self.csv_file:
Expand Down
7 changes: 4 additions & 3 deletions geest/core/workflows/aggregation_workflow_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@ def __init__(
cell_size_m: float,
feedback: QgsFeedback,
context: QgsProcessingContext,
working_directory: str = None,
):
"""
Initialize the workflow with attributes and feedback.
:param item: Item containing workflow parameters.
:param cell_size_m: Cell size in meters.
:param attributes: Item containing workflow parameters.
:param feedback: QgsFeedback object for progress reporting and cancellation.
:context: QgsProcessingContext object for processing. This can be used to pass objects to the thread. e.g. the QgsProject Instance
:working_directory: Folder containing study_area.gpkg and where the outputs will be placed. If not set will be taken from QSettings.
"""
super().__init__(
item, cell_size_m, feedback, context
item, cell_size_m, feedback, context, working_directory
) # ⭐️ Item is a reference - whatever you change in this item will directly update the tree
self.guids = None # This should be set by the child class - a list of guids of JSONTreeItems to aggregate
self.id = None # This should be set by the child class
Expand Down
7 changes: 4 additions & 3 deletions geest/core/workflows/analysis_aggregation_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ def __init__(
cell_size_m: float,
feedback: QgsFeedback,
context: QgsProcessingContext,
working_directory: str = None,
):
"""
Initialize the workflow with attributes and feedback.
:param item: Item containing workflow parameters.
:param cell_size_m: Cell size in meters.
:param attributes: Item containing workflow parameters.
:param feedback: QgsFeedback object for progress reporting and cancellation.
:context: QgsProcessingContext object for processing. This can be used to pass objects to the thread. e.g. the QgsProject Instance
:working_directory: Folder containing study_area.gpkg and where the outputs will be placed. If not set will be taken from QSettings.
"""
super().__init__(
item, cell_size_m, feedback, context
item, cell_size_m, feedback, context, working_directory
) # ⭐️ Item is a reference - whatever you change in this item will directly update the tree
self.guids = (
self.item.getAnalysisDimensionGuids()
Expand Down
9 changes: 5 additions & 4 deletions geest/core/workflows/classified_polygon_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ def __init__(
cell_size_m: float,
feedback: QgsFeedback,
context: QgsProcessingContext,
working_directory: str = None,
):
"""
Initialize the workflow with attributes and feedback.
:param item: Item containing workflow parameters.
:param cell_size_m: Cell size in meters.
:param attributes: Item containing workflow parameters.
:param feedback: QgsFeedback object for progress reporting and cancellation.
:param context: QgsProcessingContext object for processing. This can be used to pass objects to the thread. e.g. the QgsProject Instance
:context: QgsProcessingContext object for processing. This can be used to pass objects to the thread. e.g. the QgsProject Instance
:working_directory: Folder containing study_area.gpkg and where the outputs will be placed. If not set will be taken from QSettings.
"""
super().__init__(
item, cell_size_m, feedback, context
item, cell_size_m, feedback, context, working_directory
) # ⭐️ Item is a reference - whatever you change in this item will directly update the tree
self.workflow_name = "use_classify_polygon_into_classes"
layer_path = self.attributes.get(
Expand Down
7 changes: 4 additions & 3 deletions geest/core/workflows/dimension_aggregation_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ def __init__(
cell_size_m: float,
feedback: QgsFeedback,
context: QgsProcessingContext,
working_directory: str = None,
):
"""
Initialize the workflow with attributes and feedback.
:param item: Item containing workflow parameters.
:param cell_size_m: Cell size in meters.
:param attributes: Item containing workflow parameters.
:param feedback: QgsFeedback object for progress reporting and cancellation.
:context: QgsProcessingContext object for processing. This can be used to pass objects to the thread. e.g. the QgsProject Instance
:working_directory: Folder containing study_area.gpkg and where the outputs will be placed. If not set will be taken from QSettings.
"""
super().__init__(
item, cell_size_m, feedback, context
item, cell_size_m, feedback, context, working_directory
) # ⭐️ Item is a reference - whatever you change in this item will directly update the tree
self.guids = (
self.item.getDimensionFactorGuids()
Expand Down
7 changes: 4 additions & 3 deletions geest/core/workflows/dont_use_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ def __init__(
cell_size_m: float,
feedback: QgsFeedback,
context: QgsProcessingContext,
working_directory: str = None,
):
"""
Initialize the workflow with attributes and feedback.
:param item: Item containing workflow parameters.
:param cell_size_m: Cell size in meters.
:param attributes: Item containing workflow parameters.
:param feedback: QgsFeedback object for progress reporting and cancellation.
:context: QgsProcessingContext object for processing. This can be used to pass objects to the thread. e.g. the QgsProject Instance
:working_directory: Folder containing study_area.gpkg and where the outputs will be placed. If not set will be taken from QSettings.
"""
super().__init__(
item, cell_size_m, feedback, context
item, cell_size_m, feedback, context, working_directory
) # ⭐️ Item is a reference - whatever you change in this item will directly update the tree
self.workflow_name = "Do Not Use"
self.attributes["result_file"] = ""
Expand Down
6 changes: 4 additions & 2 deletions geest/core/workflows/factor_aggregation_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,21 @@ class FactorAggregationWorkflow(AggregationWorkflowBase):

def __init__(
self,
item: dict,
item: JsonTreeItem,
cell_size_m: float,
feedback: QgsFeedback,
context: QgsProcessingContext,
working_directory: str = None,
):
"""
Initialize the workflow with attributes and feedback.
:param attributes: Item containing workflow parameters.
:param feedback: QgsFeedback object for progress reporting and cancellation.
:context: QgsProcessingContext object for processing. This can be used to pass objects to the thread. e.g. the QgsProject Instance
:working_directory: Folder containing study_area.gpkg and where the outputs will be placed. If not set will be taken from QSettings.
"""
super().__init__(
item, cell_size_m, feedback, context
item, cell_size_m, feedback, context, working_directory
) # ⭐️ Item is a reference - whatever you change in this item will directly update the tree

self.guids = (
Expand Down
7 changes: 4 additions & 3 deletions geest/core/workflows/index_score_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ def __init__(
cell_size_m: float,
feedback: QgsFeedback,
context: QgsProcessingContext,
working_directory: str = None,
):
"""
Initialize the workflow with attributes and feedback.
:param item: Item containing workflow parameters.
:param cell_size_m: Cell size in meters.
:param attributes: Item containing workflow parameters.
:param feedback: QgsFeedback object for progress reporting and cancellation.
:context: QgsProcessingContext object for processing. This can be used to pass objects to the thread. e.g. the QgsProject Instance
:working_directory: Folder containing study_area.gpkg and where the outputs will be placed. If not set will be taken from QSettings.
"""
super().__init__(
item, cell_size_m, feedback, context
item, cell_size_m, feedback, context, working_directory
) # ⭐️ Item is a reference - whatever you change in this item will directly update the tree
self.index_score = float((self.attributes.get("index_score", 0) / 100) * 5)
self.features_layer = True # Normally we would set this to a QgsVectorLayer but in this workflow it is not needed
Expand Down
7 changes: 4 additions & 3 deletions geest/core/workflows/multi_buffer_distances_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,17 @@ def __init__(
cell_size_m: float,
feedback: QgsFeedback,
context: QgsProcessingContext,
working_directory: str = None,
):
"""
Initialize the workflow with attributes and feedback.
:param: item: Item containing workflow parameters.
:cell_size_m: Cell size in meters.
:param attributes: Item containing workflow parameters.
:param feedback: QgsFeedback object for progress reporting and cancellation.
:context: QgsProcessingContext object for processing. This can be used to pass objects to the thread. e.g. the QgsProject Instance
:working_directory: Folder containing study_area.gpkg and where the outputs will be placed. If not set will be taken from QSettings.
"""
super().__init__(
item, cell_size_m, feedback, context
item, cell_size_m, feedback, context, working_directory
) # ⭐️ Item is a reference - whatever you change in this item will directly update the tree
self.workflow_name = "use_multi_buffer_point"
self.distances = self.attributes.get("multi_buffer_travel_distances", None)
Expand Down
7 changes: 4 additions & 3 deletions geest/core/workflows/point_per_cell_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ def __init__(
cell_size_m: float,
feedback: QgsFeedback,
context: QgsProcessingContext,
working_directory: str = None,
):
"""
Initialize the workflow with attributes and feedback.
:param item: Item containing workflow parameters.
:param cell_size_m: Cell size in meters.
:param attributes: Item containing workflow parameters.
:param feedback: QgsFeedback object for progress reporting and cancellation.
:context: QgsProcessingContext object for processing. This can be used to pass objects to the thread. e.g. the QgsProject Instance
:working_directory: Folder containing study_area.gpkg and where the outputs will be placed. If not set will be taken from QSettings.
"""
super().__init__(
item, cell_size_m, feedback, context
item, cell_size_m, feedback, context, working_directory
) # ⭐️ Item is a reference - whatever you change in this item will directly update the tree
self.workflow_name = "use_point_per_cell"
layer_path = self.attributes.get("point_per_cell_shapefile", None)
Expand Down
7 changes: 4 additions & 3 deletions geest/core/workflows/polygon_per_cell_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ def __init__(
cell_size_m: float,
feedback: QgsFeedback,
context: QgsProcessingContext,
working_directory: str = None,
):
"""
Initialize the workflow with attributes and feedback.
:param item: Item containing workflow parameters.
:param cell_size_m: Cell size in meters.
:param attributes: Item containing workflow parameters.
:param feedback: QgsFeedback object for progress reporting and cancellation.
:context: QgsProcessingContext object for processing. This can be used to pass objects to the thread. e.g. the QgsProject Instance
:working_directory: Folder containing study_area.gpkg and where the outputs will be placed. If not set will be taken from QSettings.
"""
super().__init__(
item, cell_size_m, feedback, context
item, cell_size_m, feedback, context, working_directory
) # ⭐️ Item is a reference - whatever you change in this item will directly update the tree
# TODO fix inconsistent abbreviation below for Poly
self.workflow_name = "use_polygon_per_cell"
Expand Down
7 changes: 4 additions & 3 deletions geest/core/workflows/polyline_per_cell_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ def __init__(
cell_size_m: float,
feedback: QgsFeedback,
context: QgsProcessingContext,
working_directory: str = None,
):
"""
Initialize the workflow with attributes and feedback.
:param item: Item containing workflow parameters.
:param cell_size_m: Cell size in meters.
:param attributes: Item containing workflow parameters.
:param feedback: QgsFeedback object for progress reporting and cancellation.
:context: QgsProcessingContext object for processing. This can be used to pass objects to the thread. e.g. the QgsProject Instance
:working_directory: Folder containing study_area.gpkg and where the outputs will be placed. If not set will be taken from QSettings.
"""
super().__init__(
item, cell_size_m, feedback, context
item, cell_size_m, feedback, context, working_directory
) # ⭐️ Item is a reference - whatever you change in this item will directly update the tree
self.workflow_name = "use_polyline_per_cell"

Expand Down
9 changes: 5 additions & 4 deletions geest/core/workflows/raster_reclassification_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ def __init__(
cell_size_m: float,
feedback: QgsFeedback,
context: QgsProcessingContext,
working_directory: str = None,
):
"""
Initialize the workflow with attributes and feedback.
:param item: Item containing workflow parameters.
:param cell_size_m: Cell size in meters.
:param attributes: Item containing workflow parameters.
:param feedback: QgsFeedback object for progress reporting and cancellation.
:param context: QgsProcessingContext object for processing. This can be used to pass objects to the thread. e.g. the QgsProject Instance
:context: QgsProcessingContext object for processing. This can be used to pass objects to the thread. e.g. the QgsProject Instance
:working_directory: Folder containing study_area.gpkg and where the outputs will be placed. If not set will be taken from QSettings.
"""
super().__init__(
item, cell_size_m, feedback, context
item, cell_size_m, feedback, context, working_directory
) # ⭐️ Item is a reference - whatever you change in this item will directly update the tree
self.workflow_name = "use_environmental_hazards"

Expand Down
9 changes: 5 additions & 4 deletions geest/core/workflows/safety_polygon_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ def __init__(
cell_size_m: float,
feedback: QgsFeedback,
context: QgsProcessingContext,
working_directory: str = None,
):
"""
Initialize the workflow with attributes and feedback.
:param item: Item containing workflow parameters.
:param cell_size_m: Cell size in meters.
:param attributes: Item containing workflow parameters.
:param feedback: QgsFeedback object for progress reporting and cancellation.
:param context: QgsProcessingContext object for processing. This can be used to pass objects to the thread. e.g. the QgsProject Instance
:context: QgsProcessingContext object for processing. This can be used to pass objects to the thread. e.g. the QgsProject Instance
:working_directory: Folder containing study_area.gpkg and where the outputs will be placed. If not set will be taken from QSettings.
"""
super().__init__(
item, cell_size_m, feedback, context
item, cell_size_m, feedback, context, working_directory
) # ⭐️ Item is a reference - whatever you change in this item will directly update the tree
self.workflow_name = "use_classify_safety_polygon_into_classes"
layer_path = self.attributes.get(
Expand Down
5 changes: 4 additions & 1 deletion geest/core/workflows/safety_raster_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ def __init__(
cell_size_m: float,
feedback: QgsFeedback,
context: QgsProcessingContext,
working_directory: str = None,
):
"""
Initialize the workflow with attributes and feedback.
:param attributes: Item containing workflow parameters.
:param feedback: QgsFeedback object for progress reporting and cancellation.
:context: QgsProcessingContext object for processing. This can be used to pass objects to the thread. e.g. the QgsProject Instance
:working_directory: Folder containing study_area.gpkg and where the outputs will be placed. If not set will be taken from QSettings.
"""
super().__init__(
item, cell_size_m, feedback, context
item, cell_size_m, feedback, context, working_directory
) # ⭐️ Item is a reference - whatever you change in this item will directly update the tree
self.workflow_name = "use_nighttime_lights"
layer_name = self.attributes.get("nighttime_lights_raster", None)
Expand Down
7 changes: 4 additions & 3 deletions geest/core/workflows/single_point_buffer_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ def __init__(
cell_size_m: float,
feedback: QgsFeedback,
context: QgsProcessingContext,
working_directory: str = None,
):
"""
Initialize the workflow with attributes and feedback.
:param item: Item containing workflow parameters.
:param cell_size_m: Cell size in meters.
:param attributes: Item containing workflow parameters.
:param feedback: QgsFeedback object for progress reporting and cancellation.
:context: QgsProcessingContext object for processing. This can be used to pass objects to the thread. e.g. the QgsProject Instance
:working_directory: Folder containing study_area.gpkg and where the outputs will be placed. If not set will be taken from QSettings.
"""
super().__init__(
item, cell_size_m, feedback, context
item, cell_size_m, feedback, context, working_directory
) # ⭐️ Item is a reference - whatever you change in this item will directly update the tree
self.workflow_name = "use_single_buffer_point"

Expand Down
7 changes: 4 additions & 3 deletions geest/core/workflows/street_lights_buffer_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ def __init__(
cell_size_m: float,
feedback: QgsFeedback,
context: QgsProcessingContext,
working_directory: str = None,
):
"""
Initialize the workflow with attributes and feedback.
:param item: Item containing workflow parameters.
:param cell_size_m: Cell size in meters.
:param attributes: Item containing workflow parameters.
:param feedback: QgsFeedback object for progress reporting and cancellation.
:context: QgsProcessingContext object for processing. This can be used to pass objects to the thread. e.g. the QgsProject Instance
:working_directory: Folder containing study_area.gpkg and where the outputs will be placed. If not set will be taken from QSettings.
"""
super().__init__(
item, cell_size_m, feedback, context
item, cell_size_m, feedback, context, working_directory
) # ⭐️ Item is a reference - whatever you change in this item will directly update the tree
self.workflow_name = "use_street_lights"

Expand Down
Loading

0 comments on commit e016db8

Please sign in to comment.