Skip to content

Commit

Permalink
add progress when preparing input layers
Browse files Browse the repository at this point in the history
  • Loading branch information
danangmassandy committed May 30, 2024
1 parent 713567b commit 012976e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions django_project/cplus_api/utils/worker_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ def __init__(self, task_config: TaskConfig,
self.scenario_task = scenario_task
self.last_update_progress = None
self.downloaded_layers = {}
self.downloaded_layer_count = 0

def prepare_run(self):
# clear existing scenario directory if exists
Expand All @@ -416,6 +417,8 @@ def prepare_run(self):
def initialize_input_layers(self, scenario_path: str):
self.log_message(
f'Initialize input layers: {self.task_config.total_input_layers}')
self.set_custom_progress(0)
self.set_status_message('Preparing input layers')

# init priority layers
priority_layer_paths = {}
Expand Down Expand Up @@ -522,6 +525,7 @@ def initialize_input_layers(self, scenario_path: str):
'Finished copy input layers: '
f'{self.task_config.total_input_layers}'
)
self.set_custom_progress(100)

def copy_input_layers_by_uuids(
self, component_type: InputLayer.ComponentTypes,
Expand All @@ -534,8 +538,19 @@ def copy_input_layers_by_uuids(
layers = layers.filter(
component_type=component_type
)
total_input_layers = (
self.task_config.total_input_layers if
self.task_config.total_input_layers > 0 else 1
)
for layer in layers:
file_path = layer.download_to_working_directory(scenario_path)
self.downloaded_layer_count += 1
self.set_custom_progress(
100 * (
self.downloaded_layer_count /
total_input_layers
)
)
if not file_path:
continue
if not os.path.exists(file_path):
Expand Down

0 comments on commit 012976e

Please sign in to comment.