Skip to content

Commit

Permalink
adding dryrun option for task scheduling (#8734)
Browse files Browse the repository at this point in the history
* adding dryrun option for task scheduling

* Handle absence of dry_run option

* General exception pylint disable

* add getattr and httpexception
  • Loading branch information
aspiringmind-code authored Oct 14, 2024
1 parent c5d4248 commit a334d7c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
4 changes: 1 addition & 3 deletions src/python/TaskWorker/Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ def main():
raise ConfigException("Configuration not found")

configuration = loadConfigurationFile(os.path.abspath(options.config))
configuration.section_('TaskScheduling')
configuration.TaskScheduling.selection_limit = 10
configuration.TaskScheduling.dry_run= True

status, msg = validateConfig(configuration)
if not status:
raise ConfigException(msg)
Expand Down
19 changes: 12 additions & 7 deletions src/python/TaskWorker/MasterWorker.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,18 @@ def _externalScheduling(self, limit):
# Log the formatted table
self.logger.info('\n%s', table)

if self.config.TaskScheduling.dry_run:
return selected_tasks #dry_run True (with Task Scheduling)
else:
return waiting_tasks #dry_run False (without Task Scheduling)
if getattr(self.config.TaskWorker, 'task_scheduling_dry_run', False):
return waiting_tasks
return selected_tasks

except Exception as e:
self.logger.exception("Exception occurred during external scheduling: %s", str(e))
except HTTPException as hte:
msg = "HTTP Error during external scheduling: %s\n" % str(hte)
msg += "HTTP Headers are %s: " % hte.headers
self.logger.error(msg)
return []

except Exception as e: #pylint: disable=broad-except
self.logger.exception("Unknown Exception occurred during external scheduling: %s", str(e))
return []

def _pruneTaskQueue(self):
Expand Down Expand Up @@ -519,7 +524,7 @@ def algorithm(self):
self.restartQueuedTasks()
self.logger.debug("Master Worker Starting Main Cycle.")
while not self.STOP:
selection_limit = self.config.TaskScheduling.selection_limit
selection_limit = self.config.TaskWorker.task_scheduling_limit
if not self._selectWork(limit=selection_limit):
self.logger.warning("Selection of work failed.")
else:
Expand Down

0 comments on commit a334d7c

Please sign in to comment.